/**
 * chat.css — MyTravelsai AI Travel Assistant
 * Persistent sticky chat bar + sliding side panel
 */

/* ── Variables (extend editor.css tokens) ────────────────────────────────── */
:root {
  --chat-navy:      #060E1C;
  --chat-surface:   rgba(8, 18, 36, 0.92);
  --chat-border:    rgba(201, 168, 76, 0.22);
  --chat-gold:      #C9A84C;
  --chat-gold-glow: rgba(201, 168, 76, 0.18);
  --chat-radius:    16px;
  --chat-radius-sm: 10px;
  --chat-transition: 0.28s cubic-bezier(.4,0,.2,1);
}

/* ──────────────────────────────────────────────────────────────────────────
   STICKY CHAT BAR
   ────────────────────────────────────────────────────────────────────────── */
#ai-chat-bar {
  position: fixed;
  bottom: 72px;   /* stays above footer */
  left: 50%;
  transform: translateX(-50%);
  width: min(780px, calc(100vw - 32px));
  z-index: 980;
  pointer-events: none;   /* children re-enable pointer events */
}

/* When the footer is intersecting, push the bar up */
#ai-chat-bar.footer-visible {
  bottom: calc(var(--footer-height, 240px) + 16px);
  transition: bottom 0.3s ease;
}

.ai-chat-bar-inner {
  pointer-events: all;
  background: var(--chat-surface);
  border: 1.5px solid var(--chat-border);
  border-radius: var(--chat-radius);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 40px rgba(0,0,0,0.45), 0 0 0 1px rgba(201,168,76,0.08);
  padding: 10px 12px 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
  transition: box-shadow var(--chat-transition), border-color var(--chat-transition);
}

.ai-chat-bar-inner:focus-within {
  border-color: rgba(201, 168, 76, 0.5);
  box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 0 0 3px rgba(201,168,76,0.1);
}

.ai-chat-bar-top {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.ai-chat-bar-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1A3A6B 0%, #0A1628 100%);
  border: 1.5px solid var(--chat-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--chat-gold);
  font-size: 1rem;
}

#ai-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #E8E8F0;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  resize: none;
  max-height: 120px;
  min-height: 24px;
  line-height: 1.5;
  padding: 4px 0;
}

#ai-chat-input::placeholder {
  color: rgba(180, 180, 210, 0.45);
}

.ai-chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: var(--chat-gold);
  color: #0A1628;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
  transition: all var(--chat-transition);
}

.ai-chat-send-btn:hover {
  background: #e8c96a;
  transform: scale(1.06);
  box-shadow: 0 4px 14px rgba(201, 168, 76, 0.35);
}

.ai-chat-send-btn:disabled {
  background: rgba(201, 168, 76, 0.3);
  cursor: not-allowed;
  transform: none;
}

/* Meta row: city + cost info */
.ai-chat-bar-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 2px 2px;
  gap: 8px;
}

.ai-chat-bar-city {
  font-size: 0.72rem;
  color: rgba(180, 180, 210, 0.55);
  display: flex;
  align-items: center;
  gap: 5px;
}

.ai-chat-bar-city i { color: var(--chat-gold); font-size: 0.78rem; }

.ai-chat-bar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-chat-quota-badge {
  font-size: 0.7rem;
  color: rgba(180, 180, 210, 0.5);
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-chat-quota-badge.low { color: #f87171; }
.ai-chat-quota-badge i { font-size: 0.75rem; }

.ai-chat-open-panel-btn {
  background: transparent;
  border: 1px solid var(--chat-border);
  border-radius: 6px;
  color: rgba(180, 180, 210, 0.6);
  font-size: 0.7rem;
  padding: 3px 9px;
  cursor: pointer;
  transition: all var(--chat-transition);
  display: flex;
  align-items: center;
  gap: 4px;
}
.ai-chat-open-panel-btn:hover {
  color: var(--chat-gold);
  border-color: var(--chat-border);
  background: rgba(201, 168, 76, 0.06);
}

/* ── Chips ────────────────────────────────────────────────────────────────── */
.ai-chat-chips-row {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 6px 2px 0;
  scrollbar-width: none;
}
.ai-chat-chips-row::-webkit-scrollbar { display: none; }

.ai-chat-chip {
  background: rgba(201, 168, 76, 0.07);
  border: 1px solid rgba(201, 168, 76, 0.18);
  border-radius: 20px;
  color: rgba(210, 210, 230, 0.8);
  font-size: 0.72rem;
  padding: 4px 11px;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--chat-transition);
  flex-shrink: 0;
}
.ai-chat-chip:hover {
  background: rgba(201, 168, 76, 0.14);
  border-color: var(--chat-gold);
  color: var(--chat-gold);
}

/* ──────────────────────────────────────────────────────────────────────────
   SIDE CHAT PANEL
   ────────────────────────────────────────────────────────────────────────── */
#ai-chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100dvh;
  width: 420px;
  max-width: 100vw;
  z-index: 1050;
  display: flex;
  flex-direction: column;
  background: rgba(6, 14, 28, 0.97);
  border-left: 1.5px solid var(--chat-border);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  transform: translateX(100%);
  transition: transform var(--chat-transition);
  box-shadow: -8px 0 60px rgba(0, 0, 0, 0.55);
}

#ai-chat-panel.open {
  transform: translateX(0);
}

/* Panel header */
.chat-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--chat-border);
  flex-shrink: 0;
}

.chat-panel-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1A3A6B, #0A1628);
  border: 1.5px solid var(--chat-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--chat-gold);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.chat-panel-info { flex: 1; min-width: 0; }

