/* VA Chatbot – modern UI
   Drop this file in /assets/chat.css (replace existing)
   Customize colors in :root or add a body[data-va-theme="dark"] to force dark.
*/

/* ========== Design Tokens (brand here) ========== */
:root {
  --va-font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --va-radius: 14px;
  --va-radius-sm: 10px;
  --va-shadow: 0 10px 30px rgba(0,0,0,.15);
  --va-z: 9999;

  /* Brand */
  --va-primary: #2563eb;   /* buttons, accents */
  --va-primary-600: #1d4ed8;
  --va-primary-100: #e0e7ff;
  --va-bg: #ffffff;
  --va-elev: #ffffff;      /* panel */
  --va-border: #e5e7eb;
  --va-text: #111827;
  --va-subtle: #6b7280;

  /* Bubbles */
  --va-bubble-bot: #f3f4f6;
  --va-bubble-user: #2563eb;
  --va-bubble-user-text: #ffffff;

  /* Inputs */
  --va-input-bg: #fff;
  --va-input-border: #d1d5db;
  --va-input-focus: #93c5fd;

  /* Steps */
  --va-step-bg: #eef2ff;
  --va-step-active: #2563eb;

  /* Success/alert */
  --va-ok: #16a34a;
  --va-warn: #f59e0b;
  --va-bad: #ef4444;
}

/* Auto dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --va-bg: #0b0e14;
    --va-elev: #0f131b;
    --va-border: #1f2430;
    --va-text: #e5e7eb;
    --va-subtle: #a1a1aa;
    --va-bubble-bot: #151a22;
    --va-input-bg: #0f131b;
    --va-input-border: #272b36;
    --va-bubble-user: #2f6cf0;
    --va-primary-100: #1b2a55;
  }
}

/* Optional manual dark theme: body[data-va-theme="dark"] { ... } */
body[data-va-theme="dark"] {
  --va-bg: #0b0e14;
  --va-elev: #0f131b;
  --va-border: #1f2430;
  --va-text: #e5e7eb;
  --va-subtle: #a1a1aa;
  --va-bubble-bot: #151a22;
  --va-input-bg: #0f131b;
  --va-input-border: #272b36;
  --va-bubble-user: #2f6cf0;
  --va-primary-100: #1b2a55;
}

/* ========== Core Layout ========== */
#va-chatbot-root {
  position: fixed;
  inset: auto 24px 24px auto;
  z-index: var(--va-z);
  font-family: var(--va-font);
}

/* Floating button */
#va-chatbot-root .va-fab {
  all: unset;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--va-primary);
  color: #fff;
  box-shadow: var(--va-shadow);
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
}
#va-chatbot-root .va-fab:hover { transform: translateY(-1px); background: var(--va-primary-600); }
#va-chatbot-root .va-fab:active { transform: translateY(0); }
#va-chatbot-root .va-fab:focus-visible {
  outline: 3px solid var(--va-input-focus);
  outline-offset: 3px;
}

/* Panel */
#va-chatbot-root .va-panel {
  position: fixed;
  right: 24px;
  bottom: 92px; /* space for fab */
  width: 380px;
  height: 580px;
  display: none; /* toggled by JS */
  flex-direction: column;
  background: var(--va-elev);
  color: var(--va-text);
  border: 1px solid var(--va-border);
  border-radius: var(--va-radius);
  box-shadow: var(--va-shadow);
  overflow: hidden;
  transform-origin: 90% 100%;
}
@media (max-width: 520px) {
  #va-chatbot-root { inset: 0; }
  #va-chatbot-root .va-fab { position: fixed; right: 16px; bottom: 16px; }
  #va-chatbot-root .va-panel {
    right: 0; bottom: 0; left: 0; top: 0;
    width: 100vw; height: 100vh; border-radius: 0;
  }
}

/* Subtle open/close animation (respects reduced motion) */
@media (prefers-reduced-motion: no-preference) {
  #va-chatbot-root .va-panel[style*="display: flex"] {
    animation: va-pop .18s ease-out;
  }
  @keyframes va-pop {
    from { transform: scale(.98); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
  }
}

