/* ====== ChatGPT-like Refresh – BizGPT ====== */
/* Font & base */
#chatbot-chatgpt, #chatbot-chatgpt * {
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  box-sizing: border-box;
}

/* Khung tổng */
#chatbot-chatgpt.chatbot-embedded-style {
  position: relative !important;
  display: flex !important;
  flex-direction: column;
  width: 100% !important;
  height: 70vh !important;
  max-height: 90vh !important;
  margin: 16px auto;
  padding: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.08);
  overflow: hidden;
}

/* Header */
#chatbot-chatgpt-header-embedded {
  background: #343541;
  color: #fff;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  border: none;
}

/* Tiêu đề */
#chatbot-chatgpt-title.title {
  color: #fff;
  font-size: 14px;
  line-height: 1;
}

/* Vùng hội thoại */
#chatbot-chatgpt-conversation {
  flex: 1 1 auto;
  background: #f7f7f8;
  padding: 20px 16px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* Scrollbar tinh gọn */
#chatbot-chatgpt-conversation::-webkit-scrollbar { width: 8px; }
#chatbot-chatgpt-conversation::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 8px; }
#chatbot-chatgpt-conversation::-webkit-scrollbar-track { background: transparent; }

/* Message container cũ (tôn trọng cấu trúc hiện có) */
.chat-message { 
  margin: 8px 0; 
  display: flex; 
  width: 100%;
}

/* Bên phải cho user, trái cho bot */
.user-message { justify-content: flex-end; }
.bot-message  { justify-content: flex-start; }

/* Bong bóng – user */
.chatbot-user-text {
  display: inline-block;
  background: #10a37f; /* xanh ChatGPT */
  color: #fff;
  padding: 10px 14px;
  border-radius: 14px 14px 2px 14px;
  max-width: 85%;
  line-height: 1.45;
  font-size: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  box-shadow: 0 2px 12px rgba(16,163,127,0.22);
}

/* Bong bóng – bot */
.chatbot-bot-text,
.chatbot-typing-indicator {
  display: inline-block;
  background: #ffffff;
  color: #111827;
  padding: 10px 14px;
  border-radius: 14px 14px 14px 2px;
  max-width: 85%;
  line-height: 1.6;
  font-size: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  border: 1px solid #eef2f7;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}

/* Error */
.error-message {
  display: inline-block;
  background: #fee2e2;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid #fecaca;
}

/* Input area wrapper (giữ nguyên id) */
#chatbot-chatgpt-input {
  position: relative;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Cột chứa textarea (giữ nguyên id) */
#chatbot-chatgpt-input-area {
  flex: 1 1 auto;
  max-width: 100%;
}
/* input bar sticky (đã có) */
#chatbot-chatgpt-input {
  position: sticky;
  bottom: 0;
  z-index: 2;
}

/* hàng nút sticky ngay dưới input (nếu bạn muốn nó cũng luôn hiển thị) */
#chatbot-chatgpt-buttons-container {
  position: sticky;
  bottom: 0;           /* hoặc 44px nếu muốn nằm ngay dưới textarea */
  background: var(--bg, #fff);
  z-index: 2;
  border-top: 1px solid var(--border, #e5e7eb);
}

/* Textarea (giữ nguyên id) */
#chatbot-chatgpt-message {
  width: 100%;
  min-height: 44px;
  max-height: 160px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #111827;
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  resize: none;   /* dùng autosize JS */
  font-size: 14px;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}
#chatbot-chatgpt-message:focus {
  background: #fff;
  border-color: #10a37f;
  box-shadow: 0 0 0 3px rgba(16,163,127,0.2);
}

/* Hàng nút (giữ nguyên id + các button id hiện có) */
#chatbot-chatgpt-buttons-container {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 12px 12px;
  flex-wrap: wrap;
}

/* Nút chung */
#chatbot-chatgpt-buttons-container button,
#chatbot-chatgpt-submit,
#chatbot-chatgpt-upload-file,
#chatbot-chatgpt-upload-mp3,
#chatbot-chatgpt-erase-btn,
#chatbot-chatgpt-text-to-speech-btn,
#chatbot-chatgpt-speech-recognition-btn,
#chatbot-chatgpt-download-transcript-btn {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  color: #111827;
  height: 38px;
  min-width: 38px;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s, border-color 0.2s, transform 0.04s ease-in-out;
}

#chatbot-chatgpt-buttons-container button:hover,
#chatbot-chatgpt-submit:hover,
#chatbot-chatgpt-upload-file:hover,
#chatbot-chatgpt-upload-mp3:hover,
#chatbot-chatgpt-erase-btn:hover,
#chatbot-chatgpt-text-to-speech-btn:hover,
#chatbot-chatgpt-speech-recognition-btn:hover,
#chatbot-chatgpt-download-transcript-btn:hover {
  background: #e9eef1;
  border-color: #dbe3ea;
}

