/* ==========================================================================
   CSV STUDIO — LUXURY DARK AI CHATBOT
   Đồng bộ 100% nhận diện thương hiệu CSV Studio (Brand Orange #f97316 & Dark Bg #0b0f19)
   ========================================================================== */

:root {
  --cb-primary: #f97316;
  --cb-primary-dark: #ea580c;
  --cb-primary-hover: #fb923c;
  --cb-primary-glow: rgba(249, 115, 22, 0.35);
  --cb-teal: #06b6d4;
  --cb-bg-panel: #0d131f;
  --cb-bg-header: #101726;
  --cb-bg-messages: #080d16;
  --cb-bg-card: #131926;
  --cb-text-light: #f8fafc;
  --cb-text-muted: #94a3b8;
  --cb-border: rgba(255, 255, 255, 0.08);
  --cb-border-focus: #f97316;
  --cb-radius: 22px;
  --cb-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* 1. FLOATING CHAT BUTTON (Ở giữa arcontactus và back-to-top như mẫu) */
.cb-floating-btn {
  position: fixed;
  bottom: 82px;
  right: 16px;
  left: auto;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-primary-dark) 100%);
  border: none;
  color: #ffffff !important;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 99990;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
  outline: none;
}

.cb-floating-btn:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 30px rgba(249, 115, 22, 0.55);
}

.cb-floating-btn svg {
  width: 22px;
  height: 22px;
  stroke: #ffffff;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.cb-icon-bot,
.cb-icon-close {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}

.cb-icon-close {
  display: none !important;
}

.cb-floating-btn.active .cb-icon-bot {
  display: none !important;
}

.cb-floating-btn.active .cb-icon-close {
  display: flex !important;
  transform: rotate(90deg);
}

/* Ping notification indicator (Chấm vàng viền trắng góc trên phải như mẫu) */
.cb-ping-dot {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 13px;
  height: 13px;
  background-color: #f59e0b;
  border: 2px solid #ffffff;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
}

.cb-ping-dot::after {
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid #f59e0b;
  animation: cb-ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes cb-ping {
  75%, 100% {
    transform: scale(2.2);
    opacity: 0;
  }
}

.cb-floating-btn.active .cb-ping-dot {
  display: none;
}

/* 2. CHAT PANEL */
.cb-chat-panel {
  position: fixed;
  bottom: 140px;
  right: 16px;
  left: auto;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 165px);
  background: var(--cb-bg-panel);
  border: 1px solid var(--cb-border);
  border-radius: var(--cb-radius);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  z-index: 99991;
  overflow: hidden;
  font-family: var(--cb-font);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s ease;
}

.cb-chat-panel.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* 3. HEADER */
.cb-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.12) 0%, rgba(6, 182, 212, 0.05) 100%), var(--cb-bg-header);
  border-bottom: 1px solid var(--cb-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.cb-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cb-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-primary-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px var(--cb-primary-glow);
}

.cb-header-avatar svg {
  width: 22px;
  height: 22px;
  stroke: #ffffff;
  stroke-width: 2;
  fill: none;
}

.cb-header-meta {
  display: flex;
  flex-direction: column;
}

.cb-header-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--cb-text-light);
  line-height: 1.3;
}

.cb-header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.cb-status-dot {
  width: 8px;
  height: 8px;
  background-color: #22c55e;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px #22c55e;
}

.cb-header-subtitle {
  font-size: 12px;
  color: var(--cb-text-muted);
}

.cb-close-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--cb-border);
  cursor: pointer;
  padding: 6px;
  color: var(--cb-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.cb-close-btn:hover {
  color: var(--cb-text-light);
  background: rgba(255, 255, 255, 0.12);
}

.cb-close-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

/* 4. MESSAGES CONTAINER */
.cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--cb-bg-messages);
  scroll-behavior: smooth;
}

.cb-messages::-webkit-scrollbar {
  width: 5px;
}

.cb-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

/* Message Rows */
.cb-msg-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: cb-fade-in 0.25s ease forwards;
}

@keyframes cb-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cb-msg-row.user {
  flex-direction: row-reverse;
}

.cb-msg-avatar {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-primary-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
}

.cb-msg-avatar svg {
  width: 17px;
  height: 17px;
  stroke: #ffffff;
  stroke-width: 2;
  fill: none;
}

.cb-msg-avatar-status {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 8px;
  height: 8px;
  background-color: #22c55e;
  border: 1.5px solid var(--cb-bg-messages);
  border-radius: 50%;
}

