/* ============================================================
   chatbot.css — Floating Chat Widget Tư vấn Tuyển sinh
   Thiết kế: Glassmorphism, Gradient tím-xanh, Dark mode
   ============================================================ */

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ─── 1. BUBBLE NÚT MỞ ─────────────────────────────────── */
#chatbot-bubble {
  position: fixed;
  bottom: 28px;
  right: 24px;
  z-index: 10000;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6C63FF 0%, #48CAE4 100%);
  box-shadow: 0 6px 28px rgba(108,99,255,.50), 0 2px 8px rgba(0,0,0,.18);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .25s;
  font-size: 26px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#chatbot-bubble:hover {
  transform: scale(1.12);
  box-shadow: 0 10px 36px rgba(108,99,255,.60), 0 4px 12px rgba(0,0,0,.20);
}
#chatbot-bubble.chatbot-open {
  transform: scale(.9) rotate(15deg);
}
/* Badge số tin chưa đọc */
#chatbot-bubble .cb-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #F97316;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  min-width: 19px;
  height: 19px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid #fff;
  pointer-events: none;
  opacity: 0;
  transform: scale(.3);
  transition: opacity .2s, transform .3s cubic-bezier(.34,1.56,.64,1);
}
#chatbot-bubble .cb-badge.show {
  opacity: 1;
  transform: scale(1);
}

/* ─── 2. PANEL CHÍNH ────────────────────────────────────── */
#chatbot-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  z-index: 9999;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0,0,0,.18), 0 4px 16px rgba(108,99,255,.12);
  transform-origin: bottom right;
  transform: scale(.6) translateY(40px);
  opacity: 0;
  pointer-events: none;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .25s ease;
  font-family: 'Inter', sans-serif;
}
#chatbot-panel.cb-visible {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
/* Dark mode */
#chatbot-panel.cb-dark {
  background: #1A1B2E;
  color: #E8E8F0;
}

/* ─── 3. HEADER ─────────────────────────────────────────── */
.cb-header {
  background: linear-gradient(135deg, #6C63FF 0%, #48CAE4 100%);
  padding: 14px 16px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.cb-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.4);
}
.cb-header-info { flex: 1; min-width: 0; }
.cb-header-name {
  color: #fff;
  font-size: .88rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cb-header-sub {
  color: rgba(255,255,255,.75);
  font-size: .70rem;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
}
.cb-online-dot {
  width: 6px;
  height: 6px;
  background: #4ADE80;
  border-radius: 50%;
  animation: cbPulse 1.8s infinite;
}
@keyframes cbPulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: .5; transform: scale(.8); }
}
.cb-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.cb-header-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: rgba(255,255,255,.15);
  color: #fff;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .15s;
}
.cb-header-btn:hover {
  background: rgba(255,255,255,.30);
  transform: scale(1.1);
}

/* ─── 4. STUDENT INFO BAR ──────────────────────────────── */
#cb-student-bar {
  background: linear-gradient(90deg, #F0F4FF 0%, #E8F7FF 100%);
  border-bottom: 1px solid #E2E8F0;
  padding: 8px 14px;
  font-size: .74rem;
  color: #475569;
  display: none;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
#cb-student-bar .cb-student-name {
  font-weight: 700;
  color: #1E3A5F;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#cb-student-bar .cb-student-class {
  background: #6C63FF;
  color: #fff;
  border-radius: 6px;
  padding: 1px 7px;
  font-size: .66rem;
  font-weight: 600;
  flex-shrink: 0;
}
#cb-student-bar .cb-remaining {
  margin-left: auto;
  color: #94A3B8;
  font-size: .68rem;
  flex-shrink: 0;
}
#cb-student-bar.show { display: flex; }
.cb-dark #cb-student-bar {
  background: #1E2035;
  border-bottom-color: #2A2B40;
  color: #94A3B8;
}
.cb-dark #cb-student-bar .cb-student-name { color: #C5C6E8; }

