/*
 * assets/css/ai-concierge.css
 * MyStay AI Travel Concierge — Premium UI v5
 *
 * Changes from v4:
 *  - Panel wider (460px) and taller (680px)
 *  - Source badges: .platform (green tint) / .external (gray tint)
 *  - ai-slot-stats always visible; ai-stat-price prominent
 *  - Nearby hotels panel: .ai-nearby-hotels + .ai-hotel-chip
 *  - Footer: customize (gold border) + primary (book all) + secondary (share)
 *  - Day blocks default open; .collapsed rotates chevron
 */

/* ─── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --ai-primary:       #1a6b5a;
  --ai-primary-light: #2d9277;
  --ai-primary-dark:  #124d41;
  --ai-accent:        #c8a96e;
  --ai-accent-dark:   #92400e;
  --ai-bg:            #ffffff;
  --ai-surface:       #f7f8f9;
  --ai-border:        #e8eaed;
  --ai-text:          #1c1c1e;
  --ai-text-muted:    #6b7280;
  --ai-user-bubble:   #1a6b5a;
  --ai-ai-bubble:     #f0f4f2;
  --ai-shadow:        0 24px 64px rgba(0,0,0,0.13);
  --ai-radius:        16px;
  --ai-panel-w:       460px;
  --ai-panel-h:       680px;
  --ai-z:             99990;
}

/* ─── Floating button ────────────────────────────────────────────────────────── */
#ai-concierge-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--ai-primary);
  border: none;
  cursor: pointer;
  z-index: var(--ai-z);
  box-shadow: 0 4px 18px rgba(26,107,90,0.40);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.25s;
  outline: none;
}
[dir="rtl"] #ai-concierge-btn { right: auto; left: 28px; }
#ai-concierge-btn:hover  { transform: scale(1.08); box-shadow: 0 6px 24px rgba(26,107,90,0.50); }
#ai-concierge-btn.is-open { background: var(--ai-primary-dark); }

/* ─── Panel ──────────────────────────────────────────────────────────────────── */
#ai-panel {
  position: fixed;
  bottom: 90px;
  right: 28px;
  width: var(--ai-panel-w);
  height: var(--ai-panel-h);
  max-height: 88vh;
  background: var(--ai-bg);
  border-radius: var(--ai-radius);
  box-shadow: var(--ai-shadow);
  z-index: calc(var(--ai-z) + 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(16px) scale(0.97);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s ease;
  border: 1px solid var(--ai-border);
}
[dir="rtl"] #ai-panel { right: auto; left: 28px; }
#ai-panel.is-open { transform: translateY(0) scale(1); opacity: 1; pointer-events: all; }

@media (max-width: 520px) {
  #ai-panel {
    width: 100vw; height: 100vh; max-height: 100vh;
    bottom: 0; right: 0; left: 0; border-radius: 0;
  }
  [dir="rtl"] #ai-panel { right: 0; left: 0; }
}

