/* ============================================
   KORABI TRAVEL AI CHATBOT — Premium Widget
   ============================================ */

/* — CSS Custom Properties — */
:root {
  --cb-primary: #0c6e5f;
  --cb-primary-light: #0f8a76;
  --cb-primary-dark: #094d43;
  --cb-accent: #f4a623;
  --cb-accent-light: #ffc857;
  --cb-gradient: linear-gradient(135deg, #0c6e5f 0%, #0f8a76 50%, #14b8a6 100%);
  --cb-gradient-accent: linear-gradient(135deg, #f4a623 0%, #ffc857 100%);

  /* Light mode */
  --cb-bg: #ffffff;
  --cb-bg-secondary: #f7f8fa;
  --cb-bg-glass: rgba(255, 255, 255, 0.85);
  --cb-text: #1a1a2e;
  --cb-text-secondary: #6b7280;
  --cb-text-muted: #9ca3af;
  --cb-border: rgba(0, 0, 0, 0.08);
  --cb-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 4px 16px rgba(0, 0, 0, 0.08);
  --cb-shadow-button: 0 8px 32px rgba(12, 110, 95, 0.4);
  --cb-msg-bot-bg: #f0f4f3;
  --cb-msg-user-bg: var(--cb-gradient);
  --cb-msg-user-text: #ffffff;
  --cb-input-bg: #f7f8fa;
  --cb-input-border: rgba(0, 0, 0, 0.1);
  --cb-scrollbar-thumb: rgba(0, 0, 0, 0.15);
  --cb-scrollbar-track: transparent;
  --cb-overlay: rgba(0, 0, 0, 0.3);
}

/* Dark mode */
[data-cb-theme="dark"] {
  --cb-bg: #1a1a2e;
  --cb-bg-secondary: #16162a;
  --cb-bg-glass: rgba(26, 26, 46, 0.92);
  --cb-text: #e8e8f0;
  --cb-text-secondary: #a0a0b8;
  --cb-text-muted: #6b6b80;
  --cb-border: rgba(255, 255, 255, 0.08);
  --cb-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.3);
  --cb-shadow-button: 0 8px 32px rgba(12, 110, 95, 0.5);
  --cb-msg-bot-bg: #252540;
  --cb-input-bg: #252540;
  --cb-input-border: rgba(255, 255, 255, 0.1);
  --cb-scrollbar-thumb: rgba(255, 255, 255, 0.15);
  --cb-overlay: rgba(0, 0, 0, 0.6);
}

/* ============================================
   FLOATING CHAT BUTTON
   ============================================ */
#cb-toggle-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--cb-gradient);
  border: none;
  cursor: pointer;
  z-index: 999998;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--cb-shadow-button);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

#cb-toggle-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(12, 110, 95, 0.5);
}

#cb-toggle-btn:active {
  transform: scale(0.95);
}

#cb-toggle-btn svg {
  width: 28px;
  height: 28px;
  fill: #ffffff;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

#cb-toggle-btn .cb-icon-close {
  position: absolute;
  transform: rotate(90deg) scale(0);
  opacity: 0;
}

#cb-toggle-btn.cb-active .cb-icon-chat {
  transform: rotate(-90deg) scale(0);
  opacity: 0;
}

#cb-toggle-btn.cb-active .cb-icon-close {
  transform: rotate(0deg) scale(1);
  opacity: 1;
}

/* Pulse animation */
#cb-toggle-btn::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--cb-gradient);
  opacity: 0;
  animation: cb-pulse 2.5s infinite;
}

#cb-toggle-btn.cb-active::before {
  animation: none;
  opacity: 0;
}

@keyframes cb-pulse {
  0% { transform: scale(1); opacity: 0.5; }
  70% { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* Notification badge */
#cb-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Inter', system-ui, sans-serif;
  border: 2px solid var(--cb-bg);
  animation: cb-badge-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#cb-badge.cb-hidden {
  display: none;
}

@keyframes cb-badge-pop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

/* ============================================
   CHAT WINDOW
   ============================================ */
#cb-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 400px;
  height: 560px;
  max-height: calc(100vh - 140px);
  border-radius: 20px;
  background: var(--cb-bg);
  box-shadow: var(--cb-shadow);
  z-index: 999997;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--cb-border);
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.3s ease;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

/* ============================================
   HEADER
   ============================================ */
#cb-header {
  background: var(--cb-gradient);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  flex-shrink: 0;
}

#cb-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

#cb-header-info {
  flex: 1;
  min-width: 0;
}

#cb-header-title {
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin: 0;
}

#cb-header-status {
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

#cb-header-status .cb-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  animation: cb-dot-pulse 2s infinite;
}

@keyframes cb-dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

#cb-header-actions {
  display: flex;
  gap: 6px;
}

.cb-header-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.cb-header-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.cb-header-btn svg {
  width: 16px;
  height: 16px;
  fill: #ffffff;
}

/* ============================================
   MESSAGES AREA
   ============================================ */
#cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  background: var(--cb-bg);
}

/* Custom scrollbar */
#cb-messages::-webkit-scrollbar {
  width: 5px;
}

#cb-messages::-webkit-scrollbar-track {
  background: var(--cb-scrollbar-track);
}

#cb-messages::-webkit-scrollbar-thumb {
  background: var(--cb-scrollbar-thumb);
  border-radius: 10px;
}