/* ─── 5. SBD GATE ──────────────────────────────────────── */
#cb-sbd-gate {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  gap: 16px;
  text-align: center;
}
.cb-gate-icon {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6C63FF20, #48CAE420);
  border: 2px solid #6C63FF30;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}
.cb-gate-title {
  font-size: .95rem;
  font-weight: 700;
  color: #1E3A5F;
  line-height: 1.4;
}
.cb-dark .cb-gate-title { color: #C5C6E8; }
.cb-gate-desc {
  font-size: .78rem;
  color: #64748B;
  line-height: 1.5;
}
.cb-dark .cb-gate-desc { color: #6B7280; }
.cb-sbd-input-wrap {
  width: 100%;
  display: flex;
  gap: 8px;
}
.cb-sbd-input {
  flex: 1;
  height: 44px;
  border: 1.5px solid #CBD5E1;
  border-radius: 12px;
  padding: 0 14px;
  font-size: .88rem;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  background: #fff;
  color: #0F172A;
}
.cb-sbd-input:focus {
  border-color: #6C63FF;
  box-shadow: 0 0 0 3px rgba(108,99,255,.12);
}
.cb-dark .cb-sbd-input {
  background: #252640;
  border-color: #3A3B55;
  color: #E8E8F0;
}
.cb-dark .cb-sbd-input:focus { border-color: #6C63FF; }
.cb-sbd-btn {
  height: 44px;
  padding: 0 18px;
  background: linear-gradient(135deg, #6C63FF, #48CAE4);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: .84rem;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: opacity .2s, transform .15s;
  white-space: nowrap;
}
.cb-sbd-btn:hover { opacity: .9; transform: scale(1.03); }
.cb-sbd-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.cb-gate-error {
  width: 100%;
  background: #FEF2F2;
  color: #DC2626;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: .78rem;
  display: none;
  text-align: left;
}
.cb-gate-error.show { display: block; }

/* ─── 6. KHU VỰC TIN NHẮN ─────────────────────────────── */
#cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: none;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
#cb-messages.show { display: flex; }
#cb-messages::-webkit-scrollbar { width: 4px; }
#cb-messages::-webkit-scrollbar-track { background: transparent; }
#cb-messages::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 4px;
}
.cb-dark #cb-messages::-webkit-scrollbar-thumb { background: #3A3B55; }

/* Bubble tin nhắn */
.cb-msg {
  display: flex;
  gap: 8px;
  animation: cbMsgIn .25s ease;
}
@keyframes cbMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cb-msg.user { flex-direction: row-reverse; }
.cb-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6C63FF, #48CAE4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}
.cb-msg.user .cb-msg-avatar {
  background: linear-gradient(135deg, #F97316, #FBBF24);
}
.cb-msg-content { max-width: 78%; }
.cb-msg-bubble {
  padding: 9px 13px;
  border-radius: 16px;
  font-size: .82rem;
  line-height: 1.55;
  word-break: break-word;
}
/* AI bubble — trái */
.cb-msg.ai .cb-msg-bubble {
  background: #F1F5FF;
  color: #1E3A5F;
  border-bottom-left-radius: 4px;
}
.cb-dark .cb-msg.ai .cb-msg-bubble {
  background: #252640;
  color: #C5C6E8;
}
/* User bubble — phải */
.cb-msg.user .cb-msg-bubble {
  background: linear-gradient(135deg, #6C63FF, #48CAE4);
  color: #fff;
  border-bottom-right-radius: 4px;
  text-align: right;
}
.cb-msg-time {
  font-size: .62rem;
  color: #94A3B8;
  margin-top: 3px;
  padding: 0 2px;
}
.cb-msg.user .cb-msg-time { text-align: right; }
/* Markdown trong bubble AI */
.cb-msg-bubble p { margin: 0 0 6px; }
.cb-msg-bubble p:last-child { margin-bottom: 0; }
.cb-msg-bubble ul, .cb-msg-bubble ol {
  margin: 4px 0 4px 16px;
  padding: 0;
}
.cb-msg-bubble li { margin-bottom: 2px; }
.cb-msg-bubble strong { font-weight: 700; }
.cb-msg-bubble code {
  background: rgba(108,99,255,.12);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: .8em;
}
.cb-msg-bubble h3 {
  font-size: .84rem;
  margin: 8px 0 4px;
  color: #6C63FF;
}
.cb-dark .cb-msg-bubble h3 { color: #9087FF; }

/* Typing animation */
.cb-typing {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.cb-typing-dots {
  background: #F1F5FF;
  padding: 10px 14px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 4px;
  align-items: center;
}
.cb-dark .cb-typing-dots { background: #252640; }
.cb-typing-dot {
  width: 7px;
  height: 7px;
  background: #6C63FF;
  border-radius: 50%;
  animation: cbDot 1.2s infinite;
}
.cb-typing-dot:nth-child(2) { animation-delay: .2s; }
.cb-typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes cbDot {
  0%,80%,100% { transform: translateY(0); opacity: .4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* ─── 7. QUICK SUGGESTIONS ─────────────────────────────── */
#cb-suggestions {
  padding: 0 14px 8px;
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}
#cb-suggestions.show { display: flex; }
.cb-suggest-btn {
  background: #EEF2FF;
  color: #4F46E5;
  border: 1px solid #C7D2FE;
  border-radius: 16px;
  padding: 5px 11px;
  font-size: .72rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, transform .15s;
  white-space: nowrap;
}
.cb-suggest-btn:hover {
  background: #6C63FF;
  color: #fff;
  border-color: #6C63FF;
  transform: scale(1.04);
}
.cb-dark .cb-suggest-btn {
  background: #252640;
  color: #9087FF;
  border-color: #3A3B55;
}
.cb-dark .cb-suggest-btn:hover {
  background: #6C63FF;
  color: #fff;
}

/* ─── 8. INPUT BAR ──────────────────────────────────────── */
.cb-input-bar {
  padding: 10px 12px 14px;
  border-top: 1px solid #F1F5F9;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: #fff;
}
.cb-dark .cb-input-bar {
  background: #1A1B2E;
  border-top-color: #252640;
}
.cb-input-wrap { flex: 1; position: relative; }
#cb-input {
  width: 100%;
  min-height: 40px;
  max-height: 100px;
  border: 1.5px solid #E2E8F0;
  border-radius: 12px;
  padding: 9px 36px 9px 12px;
  font-size: .83rem;
  font-family: 'Inter', sans-serif;
  outline: none;
  resize: none;
  transition: border-color .2s, box-shadow .2s;
  background: #F8FAFC;
  color: #0F172A;
  line-height: 1.45;
  overflow-y: auto;
  box-sizing: border-box;
}
#cb-input:focus {
  border-color: #6C63FF;
  box-shadow: 0 0 0 3px rgba(108,99,255,.10);
  background: #fff;
}
.cb-dark #cb-input {
  background: #252640;
  border-color: #3A3B55;
  color: #E8E8F0;
}
.cb-dark #cb-input:focus { background: #2A2B42; border-color: #6C63FF; }
#cb-input::placeholder { color: #94A3B8; }
.cb-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6C63FF, #48CAE4);
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .2s, transform .15s;
  flex-shrink: 0;
}
.cb-send-btn:hover:not(:disabled) { opacity: .88; transform: scale(1.08); }
.cb-send-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.cb-rate-info {
  width: 100%;
  text-align: center;
  font-size: .67rem;
  color: #94A3B8;
  margin-top: 4px;
}
.cb-dark .cb-rate-info { color: #4B5563; }

/* ─── 9. MOBILE RESPONSIVE ─────────────────────────────── */
@media (max-width: 480px) {
  #chatbot-panel {
    right: 0; left: 0;
    bottom: 80px;
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    height: calc(100vh - 90px);
    max-height: none;
  }
  #chatbot-bubble { right: 16px; bottom: 20px; }
}