#chatbot-chatgpt-buttons-container button:active,
#chatbot-chatgpt-submit:active { transform: translateY(1px); }

/* Nút gửi làm nổi bật hơn một chút */
#chatbot-chatgpt-submit {
  background: #10a37f;
  border-color: #10a37f;
  color: #fff;
}
#chatbot-chatgpt-submit:hover {
  background: #0d8a6b;
  border-color: #0d8a6b;
}

/* Icon trong nút */
#chatbot-chatgpt-buttons-container img,
#chatbot-chatgpt-submit img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: block;
}

/* Typing indicator (giữ nguyên class cũ nhưng làm lại style) */
.chatbot-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 14px 14px 14px 2px;
  background: #ffffff;
  border: 1px solid #eef2f7;
}
.chatbot-typing-dot {
  width: 6px; height: 6px;
  background: #6b7280;
  border-radius: 50%;
  animation: typingBlink 1s infinite;
}
.chatbot-typing-dot:nth-child(2) { animation-delay: .15s; }
.chatbot-typing-dot:nth-child(3) { animation-delay: .3s; }

@keyframes typingBlink {
  0%, 80%, 100% { opacity: .2; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* Markdown/code trong bot message (nếu có render HTML) */
.chatbot-bot-text pre, .chatbot-bot-text code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  background: #0b10211a;
  color: #0b1021;
  padding: 2px 6px;
  border-radius: 6px;
}
.chatbot-bot-text pre {
  display: block;
  padding: 10px;
  overflow-x: auto;
}

/* Mobile */
@media (max-width: 640px) {
  #chatbot-chatgpt.chatbot-embedded-style { height: 75vh !important; border-radius: 12px; }
  #chatbot-chatgpt-conversation { padding: 14px 12px; }
  .chatbot-bot-text, .chatbot-user-text { max-width: 100%; }
}
/* ==== Fade-in cho mỗi tin nhắn ==== */
.kchat-appear {
  opacity: 0;
  transform: translateY(6px);
  animation: kchatFadeIn .28s ease-out forwards;
}
@keyframes kchatFadeIn {
  to { opacity: 1; transform: none; }
}

/* ==== Fullscreen mode ==== */
#chatbot-chatgpt.kchat-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  z-index: 999999999 !important;
  box-shadow: none !important;
}
#chatbot-chatgpt.kchat-fullscreen #chatbot-chatgpt-conversation {
  padding: 24px 20px;
}
#chatbot-chatgpt.kchat-fullscreen #chatbot-chatgpt-header-embedded {
  border-radius: 0;
}
body.kchat-no-scroll { overflow: hidden; }

/* Nút Fullscreen nhỏ gọn (nếu muốn khác màu hãy đổi ở đây) */
#chatbot-chatgpt-fullscreen-btn {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  color: #111827;
  height: 38px;
  min-width: 38px;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .2s, border-color .2s, transform .04s;
}
#chatbot-chatgpt-fullscreen-btn:hover {
  background: #e9eef1;
  border-color: #dbe3ea;
}
#chatbot-chatgpt-fullscreen-btn:active { transform: translateY(1px); }

/* Icon trong nút */
#chatbot-chatgpt-fullscreen-btn svg {
  width: 18px; height: 18px; display: block;
}

/* ===== Bridge CSS: map kchat-* -> style mới ===== */

/* Hàng hội thoại */
#chatbot-chatgpt .kchat-msg { display:flex; width:100%; margin:8px 0; }
#chatbot-chatgpt .kchat-user { justify-content:flex-end; }
#chatbot-chatgpt .kchat-assistant { justify-content:flex-start; }

/* Avatar tròn nhỏ */
#chatbot-chatgpt .kchat-avatar{
  width:28px; height:28px; flex:0 0 28px;
  border-radius:50%; background:#10a37f; color:#fff;
  display:flex; align-items:center; justify-content:center;
  font-weight:700; font-size:12px; margin:2px 8px 0 0;
}
#chatbot-chatgpt .kchat-assistant .kchat-avatar{ background:#111827; }

/* Bong bóng theo .kchat-bubble */
#chatbot-chatgpt .kchat-bubble{
  max-width:86%;
  background:var(--panel,#fff);
  border:1px solid var(--panel-border,#e5e7eb);
  color:var(--text,#111827);
  padding:10px 14px; line-height:1.55; font-size:14px;
  border-radius:14px 14px 14px 2px;
  box-shadow:0 2px 10px rgba(0,0,0,.04);
 overflow-wrap:anywhere;
}
#chatbot-chatgpt .kchat-user .kchat-bubble{
  background:#10a37f; color:#fff; border-color:#10a37f;
  border-radius:14px 14px 2px 14px;
  box-shadow:0 2px 12px rgba(16,163,127,.22);
}

/* Nội dung trong bong bóng */
#chatbot-chatgpt .kchat-content{ display:block; }
#chatbot-chatgpt .kchat-bubble pre,
#chatbot-chatgpt .kchat-bubble code{
  font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;
  background:rgba(11,16,33,.06); border-radius:8px; color:inherit;
}
#chatbot-chatgpt .kchat-bubble code{ padding:2px 6px; font-size:13px; }
#chatbot-chatgpt .kchat-bubble pre{ padding:10px; overflow-x:auto; }