/* Header */
.va-panel .va-header {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--va-border);
  background: linear-gradient(180deg, rgba(0,0,0,.02), transparent);
}
.va-panel .va-title {
  font-weight: 700;
  letter-spacing: .2px;
}
.va-panel .va-close {
  all: unset; cursor: pointer;
  width: 34px; height: 34px; border-radius: 8px;
  display: grid; place-items: center;
}
.va-panel .va-close:hover { background: rgba(0,0,0,.06); }
body[data-va-theme="dark"] .va-panel .va-close:hover { background: rgba(255,255,255,.06); }

/* Tabs */
.va-tabs { display: flex; gap: 6px; }
.va-tab {
  all: unset; cursor: pointer; font-weight: 600; font-size: 13px;
  padding: 6px 10px; border-radius: 999px; color: var(--va-subtle);
}
.va-tab.active {
  color: #fff; background: var(--va-primary);
}

/* Body areas */
.va-body { display: grid; grid-template-rows: 1fr; min-height: 0; }
.va-chat-area, .va-book-area { height: 100%; overflow: auto; padding: 12px; }

/* Suggestion */
.va-suggestion {
  color: var(--va-subtle);
  font-size: 12px;
  padding: 6px 12px;
  border-top: 1px solid var(--va-border);
}

/* Input Row */
.va-input {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--va-border);
  background: var(--va-bg);
}
.va-input input {
  width: 100%;
  padding: 10px 12px;
  background: var(--va-input-bg);
  border: 1px solid var(--va-input-border);
  border-radius: var(--va-radius-sm);
  color: var(--va-text);
}
.va-input input:focus { outline: none; border-color: var(--va-input-focus); box-shadow: 0 0 0 3px rgba(147,197,253,.4); }

.va-input .va-send,
.va-input .va-voice {
  all: unset; cursor: pointer;
  padding: 10px 12px;
  border-radius: var(--va-radius-sm);
  border: 1px solid var(--va-border);
  background: var(--va-elev);
}
.va-input .va-send {
  background: var(--va-primary); color: #fff; border-color: var(--va-primary);
  font-weight: 600;
}
.va-input .va-send:hover { background: var(--va-primary-600); }
.va-input .va-voice:hover { background: rgba(0,0,0,.06); }
body[data-va-theme="dark"] .va-input .va-voice:hover { background: rgba(255,255,255,.06); }
.va-input .va-send:focus-visible, .va-input .va-voice:focus-visible {
  outline: 3px solid var(--va-input-focus); outline-offset: 2px;
}

/* ========== Chat Bubbles ========== */
.va-msg { display: flex; margin: 10px 0; }
.va-msg.user { justify-content: flex-end; }
.va-bubble {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.35;
  font-size: 14px;
  border: 1px solid var(--va-border);
  background: var(--va-bubble-bot);
  color: var(--va-text);
  word-wrap: break-word;
}
.va-msg.user .va-bubble {
  background: var(--va-bubble-user);
  color: var(--va-bubble-user-text);
  border-color: transparent;
}
.va-bubble p { margin: 0 0 8px; }
.va-bubble p:last-child { margin: 0; }

/* Subtle tails */
.va-msg.bot .va-bubble { border-bottom-left-radius: 4px; }
.va-msg.user .va-bubble { border-bottom-right-radius: 4px; }

/* Scrollbars (webkit) */
.va-chat-area::-webkit-scrollbar,
.va-book-area::-webkit-scrollbar { width: 10px; }
.va-chat-area::-webkit-scrollbar-thumb,
.va-book-area::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 8px; }
body[data-va-theme="dark"] .va-chat-area::-webkit-scrollbar-thumb,
body[data-va-theme="dark"] .va-book-area::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); }

