/*
 * booking-agent.css — Premier Booker text-booking chat widget
 *
 * Self-contained, scoped under the .pba- prefix so it can be embedded on any
 * page without colliding with host styles. Uses the project design system
 * (navy / gold / cream; Cormorant Garamond headings + DM Sans body).
 *
 * The widget is hidden by default. booking-agent.js adds .pba-ready to
 * #pba-root only after a runtime check confirms the feature is enabled.
 */

#pba-root,
#pba-root * { box-sizing: border-box; }

/* Hidden until the runtime gate says the feature is on. */
#pba-root { display: none; }
#pba-root.pba-ready { display: block; }

:root {
  --pba-navy:  #0a0f1e;
  --pba-n2:    #0f172a;
  --pba-n3:    #1a2540;
  --pba-n4:    #243050;
  --pba-gold:  #c9a55a;
  --pba-gl:    #e8c98e;
  --pba-cream: #f4ede0;
  --pba-muted: #d8e2f2;
}

/* ── Floating launcher button ─────────────────────────────────────────────── */
.pba-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483600;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px;
  border: 1px solid var(--pba-gold);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--pba-n3), var(--pba-navy));
  color: var(--pba-cream);
  font-family: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.38);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.pba-launcher:hover { transform: translateY(-2px); box-shadow: 0 12px 34px rgba(0, 0, 0, 0.46); }
.pba-launcher:focus-visible { outline: 2px solid var(--pba-gl); outline-offset: 3px; }
.pba-launcher svg { width: 20px; height: 20px; flex: none; fill: var(--pba-gold); }
#pba-root.pba-open .pba-launcher { display: none; }

/* ── Chat panel ───────────────────────────────────────────────────────────── */
.pba-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483601;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 32px);
  display: none;
  flex-direction: column;
  border: 1px solid var(--pba-n4);
  border-radius: 16px;
  overflow: hidden;
  background: var(--pba-navy);
  color: var(--pba-cream);
  font-family: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 0.95rem;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}
#pba-root.pba-open .pba-panel { display: flex; }

/* ── Header ───────────────────────────────────────────────────────────────── */
.pba-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--pba-n3), var(--pba-n2));
  border-bottom: 1px solid var(--pba-n4);
}
.pba-header-title {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.1;
  color: var(--pba-cream);
}
.pba-header-sub {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--pba-muted);
}
.pba-close {
  flex: none;
  width: 34px;
  height: 34px;
  border: 1px solid var(--pba-n4);
  border-radius: 50%;
  background: transparent;
  color: var(--pba-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.pba-close:hover { background: var(--pba-n4); color: var(--pba-cream); }
.pba-close:focus-visible { outline: 2px solid var(--pba-gl); outline-offset: 2px; }

/* ── Message list ─────────────────────────────────────────────────────────── */
.pba-log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background:
    radial-gradient(1200px 400px at 100% 0%, rgba(201, 165, 90, 0.06), transparent 60%),
    var(--pba-navy);
}
.pba-msg {
  max-width: 84%;
  padding: 10px 13px;
  border-radius: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.pba-msg-bot {
  align-self: flex-start;
  background: var(--pba-n2);
  border: 1px solid var(--pba-n4);
  color: var(--pba-cream);
  border-bottom-left-radius: 5px;
}
.pba-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--pba-gold), var(--pba-gl));
  color: var(--pba-navy);
  font-weight: 500;
  border-bottom-right-radius: 5px;
}
.pba-msg-note {
  align-self: center;
  max-width: 92%;
  text-align: center;
  font-size: 0.8rem;
  color: var(--pba-muted);
  background: transparent;
  padding: 4px 8px;
}

/* Typing indicator */
.pba-typing { display: inline-flex; gap: 5px; align-items: center; }
.pba-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--pba-muted);
  animation: pba-bounce 1.1s infinite ease-in-out;
}
.pba-typing span:nth-child(2) { animation-delay: 0.15s; }
.pba-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes pba-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* ── Input row ────────────────────────────────────────────────────────────── */
.pba-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--pba-n4);
  background: var(--pba-n2);
}
.pba-input {
  flex: 1 1 auto;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  padding: 11px 12px;
  border: 1px solid var(--pba-n4);
  border-radius: 10px;
  background: var(--pba-navy);
  color: var(--pba-cream);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
}
.pba-input::placeholder { color: #9aa0b0; }
.pba-input:focus { outline: none; border-color: var(--pba-gold); }
.pba-send {
  flex: none;
  width: 44px;
  height: 44px;
  align-self: flex-end;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--pba-gold), var(--pba-gl));
  color: var(--pba-navy);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.pba-send:hover { transform: translateY(-1px); }
.pba-send:disabled { opacity: 0.45; cursor: default; transform: none; }
.pba-send:focus-visible { outline: 2px solid var(--pba-navy); outline-offset: 2px; }
.pba-send svg { width: 20px; height: 20px; fill: var(--pba-navy); }

/* ── Footer disclaimer ────────────────────────────────────────────────────── */
.pba-foot {
  padding: 6px 12px 10px;
  font-size: 0.72rem;
  text-align: center;
  color: var(--pba-muted);
  background: var(--pba-n2);
}

/* ── Mobile ───────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .pba-panel {
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
  }
  .pba-launcher { right: 14px; bottom: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .pba-launcher, .pba-send, .pba-typing span { transition: none; animation: none; }
}

/* ── Inline mode ──────────────────────────────────────────────────────────────
   A host that already HAS a place for the assistant — the passenger portal's
   "AI Dispatch" tab is a whole screen of it — does not want a floating bubble
   sitting on top of its own layout. Setting data-pba-inline on #pba-root drops
   the launcher and renders the panel in flow, filling its container.

   No JS change: build() still creates the launcher and leaves the panel closed,
   and both of those are decided here. The runtime gate is untouched — nothing
   below applies until the script adds .pba-ready, which it only does after
   booking-agent.php?status=1 reports enabled.

   These selectors carry an id + an attribute, so they outrank the .pba-panel
   rules inside the max-width:480px block above regardless of source order. */
#pba-root[data-pba-inline] { width: 100%; }
#pba-root[data-pba-inline] .pba-launcher { display: none; }
#pba-root[data-pba-inline] .pba-close { display: none; }
#pba-root[data-pba-inline] .pba-panel {
  position: static;
  display: flex;
  right: auto;
  bottom: auto;
  width: 100%;
  max-width: 100%;
  /* Tall enough to hold a conversation, short enough that the host page's own
     chrome (tab bar, header) stays reachable without scrolling past the panel. */
  height: min(72vh, 620px);
  max-height: none;
  border-radius: 14px;
  border: 1px solid var(--pba-n4);
  box-shadow: none;
}