/* Message Bubbles */
.cb-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.6;
  word-break: break-word;
}

.cb-bubble-bot {
  background: var(--cb-bg-card);
  color: #e2e8f0;
  border: 1px solid var(--cb-border);
  border-top-left-radius: 4px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.cb-bubble-bot a {
  color: var(--cb-primary-hover);
  text-decoration: underline;
  font-weight: 600;
}

.cb-bubble-bot a:hover {
  color: #ffffff;
}

.cb-bubble-user {
  background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-primary-dark) 100%);
  color: #ffffff;
  border-top-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(249, 115, 22, 0.3);
}

/* Typing Indicator */
.cb-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
}

.cb-typing-dot {
  width: 7px;
  height: 7px;
  background-color: var(--cb-primary);
  border-radius: 50%;
  animation: cb-bounce 1.4s infinite ease-in-out both;
}

.cb-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.cb-typing-dot:nth-child(2) { animation-delay: -0.16s; }
.cb-typing-dot:nth-child(3) { animation-delay: 0s; }

@keyframes cb-bounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Follow-up Question Suggestions inside Bubble */
.cb-followup-wrap {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.cb-followup-title {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cb-primary-hover);
  margin-bottom: 8px;
}

.cb-followup-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cb-followup-pill {
  background: rgba(249, 115, 22, 0.08);
  border: 1px solid rgba(249, 115, 22, 0.25);
  color: #fb923c;
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.4;
  outline: none;
}

.cb-followup-pill:hover {
  background: var(--cb-primary);
  border-color: var(--cb-primary);
  color: #ffffff;
  transform: translateX(3px);
}

/* 5. QUICK BAR (HORIZONTAL CHIPS) */
.cb-quick-bar {
  padding: 8px 12px;
  background: var(--cb-bg-panel);
  border-top: 1px solid var(--cb-border);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.cb-quick-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 4px 6px 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  cursor: grab;
  user-select: none;
  scroll-behavior: smooth;
}

.cb-quick-scroll.is-dragging {
  cursor: grabbing !important;
  scroll-behavior: auto !important;
}

.cb-quick-scroll::-webkit-scrollbar {
  display: none;
}

.cb-chip-btn {
  background: var(--cb-bg-card);
  border: 1px solid var(--cb-border);
  color: var(--cb-text-muted);
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  outline: none;
}

.cb-chip-btn:hover {
  border-color: var(--cb-primary);
  color: var(--cb-primary);
  background: rgba(249, 115, 22, 0.08);
}

.cb-chip-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

/* 6. INPUT FORM */
.cb-input-wrap {
  padding: 12px 16px;
  background: var(--cb-bg-panel);
  border-top: 1px solid var(--cb-border);
  flex-shrink: 0;
}

.cb-input-group {
  display: flex;
  align-items: center;
  background: var(--cb-bg-header);
  border: 1px solid var(--cb-border);
  border-radius: 14px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cb-input-group:focus-within {
  border-color: var(--cb-primary);
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.2);
}

.cb-input-field {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 0;
  font-size: 13.5px;
  color: var(--cb-text-light);
  outline: none;
  font-family: inherit;
}

.cb-input-field::placeholder {
  color: #64748b;
}

.cb-submit-btn {
  background: var(--cb-primary);
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
  flex-shrink: 0;
}

.cb-submit-btn:hover {
  background: var(--cb-primary-dark);
  transform: scale(1.05);
}

.cb-submit-btn svg {
  width: 16px;
  height: 16px;
  stroke: #ffffff;
  stroke-width: 2;
  fill: none;
}

/* 7. RESPONSIVE FOR MOBILE & TABLET */
@media (max-width: 767.98px) {
  .cb-floating-btn {
    bottom: 76px;
    right: 16px;
    left: auto;
    width: 48px;
    height: 48px;
  }

  .cb-chat-panel {
    bottom: 80px;
    left: 12px;
    right: 12px;
    width: calc(100vw - 24px);
    height: calc(100vh - 100px);
    max-height: 560px;
    transform-origin: bottom right;
  }
}

/* Ẩn Chatbot khi Mobile Drawer Menu đang mở */
html.mobile-drawer-open .cb-floating-btn,
body.mobile-drawer-open .cb-floating-btn,
html.mobile-drawer-open .cb-chat-panel,
body.mobile-drawer-open .cb-chat-panel {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}