/* Message row */
.cb-msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: cb-msg-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cb-msg-bot {
  align-self: flex-start;
}

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

@keyframes cb-msg-in {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* Avatar (bot only) */
.cb-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--cb-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  align-self: flex-end;
}

/* Bubble */
.cb-msg-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  position: relative;
}

.cb-msg-bot .cb-msg-bubble {
  background: var(--cb-msg-bot-bg);
  color: var(--cb-text);
  border-bottom-left-radius: 6px;
}

.cb-msg-user .cb-msg-bubble {
  background: var(--cb-msg-user-bg);
  color: var(--cb-msg-user-text);
  border-bottom-right-radius: 6px;
}

/* Timestamp */
.cb-msg-time {
  font-size: 10px;
  color: var(--cb-text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.cb-msg-user .cb-msg-time {
  text-align: right;
}

/* ============================================
   TYPING INDICATOR
   ============================================ */
.cb-typing {
  display: flex;
  gap: 8px;
  align-self: flex-start;
  max-width: 88%;
  animation: cb-msg-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cb-typing-bubble {
  background: var(--cb-msg-bot-bg);
  padding: 14px 20px;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}

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

.cb-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.cb-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes cb-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ============================================
   QUICK REPLIES
   ============================================ */
#cb-quick-replies {
  padding: 6px 16px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--cb-bg);
  flex-shrink: 0;
}

.cb-quick-btn {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--cb-primary);
  background: transparent;
  color: var(--cb-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: inherit;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.cb-quick-btn:hover {
  background: var(--cb-primary);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(12, 110, 95, 0.3);
}

.cb-quick-btn:active {
  transform: translateY(0);
}

/* ============================================
   LEAD CAPTURE FORM
   ============================================ */
.cb-lead-card {
  background: var(--cb-bg-secondary);
  border: 1px solid var(--cb-border);
  border-radius: 16px;
  padding: 16px;
  margin: 4px 0;
  animation: cb-msg-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cb-lead-card h4 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--cb-text);
}

.cb-lead-card p {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--cb-text-secondary);
  line-height: 1.4;
}

.cb-lead-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--cb-input-border);
  border-radius: 10px;
  background: var(--cb-bg);
  color: var(--cb-text);
  font-size: 13px;
  font-family: inherit;
  margin-bottom: 8px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.cb-lead-input:focus {
  border-color: var(--cb-primary);
  box-shadow: 0 0 0 3px rgba(12, 110, 95, 0.1);
}

.cb-lead-input::placeholder {
  color: var(--cb-text-muted);
}

.cb-lead-submit {
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: 10px;
  background: var(--cb-gradient);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.2s ease, transform 0.2s ease;
  margin-top: 2px;
}

.cb-lead-submit:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.cb-lead-submit:active {
  transform: translateY(0);
}

.cb-lead-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ============================================
   INPUT AREA
   ============================================ */
#cb-input-area {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--cb-bg);
  border-top: 1px solid var(--cb-border);
  flex-shrink: 0;
}

#cb-input {
  flex: 1;
  padding: 12px 16px;
  border: 1.5px solid var(--cb-input-border);
  border-radius: 24px;
  background: var(--cb-input-bg);
  color: var(--cb-text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: none;
  min-height: 20px;
  max-height: 80px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#cb-input:focus {
  border-color: var(--cb-primary);
  box-shadow: 0 0 0 3px rgba(12, 110, 95, 0.1);
}

#cb-input::placeholder {
  color: var(--cb-text-muted);
}

#cb-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--cb-gradient);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, opacity 0.2s ease;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

#cb-send-btn:hover {
  transform: scale(1.05);
}

#cb-send-btn:active {
  transform: scale(0.95);
}

#cb-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

#cb-send-btn svg {
  width: 18px;
  height: 18px;
  fill: #ffffff;
  margin-left: 2px;
}

/* ============================================
   POWERED BY (FOOTER)
   ============================================ */
#cb-powered {
  text-align: center;
  padding: 6px;
  font-size: 10px;
  color: var(--cb-text-muted);
  background: var(--cb-bg);
  border-top: 1px solid var(--cb-border);
  flex-shrink: 0;
}

/* ============================================
   LINK STYLES IN BOT MESSAGES
   ============================================ */
.cb-msg-bot .cb-msg-bubble a {
  color: var(--cb-primary);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.cb-msg-bot .cb-msg-bubble a:hover {
  border-bottom-color: var(--cb-primary);
}

/* CTA button inside messages */
.cb-cta-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 9px 18px;
  border-radius: 20px;
  background: var(--cb-gradient);
  color: #ffffff !important;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none !important;
  border-bottom: none !important;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.cb-cta-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  border-bottom: none !important;
}

/* ============================================
   RESPONSIVE — MOBILE
   ============================================ */
@media (max-width: 480px) {
  #cb-window {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    bottom: 0;
    right: 0;
    border-radius: 0;
    border: none;
  }

  #cb-window.cb-open {
    transform: translateY(0) scale(1);
  }

  #cb-toggle-btn {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
  }

  #cb-toggle-btn svg {
    width: 24px;
    height: 24px;
  }

  #cb-header {
    padding: 16px;
    border-radius: 0;
  }

  .cb-msg {
    max-width: 92%;
  }

  #cb-quick-replies {
    padding: 6px 12px 10px;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  #cb-window {
    width: 360px;
    height: 500px;
  }
}

/* ============================================
   ANIMATIONS — REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

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