/* ─── Header ─────────────────────────────────────────────────────────────────── */
.ai-header {
  background: linear-gradient(135deg, var(--ai-primary-dark) 0%, var(--ai-primary) 100%);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  user-select: none;
}
.ai-header-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: #fff;
}
.ai-header-info { flex: 1; min-width: 0; }
.ai-header-name  { font-weight: 700; font-size: 14px; letter-spacing: 0.1px; }
.ai-header-status { font-size: 11px; opacity: 0.8; display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.ai-status-dot { width: 6px; height: 6px; border-radius: 50%; background: #4ade80; display: inline-block; animation: ai-blink 2s ease-in-out infinite; }
@keyframes ai-blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

.ai-header-actions { display: flex; gap: 4px; }
.ai-header-btn {
  width: 30px; height: 30px; border-radius: 8px; border: none;
  background: rgba(255,255,255,0.12); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.ai-header-btn:hover { background: rgba(255,255,255,0.22); }

/* ─── Chat body ──────────────────────────────────────────────────────────────── */
.ai-body { flex: 1; overflow-y: auto; padding: 14px; scroll-behavior: smooth; background: #fafbfa; }
.ai-body::-webkit-scrollbar { width: 4px; }
.ai-body::-webkit-scrollbar-track { background: transparent; }
.ai-body::-webkit-scrollbar-thumb { background: var(--ai-border); border-radius: 10px; }

/* ─── Welcome ────────────────────────────────────────────────────────────────── */
.ai-welcome { text-align: center; padding: 18px 12px 10px; }
.ai-welcome-icon  { color: var(--ai-primary); margin-bottom: 8px; display: flex; justify-content: center; }
.ai-welcome-title { font-weight: 700; font-size: 15px; color: var(--ai-primary-dark); margin-bottom: 4px; }
.ai-welcome-sub   { font-size: 12.5px; color: var(--ai-text-muted); line-height: 1.5; }

/* ─── Guided flow options ────────────────────────────────────────────────────── */
.ai-flow-question-group { margin-bottom: 10px; }
.ai-flow-options { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; padding-left: 2px; }
.ai-flow-option {
  background: #fff; border: 1.5px solid var(--ai-border);
  color: var(--ai-primary-dark); border-radius: 20px;
  padding: 7px 14px; font-size: 12.5px; font-weight: 500;
  cursor: pointer; transition: all 0.15s; white-space: nowrap; font-family: inherit; line-height: 1;
}
.ai-flow-option:hover:not(:disabled) {
  border-color: var(--ai-primary); background: var(--ai-primary); color: #fff;
  transform: translateY(-1px); box-shadow: 0 3px 10px rgba(26,107,90,0.2);
}
.ai-flow-option:disabled { cursor: default; opacity: 0.4; }
.ai-flow-option.chosen   { border-color: var(--ai-primary); color: var(--ai-primary); opacity: 0.6; }

/* ─── Messages ───────────────────────────────────────────────────────────────── */
.ai-message-group { margin-bottom: 10px; display: flex; flex-direction: column; }
.ai-bubble {
  max-width: 84%; padding: 10px 13px; border-radius: 14px;
  font-size: 13.5px; line-height: 1.55; word-wrap: break-word;
  animation: ai-fade-in 0.2s ease-out;
}
@keyframes ai-fade-in { from{opacity:0;transform:translateY(5px)} to{opacity:1;transform:none} }

.ai-bubble.user {
  background: var(--ai-user-bubble); color: #fff;
  border-bottom-right-radius: 4px; align-self: flex-end;
}
[dir="rtl"] .ai-bubble.user { border-bottom-right-radius: 14px; border-bottom-left-radius: 4px; }

.ai-bubble.assistant {
  background: var(--ai-ai-bubble); color: var(--ai-text);
  border-bottom-left-radius: 4px; align-self: flex-start;
}
[dir="rtl"] .ai-bubble.assistant { border-bottom-left-radius: 14px; border-bottom-right-radius: 4px; }

.ai-bubble-meta { font-size: 10px; color: var(--ai-text-muted); margin-top: 3px; opacity: 0.7; }
.ai-bubble.user + .ai-bubble-meta { text-align: right; align-self: flex-end; }

/* ─── Typing ─────────────────────────────────────────────────────────────────── */
.ai-typing {
  display: flex; align-items: center; gap: 4px; padding: 11px 14px;
  background: var(--ai-ai-bubble); border-radius: 14px; border-bottom-left-radius: 4px;
  width: fit-content; margin-bottom: 10px;
}
.ai-typing-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ai-primary); animation: ai-bounce 1.2s ease-in-out infinite; }
.ai-typing-dot:nth-child(2){animation-delay:.2s} .ai-typing-dot:nth-child(3){animation-delay:.4s}
@keyframes ai-bounce { 0%,80%,100%{transform:translateY(0);opacity:.4} 40%{transform:translateY(-6px);opacity:1} }

/* ─── Itinerary ──────────────────────────────────────────────────────────────── */
.ai-itinerary-wrap {
  margin-top: 4px; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--ai-border); animation: ai-fade-in 0.25s ease-out;
}

.ai-itinerary-header {
  background: linear-gradient(135deg, var(--ai-primary-dark), var(--ai-primary));
  color: #fff; padding: 14px 16px;
}
.ai-itinerary-title   { font-weight: 700; font-size: 14px; margin-bottom: 5px; }
.ai-itinerary-summary { font-size: 12px; opacity: 0.85; line-height: 1.45; }
.ai-itinerary-meta    { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.ai-meta-chip {
  font-size: 11px; background: rgba(255,255,255,0.16);
  padding: 3px 10px; border-radius: 20px;
}

/* ─── Day blocks ─────────────────────────────────────────────────────────────── */
.ai-day-block { border-top: 1px solid var(--ai-border); }
.ai-day-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; background: #fff; cursor: pointer;
  user-select: none; transition: background 0.15s;
}
.ai-day-header:hover { background: var(--ai-surface); }
.ai-day-num   { font-weight: 700; font-size: 12px; color: var(--ai-primary-dark); flex-shrink: 0; }
.ai-day-theme { font-size: 12px; color: var(--ai-text-muted); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-day-toggle { margin-left: auto; color: var(--ai-text-muted); display: flex; align-items: center; transition: transform 0.2s; flex-shrink: 0; }
[dir="rtl"] .ai-day-toggle { margin-left: 0; margin-right: auto; }
.ai-day-header.collapsed .ai-day-toggle { transform: rotate(-90deg); }

/* Slots default visible; toggled by JS slideToggle */
.ai-slots { display: flex; flex-direction: column; }

/* ─── Slots ──────────────────────────────────────────────────────────────────── */
.ai-slot {
  padding: 12px 14px; border-top: 1px solid var(--ai-border);
  background: #fff; transition: background 0.12s;
}
.ai-slot:hover { background: #fafbfa; }

/* Time row + source badge */
.ai-slot-time-row { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.ai-slot-time-badge {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--ai-primary); background: rgba(26,107,90,0.08);
  padding: 3px 8px; border-radius: 8px;
}
/* Source badges */
.ai-slot-source-tag {
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 8px; letter-spacing: 0.3px;
}
.ai-slot-source-tag.platform { background: rgba(26,107,90,0.10); color: var(--ai-primary-dark); }
.ai-slot-source-tag.external { background: #f3f4f6; color: #9ca3af; }

/* Slot name + type badge */
.ai-slot-header    { margin-bottom: 4px; }
.ai-slot-name      { font-weight: 600; font-size: 13.5px; color: var(--ai-text); margin-bottom: 3px; }
.ai-slot-type-badge {
  display: inline-block; font-size: 9px; font-weight: 700;
  padding: 2px 6px; border-radius: 6px; text-transform: uppercase; letter-spacing: 0.4px;
}
.ai-badge-tour     { background: #fff3e0; color: #b45309; }
.ai-badge-hotel    { background: #eff6ff; color: #1d4ed8; }
.ai-badge-cafe     { background: #fdf2f8; color: #9d174d; }
.ai-badge-istiraha { background: #f5f3ff; color: #6d28d9; }
.ai-badge-external { background: #f3f4f6; color: #6b7280; }

.ai-slot-desc { font-size: 12.5px; color: #4b5563; line-height: 1.5; margin-bottom: 6px; }
.ai-slot-why  {
  font-size: 11.5px; color: var(--ai-primary-dark); font-style: italic;
  margin-bottom: 8px; padding: 6px 10px; background: rgba(26,107,90,0.06);
  border-left: 2px solid var(--ai-primary); border-radius: 0 6px 6px 0;
}
[dir="rtl"] .ai-slot-why { border-left: none; border-right: 2px solid var(--ai-primary); border-radius: 6px 0 0 6px; }

/* Stats row — always visible */
.ai-slot-stats {
  display: flex; gap: 10px; margin-bottom: 9px; flex-wrap: wrap;
  padding: 5px 8px; background: var(--ai-surface); border-radius: 8px;
}
.ai-slot-stat  { font-size: 12px; color: var(--ai-text-muted); display: flex; align-items: center; gap: 3px; }
.ai-stat-price  { color: #065f46; font-weight: 700; }
.ai-stat-rating { color: #92400e; }
.ai-stat-dur    { color: var(--ai-text-muted); }

/* ─── Nearby hotels panel ─────────────────────────────────────────────────────── */
.ai-nearby-hotels {
  background: var(--ai-surface); border: 1px solid var(--ai-border);
  border-radius: 10px; padding: 9px 11px; margin-bottom: 9px;
}
.ai-nearby-hotels-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ai-text-muted); margin-bottom: 8px;
  display: flex; align-items: center; gap: 5px;
}
.ai-nearby-hotels-label svg { color: var(--ai-accent); flex-shrink: 0; }

.ai-hotel-chips { display: flex; flex-direction: column; gap: 6px; }
.ai-hotel-chip {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--ai-border); border-radius: 8px;
  padding: 7px 10px; transition: border-color 0.12s;
}
.ai-hotel-chip:hover { border-color: var(--ai-primary); }
.ai-hotel-chip-info { flex: 1; min-width: 0; }
.ai-hotel-chip-name {
  font-size: 12.5px; font-weight: 600; color: var(--ai-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-hotel-chip-sub  { font-size: 11px; color: #92400e; margin-top: 1px; }
.ai-hotel-chip-price { font-size: 12px; color: #065f46; font-weight: 700; flex-shrink: 0; white-space: nowrap; }
.ai-hotel-chip-book {
  font-size: 11px; font-weight: 700;
  border: 1.5px solid var(--ai-primary); color: var(--ai-primary);
  border-radius: 6px; padding: 4px 9px;
  background: transparent; cursor: pointer; white-space: nowrap;
  text-decoration: none; display: inline-flex; align-items: center;
  transition: all 0.15s; font-family: inherit; flex-shrink: 0;
}
.ai-hotel-chip-book:hover { background: var(--ai-primary); color: #fff; }

/* ─── Slot action buttons ────────────────────────────────────────────────────── */
.ai-slot-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ai-slot-btn {
  font-size: 11px; font-weight: 600; padding: 5px 12px; border-radius: 7px;
  border: 1.5px solid; cursor: pointer; transition: all 0.15s;
  text-decoration: none; display: inline-flex; align-items: center;
  background: transparent; font-family: inherit;
}
/* Book now — platform listing */
.ai-slot-btn.book    { border-color: var(--ai-primary); color: var(--ai-primary); }
.ai-slot-btn.book:hover { background: var(--ai-primary); color: #fff; }
/* View options / Find on MyStay — external slot action */
.ai-slot-btn.view    { border-color: var(--ai-primary); color: var(--ai-primary); }
.ai-slot-btn.view:hover { background: var(--ai-primary); color: #fff; }
/* Try another */
.ai-slot-btn.replace { border-color: var(--ai-border); color: var(--ai-text-muted); }
.ai-slot-btn.replace:hover { border-color: var(--ai-accent); color: var(--ai-accent-dark); }
/* Save */
.ai-slot-btn.save    { border-color: var(--ai-border); color: var(--ai-text-muted); }
.ai-slot-btn.save:hover { border-color: #059669; color: #059669; }
.ai-slot-btn.save.saved { background: #059669; border-color: #059669; color: #fff; }

/* ─── Confidence note ────────────────────────────────────────────────────────── */
.ai-confidence-note { font-size: 11px; padding: 7px 14px; display: flex; align-items: center; gap: 5px; }
.ai-confidence-note.platform { background: #f0fdf4; color: #166534; }
.ai-confidence-note.hybrid   { background: #fffbeb; color: #92400e; }
.ai-confidence-note.external { background: #f9fafb; color: #6b7280; }

/* ─── Itinerary footer ───────────────────────────────────────────────────────── */
.ai-itinerary-footer {
  padding: 10px 14px; background: var(--ai-surface);
  display: flex; gap: 7px; border-top: 1px solid var(--ai-border);
  flex-wrap: wrap;
}
.ai-itinerary-footer-btn {
  flex: 1; min-width: 80px; padding: 8px 10px; border-radius: 8px; border: 1.5px solid;
  font-size: 12px; font-weight: 600; cursor: pointer; text-align: center;
  transition: all 0.15s; font-family: inherit;
}
/* Customize — gold border, deferred email gate */
.ai-itinerary-footer-btn.customize {
  background: transparent; border-color: var(--ai-accent); color: var(--ai-accent-dark);
}
.ai-itinerary-footer-btn.customize:hover { background: rgba(200,169,110,0.1); }
/* Book all — solid primary */
.ai-itinerary-footer-btn.primary { background: var(--ai-primary); border-color: var(--ai-primary); color: #fff; }
.ai-itinerary-footer-btn.primary:hover { background: var(--ai-primary-dark); }
/* Share */
.ai-itinerary-footer-btn.secondary { background: transparent; border-color: var(--ai-border); color: var(--ai-text-muted); }
.ai-itinerary-footer-btn.secondary:hover { border-color: var(--ai-primary); color: var(--ai-primary); }

/* ─── Input area ──────────────────────────────────────────────────────────────── */
.ai-input-area {
  border-top: 1px solid var(--ai-border);
  padding: 8px 12px 7px; background: #fff; flex-shrink: 0;
}
.ai-email-prompt {
  background: #fffbeb; border: 1px solid #fcd34d; border-radius: 8px;
  padding: 8px 10px; margin-bottom: 8px; font-size: 12px; color: #78350f;
  display: flex; align-items: center; gap: 6px;
}
.ai-email-prompt input { flex: 1; border: 1px solid #e5e7eb; border-radius: 6px; padding: 5px 9px; font-size: 12px; outline: none; }
.ai-email-prompt input:focus { border-color: var(--ai-primary); }
.ai-email-prompt button { background: var(--ai-primary); color: #fff; border: none; border-radius: 6px; padding: 5px 10px; font-size: 11px; cursor: pointer; font-weight: 600; }

.ai-input-row {
  display: flex; gap: 7px; align-items: center;
  background: var(--ai-surface); border: 1.5px solid var(--ai-border);
  border-radius: 24px; padding: 4px 4px 4px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.ai-input-row:focus-within { border-color: var(--ai-primary); box-shadow: 0 0 0 3px rgba(26,107,90,0.08); background: #fff; }

#ai-input {
  flex: 1; border: none; background: transparent; outline: none;
  font-size: 13.5px; font-family: inherit; color: var(--ai-text);
  line-height: 1.4; padding: 4px 0; min-width: 0;
}
#ai-input::placeholder { color: #9ca3af; }

#ai-send-btn {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: var(--ai-primary); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; flex-shrink: 0;
  transition: background 0.15s, transform 0.1s; line-height: 1;
}
#ai-send-btn:hover   { background: var(--ai-primary-dark); }
#ai-send-btn:active  { transform: scale(0.88); }
#ai-send-btn:disabled { background: #d1d5db; cursor: not-allowed; }

/* Hint chips */
.ai-input-hints { display: flex; gap: 5px; margin-top: 7px; flex-wrap: wrap; }
.ai-hint-chip {
  font-size: 11px; padding: 4px 9px; border-radius: 10px;
  background: var(--ai-surface); border: 1px solid var(--ai-border);
  color: var(--ai-text-muted); cursor: pointer; transition: all 0.12s; white-space: nowrap;
}
.ai-hint-chip:hover { background: var(--ai-primary); color: #fff; border-color: var(--ai-primary); }

/* ─── Loading overlay ────────────────────────────────────────────────────────── */
.ai-loading-overlay {
  display: none; position: absolute; inset: 0; background: rgba(255,255,255,0.82);
  backdrop-filter: blur(2px); z-index: 10; align-items: center; justify-content: center;
  border-radius: var(--ai-radius); flex-direction: column; gap: 10px;
}
.ai-loading-overlay.visible { display: flex; }
.ai-loading-spinner { width: 32px; height: 32px; border: 2.5px solid var(--ai-border); border-top-color: var(--ai-primary); border-radius: 50%; animation: ai-spin 0.7s linear infinite; }
@keyframes ai-spin { to { transform: rotate(360deg); } }
.ai-loading-text { font-size: 12.5px; color: var(--ai-primary); font-weight: 500; }