/* Typing (khớp .js-typing .typing .dot) */
#chatbot-chatgpt .js-typing .typing{
  display:inline-flex; align-items:center; gap:6px;
  background:#fff; border:1px solid #e5e7eb;
  border-radius:14px 14px 14px 2px; padding:10px 14px;
}
#chatbot-chatgpt .js-typing .dot{
  width:6px; height:6px; border-radius:50%; background:#6b7280;
  animation:kTyping 1s infinite;
}
#chatbot-chatgpt .js-typing .dot:nth-child(2){ animation-delay:.15s; }
#chatbot-chatgpt .js-typing .dot:nth-child(3){ animation-delay:.3s; }
@keyframes kTyping{0%,80%,100%{opacity:.2;transform:translateY(0)}40%{opacity:1;transform:translateY(-2px)}}

/* Tools bên trong bong bóng bot (nút COPY…) */
#chatbot-chatgpt .kchat-tools{
  display:flex; gap:8px; margin-top:6px; flex-wrap:wrap;
}
#chatbot-chatgpt .kchat-tools .kchat-btn{
  height:30px; padding:4px 10px; line-height:1;
  background:#f3f4f6; border:1px solid #e5e7eb; color:#111827;
  border-radius:8px; cursor:pointer; display:inline-flex; align-items:center; gap:6px;
}
#chatbot-chatgpt .kchat-tools .kchat-btn:hover{
  background:#e9eef1; border-color:#dbe3ea;
}

/* Thanh input + hàng icon dưới cùng */
#chatbot-chatgpt #chatbot-chatgpt-input{ align-items:center; gap:10px; }
#chatbot-chatgpt #chatbot-chatgpt-buttons-container{
  display:flex; align-items:center; gap:8px; padding:8px 12px; flex-wrap:wrap;
}
#chatbot-chatgpt #chatbot-chatgpt-buttons-container button,
#chatbot-chatgpt .kchat-action{
  height:38px; min-width:38px; padding:6px 10px;
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  background:#f3f4f6; border:1px solid #e5e7eb; color:#111827;
  border-radius:10px; cursor:pointer; transition:background .2s,border-color .2s,transform .04s;
}
#chatbot-chatgpt #chatbot-chatgpt-buttons-container button:hover,
#chatbot-chatgpt .kchat-action:hover{ background:#e9eef1; border-color:#dbe3ea; }
#chatbot-chatgpt #chatbot-chatgpt-buttons-container img,
#chatbot-chatgpt .kchat-action img{ width:18px; height:18px; display:block; object-fit:contain; }

/* Ô nhập */
#chatbot-chatgpt #chatbot-chatgpt-message{
  width:100%; min-height:44px; max-height:180px; resize:none;
  border-radius:10px; border:1px solid #e5e7eb; background:#f9fafb; color:#111827;
  padding:10px 12px; outline:none; transition:background .2s,border-color .2s,box-shadow .2s;
}
#chatbot-chatgpt #chatbot-chatgpt-message:focus{
  background:#fff; border-color:#10a37f; box-shadow:0 0 0 3px rgba(16,163,127,.2);
}

/* 1) Đừng kéo giãn bubble theo trục cross của flex row */
#chatbot-chatgpt .kchat-msg { 
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;   /* <-- quan trọng */
  gap: 8px;
}

/* 2) Bubble là inline-block, tự cao theo content, không stretch */
#chatbot-chatgpt .kchat-bubble{
  display: inline-block;     /* <-- quan trọng */
  position: relative;
  max-width: 86%;
  width: auto;               /* thay cho width:fit-content để khỏi kén browser */
  padding: 12px 60px 12px 14px; /* chừa góc phải cho nút */
  line-height: 1.55;
  min-height: auto !important;
}

/* 3) Nút COPY là overlay, không chiếm dòng → bubble không bị đội cao */
#chatbot-chatgpt .kchat-tools{
  position: absolute;
  top: 10px; right: 10px;
  margin: 0; padding: 0;
  display: inline-flex; gap: 6px;
}
#chatbot-chatgpt .kchat-tools .kchat-btn{
  height: 28px; padding: 0 10px; font-size: 12px; border-radius: 8px;
}

/* 4) Nén margin mặc định bên trong content để không “nở” chiều cao */
#chatbot-chatgpt .kchat-content p{ margin: .4em 0; }
#chatbot-chatgpt .kchat-content > :first-child{ margin-top: 0; }
#chatbot-chatgpt .kchat-content > :last-child{ margin-bottom: 0; }
