/* Chợ Bot Native AI Sales Assistant Widget CSS */
/* Palette đồng bộ với hệ thống Chợ Bot (Dark Navy, Magenta/Purple, Slate, Emerald, Accent Orange) */
:root {
  --cb-chat-bg: #121827;
  --cb-chat-surface: #1a233a;
  --cb-chat-header: #151d32;
  --cb-chat-border: #2a3652;
  --cb-chat-text: #f8fafc;
  --cb-chat-text-muted: #94a3b8;
  --cb-chat-primary-gradient: linear-gradient(135deg, #ba54f5 0%, #e14eca 100%);
  --cb-chat-user-bubble: linear-gradient(135deg, #7c3aed 0%, #ba54f5 100%);
  --cb-chat-bot-bubble: #1e293b;
  --cb-chat-accent-cyan: #22d3ee;
  --cb-chat-accent-orange: #ff7a00;
  --cb-chat-success: #22c55e;
}

/* Launcher Button */
#cb-livechat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99998;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--cb-chat-primary-gradient);
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 50px;
  box-shadow: 0 10px 25px -5px rgba(186, 84, 245, 0.4), 0 8px 10px -6px rgba(225, 78, 202, 0.2);
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

#cb-livechat-launcher:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 15px 30px -5px rgba(186, 84, 245, 0.5);
}

#cb-livechat-launcher .cb-launcher-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Tự động ẩn launcher khi panel chat mở */
body.cb-chat-opened #cb-livechat-launcher {
  opacity: 0;
  pointer-events: none;
  transform: translateY(15px) scale(0.9);
}

/* Chat Window Panel */
#cb-livechat-window {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 48px);
  background: var(--cb-chat-bg);
  border: 1px solid var(--cb-chat-border);
  border-radius: 18px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  z-index: 99999;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.96);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

#cb-livechat-window.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Header */
.cb-chat-header {
  background: var(--cb-chat-header);
  padding: 14px 18px;
  border-bottom: 1px solid var(--cb-chat-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.cb-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed 0%, #ba54f5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  color: #fff;
  border: 2px solid rgba(186, 84, 245, 0.4);
  box-shadow: 0 2px 8px rgba(186, 84, 245, 0.3);
  overflow: hidden;
  flex-shrink: 0;
}

.cb-chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cb-chat-title {
  color: var(--cb-chat-text);
  font-size: 14.5px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.2px;
}

.cb-chat-subtitle {
  color: var(--cb-chat-success);
  font-size: 11.5px;
  margin: 2px 0 0 0;
  display: flex;
  align-items: center;
  gap: 5px;
}

.cb-chat-subtitle::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--cb-chat-success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--cb-chat-success);
}

.cb-chat-close {
  background: transparent;
  border: none;
  color: var(--cb-chat-text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.cb-chat-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

/* Chat Body & Messages */
.cb-chat-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #0d121f;
}

.cb-chat-msg {
  max-width: 88%;
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.cb-chat-msg-user {
  align-self: flex-end;
  background: var(--cb-chat-user-bubble);
  color: #ffffff;
  border-bottom-right-radius: 3px;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);
}

.cb-chat-msg-bot {
  align-self: flex-start;
  background: var(--cb-chat-bot-bubble);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom-left-radius: 3px;
}

.cb-chat-msg-bot p {
  margin: 0 0 8px 0;
}
.cb-chat-msg-bot p:last-child {
  margin-bottom: 0;
}

.cb-chat-msg-bot code {
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--cb-chat-accent-cyan);
}

/* Mini Bot Recommendation Card */
.cb-mini-bot-card {
  background: #151d30;
  border: 1px solid #283552;
  border-radius: 12px;
  padding: 12px 14px;
  margin: 10px 0 4px 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cb-mini-bot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 6px;
}

.cb-mini-bot-name {
  font-weight: 700;
  color: #ffffff;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cb-mini-bot-badge {
  background: linear-gradient(135deg, #ba54f5 0%, #e14eca 100%);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 700;
}

.cb-mini-bot-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12.5px;
}

.cb-metric-item {
  display: flex;
  flex-direction: column;
}

.cb-metric-label {
  color: #94a3b8;
  font-size: 11px;
}

.cb-metric-val {
  font-weight: 700;
  color: #f8fafc;
}

.cb-metric-val.profit {
  color: #22c55e;
}

.cb-mini-bot-actions {
  display: flex;
  gap: 6px;
}

.cb-btn-mini {
  flex: 1;
  text-align: center;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
}

.cb-btn-mini-primary {
  background: var(--cb-chat-primary-gradient);
  color: #ffffff !important;
}

.cb-btn-mini-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1 !important;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.cb-btn-mini-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Progressive Quick Action Chips */
.cb-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.cb-chat-chip {
  background: rgba(186, 84, 245, 0.12);
  border: 1px solid rgba(186, 84, 245, 0.35);
  color: #d8b4fe;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.cb-chat-chip:hover {
  background: #ba54f5;
  color: #ffffff;
  border-color: #ba54f5;
}

/* Chip dành riêng cho Zalo / Hỗ trợ người thật */
.cb-chat-chip.cb-chip-zalo {
  background: rgba(255, 122, 0, 0.15);
  border-color: rgba(255, 122, 0, 0.4);
  color: #ff9838;
}

.cb-chat-chip.cb-chip-zalo:hover {
  background: #ff7a00;
  border-color: #ff7a00;
  color: #ffffff;
}

/* Footer & Input Area */
.cb-chat-footer {
  padding: 12px 14px;
  background: var(--cb-chat-surface);
  border-top: 1px solid var(--cb-chat-border);
  display: flex;
  gap: 8px;
  align-items: center;
}

.cb-chat-input {
  flex: 1;
  background: #0f172a;
  border: 1px solid #2d3b59;
  border-radius: 24px;
  padding: 9px 16px;
  color: var(--cb-chat-text);
  font-size: 13.5px;
  outline: none;
  transition: all 0.2s;
}

.cb-chat-input:focus {
  border-color: #ba54f5;
  box-shadow: 0 0 0 2px rgba(186, 84, 245, 0.2);
}

.cb-chat-send {
  background: var(--cb-chat-primary-gradient);
  border: none;
  color: #ffffff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(186, 84, 245, 0.3);
}

.cb-chat-send:hover {
  transform: scale(1.06);
}

/* Typing Indicator */
.cb-chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--cb-chat-bot-bubble);
  border-radius: 12px;
  align-self: flex-start;
  width: fit-content;
}

.cb-chat-dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: cbPulse 1.4s infinite ease-in-out both;
}

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

@keyframes cbPulse {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

@media (max-width: 480px) {
  #cb-livechat-window {
    right: 10px;
    left: 10px;
    width: auto;
    bottom: 16px;
    height: calc(100vh - 32px);
    border-radius: 16px;
  }
  #cb-livechat-launcher {
    bottom: 16px;
    right: 16px;
    padding: 10px 16px;
  }
}