.chat-panel-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #E8E8F0;
  font-family: 'Poppins', sans-serif;
}

.chat-panel-subtitle {
  font-size: 0.72rem;
  color: rgba(180, 180, 210, 0.55);
  margin-top: 2px;
}

.chat-panel-close {
  background: transparent;
  border: none;
  color: rgba(180, 180, 210, 0.5);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: all var(--chat-transition);
  line-height: 1;
}
.chat-panel-close:hover { color: #E8E8F0; background: rgba(255,255,255,0.06); }

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(201,168,76,0.2) transparent;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(201,168,76,0.2); border-radius: 4px; }

/* Message bubbles */
.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: msg-in 0.22s ease-out;
}

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

.chat-msg-bubble {
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 0.87rem;
  line-height: 1.65;
  max-width: 92%;
}

.chat-msg.user  { align-items: flex-end; }
.chat-msg.ai    { align-items: flex-start; }

.chat-msg.user .chat-msg-bubble {
  background: rgba(201, 168, 76, 0.14);
  border: 1px solid rgba(201, 168, 76, 0.25);
  color: #E8E8F0;
  border-bottom-right-radius: 4px;
}

.chat-msg.ai .chat-msg-bubble {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: #CDD0E0;
  border-bottom-left-radius: 4px;
}

.chat-msg.ai .chat-msg-bubble h3,
.chat-msg.ai .chat-msg-bubble h4 {
  color: var(--chat-gold);
  font-size: 0.88rem;
  margin: 10px 0 6px;
}
.chat-msg.ai .chat-msg-bubble p   { margin-bottom: 8px; }
.chat-msg.ai .chat-msg-bubble ul  { padding-left: 18px; margin: 6px 0; }
.chat-msg.ai .chat-msg-bubble li  { margin-bottom: 4px; }
.chat-msg.ai .chat-msg-bubble strong { color: #E8E8F0; }
.chat-msg.ai .chat-msg-bubble a   { color: var(--chat-gold); text-decoration: none; }

/* Typing indicator */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.chat-typing-dot {
  width: 6px; height: 6px;
  background: rgba(201,168,76,0.6);
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* Patch applied notification */
.chat-patch-notice {
  background: rgba(74, 222, 128, 0.08);
  border: 1px solid rgba(74, 222, 128, 0.25);
  border-radius: 10px;
  padding: 10px 14px;
  color: #86efac;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  max-width: 92%;
}

/* Off-topic notice */
.chat-offtopic-notice {
  background: rgba(251, 191, 36, 0.07);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: 10px;
  padding: 10px 14px;
  color: #fcd34d;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  max-width: 92%;
}

/* Welcome message */
.chat-welcome {
  text-align: center;
  padding: 30px 10px;
  color: rgba(180, 180, 210, 0.5);
}
.chat-welcome i {
  font-size: 2.5rem;
  color: var(--chat-gold);
  opacity: 0.6;
  display: block;
  margin-bottom: 12px;
}
.chat-welcome p {
  font-size: 0.83rem;
  line-height: 1.6;
}

/* Quota warning in panel */
.chat-quota-warning {
  margin: 0 18px;
  padding: 10px 14px;
  background: rgba(251, 191, 36, 0.07);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: 10px;
  color: #fcd34d;
  font-size: 0.78rem;
  text-align: center;
  display: none;
}
.chat-quota-warning.show { display: block; }

/* Panel input row */
.chat-panel-input-row {
  padding: 12px 18px 16px;
  border-top: 1px solid var(--chat-border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

#chat-panel-input {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1.5px solid var(--chat-border);
  border-radius: 10px;
  outline: none;
  color: #E8E8F0;
  font-size: 0.88rem;
  font-family: 'Inter', sans-serif;
  padding: 9px 12px;
  resize: none;
  max-height: 110px;
  min-height: 38px;
  line-height: 1.5;
  transition: border-color var(--chat-transition);
}
#chat-panel-input:focus { border-color: rgba(201,168,76,0.5); }
#chat-panel-input::placeholder { color: rgba(180,180,210,0.4); }

.chat-panel-send-btn {
  width: 38px; height: 38px;
  background: var(--chat-gold);
  border: none;
  border-radius: 10px;
  color: #0A1628;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--chat-transition);
}
.chat-panel-send-btn:hover { background: #e8c96a; transform: scale(1.05); }
.chat-panel-send-btn:disabled { background: rgba(201,168,76,0.3); cursor: not-allowed; transform: none; }

/* Panel chips */
.chat-panel-chips {
  padding: 0 18px 10px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* Overlay / backdrop */
#ai-chat-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1040;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--chat-transition);
}
#ai-chat-overlay.show { opacity: 1; pointer-events: all; }

/* ──────────────────────────────────────────────────────────────────────────
   RESPONSIVE
   ────────────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  #ai-chat-bar {
    bottom: 58px;
    width: calc(100vw - 20px);
  }

  #ai-chat-panel {
    width: 100vw;
    height: 92dvh;
    top: auto;
    bottom: 0;
    transform: translateY(100%);
    border-left: none;
    border-top: 1.5px solid var(--chat-border);
    border-radius: 20px 20px 0 0;
  }
  #ai-chat-panel.open { transform: translateY(0); }

  .ai-chat-chips-row { display: none; } /* save space on mobile */
}

@media (max-width: 400px) {
  .ai-chat-bar-meta { flex-wrap: wrap; }
  .ai-chat-open-panel-btn { display: none; }
}