/* ========== Booking Wizard ========== */
.va-steps {
  display: flex; gap: 8px; padding: 8px 8px 10px;
  position: sticky; top: 0; background: var(--va-elev); z-index: 1;
}
.va-step {
  flex: 1;
  background: var(--va-step-bg);
  color: var(--va-subtle);
  text-align: center;
  padding: 8px 6px;
  border-radius: 999px;
  font-weight: 600; font-size: 12px;
  border: 1px solid var(--va-border);
}
.va-step.active {
  background: var(--va-primary);
  color: #fff;
  border-color: var(--va-primary);
}

.va-step-pane { padding: 12px 8px; }
.va-label { font-size: 13px; font-weight: 600; margin-bottom: 6px; display:block; }
.va-help { color: var(--va-subtle); font-size: 12px; margin-top: 6px; }

/* Slots grid */
.va-slots {
  display: grid; grid-template-columns: repeat(auto-fill,minmax(86px,1fr));
  gap: 8px; margin-top: 8px;
}
.va-slot {
  all: unset; cursor: pointer;
  padding: 10px 10px;
  text-align: center;
  border-radius: 12px;
  border: 1px solid var(--va-border);
  background: var(--va-bg);
  font-weight: 600; font-size: 14px;
  transition: background .15s ease, border-color .15s ease, transform .08s ease;
}
.va-slot:hover { background: var(--va-primary-100); }
.va-slot.active {
  background: var(--va-primary);
  color: #fff;
  border-color: var(--va-primary);
}
.va-slot[disabled] { opacity: .45; cursor: not-allowed; text-decoration: line-through; }
.va-pill {
  display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 700;
  padding: 2px 6px; border-radius: 999px; background: rgba(0,0,0,.07);
}
body[data-va-theme="dark"] .va-pill { background: rgba(255,255,255,.12); }

/* People & Contact */
.va-input-control {
  width: 100%; box-sizing: border-box;
  padding: 10px 12px; border-radius: var(--va-radius-sm);
  border: 1px solid var(--va-input-border);
  background: var(--va-input-bg);
  color: var(--va-text);
}
.va-input-control:focus { outline: none; border-color: var(--va-input-focus); box-shadow: 0 0 0 3px rgba(147,197,253,.35); }
.va-required { color: var(--va-bad); }

.va-grid {
  display: grid; gap: 10px;
  grid-template-columns: 110px 1fr;
  align-items: center;
}
.va-grid textarea { min-height: 90px; resize: vertical; }

/* Review */
.va-review {
  display: grid; gap: 8px;
  padding: 10px; border: 1px dashed var(--va-border);
  border-radius: 12px; background: rgba(0,0,0,.02);
}
body[data-va-theme="dark"] .va-review { background: rgba(255,255,255,.03); }

/* Wizard actions */
.va-wizard-actions {
  position: sticky; bottom: 0;
  display: flex; gap: 8px; padding: 10px 8px;
  background: linear-gradient(180deg, transparent, var(--va-elev) 40%);
}
.va-btn {
  all: unset; cursor: pointer; user-select: none;
  padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--va-border); background: var(--va-elev);
  font-weight: 700; font-size: 14px; text-align: center;
}
.va-prev { color: var(--va-subtle); }
.va-next, .va-submit { background: var(--va-primary); color: #fff; border-color: var(--va-primary); }
.va-btn:hover { filter: brightness(1.03); }
.va-btn:disabled { opacity: .5; cursor: not-allowed; }
.va-btn:focus-visible { outline: 3px solid var(--va-input-focus); outline-offset: 2px; }

/* Links inside bubbles */
.va-bubble a { color: var(--va-primary); text-decoration: none; }
.va-bubble a:hover { text-decoration: underline; }

/* Accessibility: focus outlines for key interactive elements */
.va-slot:focus-visible,
.va-tab:focus-visible,
.va-close:focus-visible {
  outline: 3px solid var(--va-input-focus);
  outline-offset: 2px;
}

/* Utility: place widget on left if you add .va-left to root */
#va-chatbot-root.va-left {
  inset: auto auto 24px 24px;
}
#va-chatbot-root.va-left .va-panel { right: auto; left: 24px; }
@media (max-width: 520px) {
  #va-chatbot-root.va-left { inset: 0; }
}
