:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #00b4d8;
  --accent-fg: #ffffff;
  --navy: #0a1628;
  --navy-fg: #ffffff;
  --bubble-user: #00b4d8;
  --bubble-user-fg: #ffffff;
  --bubble-bot: #f3f4f6;
  --bubble-bot-fg: #1f2937;
  --font-heading: 'Syne', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Deliberately navy-tinted rather than neutral gray, so dark mode still
       reads as this brand rather than a generic dark theme. */
    --bg: #0a1628;
    --fg: #e5e7eb;
    --muted: #94a3b8;
    --border: #1e2c42;
    --bubble-bot: #142137;
    --bubble-bot-fg: #f0f0f0;
  }
}

* { box-sizing: border-box; }

/* The `hidden` attribute's default `display: none` comes from the browser's
   user-agent stylesheet, which any author rule setting `display` on the same
   element silently overrides, even one with lower specificity (author styles
   always beat UA styles). Several rules below (.chat, .booking-form,
   .chat-input, .widget) set `display: flex` unconditionally, which was
   quietly defeating every `hidden` toggle on those elements: the gate,
   chat, and booking-form sections were all rendering stacked at once
   regardless of which one JS said should be showing. This one rule fixes it
   globally, for every element, present or future. */
[hidden] { display: none !important; }

html {
  background: var(--bg);
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
}

/*
 * Iframe embed: kill the opaque page canvas.
 * What was winning before: prefers-color-scheme:dark sets --bg to #0a1628, and
 * :root { color-scheme: light dark } makes Chromium paint an opaque dark
 * iframe canvas that plain `background: transparent` on body does not clear.
 * Reset color-scheme + force transparent on html/body with !important.
 */
html.mde-embedded {
  color-scheme: normal !important;
  background: transparent !important;
  background-color: transparent !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

html.mde-embedded body {
  color-scheme: normal !important;
  background: transparent !important;
  background-color: transparent !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

.launcher-btn {
  --launcher-size: 60px;
  --launcher-inset: 24px;
  --teaser-gap: 3px;

  position: fixed;
  bottom: var(--launcher-inset);
  right: var(--launcher-inset);
  width: var(--launcher-size);
  height: var(--launcher-size);
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-fg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  z-index: 1000;
}

.launcher-btn svg {
  width: 28px;
  height: 28px;
}

.launcher-btn:hover {
  filter: brightness(1.1);
}

.launcher-teaser {
  /* Keep the bubble vertically centered on the launcher and close the gap. */
  --launcher-size: 60px;
  --launcher-inset: 24px;
  --teaser-gap: 3px;

  position: fixed;
  bottom: calc(var(--launcher-inset) + (var(--launcher-size) / 2));
  right: calc(var(--launcher-inset) + var(--launcher-size) + var(--teaser-gap));
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: min(260px, calc(100vw - 120px));
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  z-index: 1000;
  transform: translateY(50%);
  animation: launcher-teaser-in 0.35s ease-out;
}

.launcher-teaser::after {
  content: '';
  position: absolute;
  top: 50%;
  right: -5px;
  bottom: auto;
  width: 10px;
  height: 10px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transform: translateY(-50%) rotate(-45deg);
}

.launcher-teaser-body {
  flex: 1;
  margin: 0;
  padding: 12px 6px 12px 14px;
  border: none;
  background: transparent;
  color: inherit;
  font: 500 13.5px/1.35 var(--font-body);
  text-align: left;
  cursor: pointer;
}

.launcher-teaser-dismiss {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin: 0 4px 0 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.launcher-teaser-dismiss:hover {
  color: var(--fg);
  background: var(--bubble-bot);
}

@keyframes launcher-teaser-in {
  from {
    opacity: 0;
    transform: translateY(calc(50% + 8px)) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(50%) scale(1);
  }
}

@media (max-width: 480px) {
  .launcher-btn {
    --launcher-inset: 16px;
    --teaser-gap: 2px;
  }

  .launcher-teaser {
    --launcher-inset: 16px;
    --teaser-gap: 2px;
    right: calc(var(--launcher-inset) + var(--launcher-size) + var(--teaser-gap));
    bottom: calc(var(--launcher-inset) + (var(--launcher-size) / 2));
  }
}

/*
 * The website iframe is only ~380–420px wide, so max-width media queries
 * always look "mobile" even on desktop. Embedded spacing is controlled by
 * classes set from the parent page's real viewport instead.
 */
html.mde-embedded .launcher-btn,
html.mde-embedded .launcher-teaser {
  --launcher-inset: 24px;
  --teaser-gap: 3px;
}

html.mde-embedded.mde-compact .launcher-btn,
html.mde-embedded.mde-compact .launcher-teaser {
  --launcher-inset: 16px;
  --teaser-gap: 2px;
}

.widget {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 100%;
  max-width: 380px;
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: min(640px, calc(100vh - 140px));
  background: var(--bg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 999;
}

@media (max-width: 480px) {
  .widget {
    right: 12px;
    left: 12px;
    bottom: 88px;
    max-width: none;
    width: auto;
  }
}

.widget-header {
  padding: 16px 20px;
  background: var(--navy);
  color: var(--navy-fg);
}

.widget-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.widget-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.widget-brand-text {
  min-width: 0;
}

.widget-logo {
  height: 32px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.reset-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: transparent;
  color: var(--navy-fg);
  cursor: pointer;
}

.reset-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.7);
}

.widget-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  line-height: 1.2;
}

.widget-subtitle {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.75rem;
  margin-top: 2px;
  white-space: nowrap;
}

.gate {
  flex: 1;
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
}

/* When embedded, prefer fitting the lead form without an inner scrollbar. */
html.mde-embedded .widget {
  height: min(640px, calc(100vh - 120px));
}

html.mde-embedded .gate {
  display: flex;
  flex-direction: column;
}

html.mde-embedded #gate-form {
  flex: 1;
}

.gate-welcome {
  margin: 0 0 16px;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--fg);
}

#gate-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#gate-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

#gate-form input {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  font-size: 1rem;
  font-family: var(--font-body);
}

#gate-form input:focus, .booking-form textarea:focus, .booking-form input:focus, #chat-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#gate-form button, .chat-input button, #booking-submit-btn {
  padding: 10px 20px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
}

#gate-form button:disabled, .chat-input button:disabled, #booking-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.error {
  color: #dc2626;
  font-size: 0.85rem;
}

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.4;
  font-size: 0.95rem;
  white-space: pre-wrap;
}

.bubble.user {
  align-self: flex-end;
  background: var(--bubble-user);
  color: var(--bubble-user-fg);
  border-bottom-right-radius: 4px;
}

.bubble.bot {
  align-self: flex-start;
  background: var(--bubble-bot);
  color: var(--bubble-bot-fg);
  border-bottom-left-radius: 4px;
}

.bubble.bot strong {
  font-weight: 700;
  color: var(--bubble-bot-fg);
}

.bubble.bot .option-line {
  display: inline;
  font-weight: 700;
}

.bubble.bot .price-highlight {
  color: var(--accent);
  font-weight: 700;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  padding: 0.05em 0.35em;
  border-radius: 4px;
  white-space: nowrap;
}

.bubble.typing {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 1.2em;
  padding-top: 14px;
  padding-bottom: 14px;
  color: var(--muted);
  font-style: normal;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.35;
  animation: typing-bounce 1.2s ease-in-out infinite;
}

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

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

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

.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.quick-reply-btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 0.88rem;
  font-family: var(--font-body);
  cursor: pointer;
  max-width: 100%;
}

.quick-reply-btn:hover {
  background: var(--accent);
  color: var(--accent-fg);
}

.booking-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: var(--bubble-bot);
}

.booking-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.booking-form textarea,
.booking-form input[type='date'] {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font-size: 0.95rem;
  font-family: inherit;
  resize: none;
}

.booking-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.secondary-btn {
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  font-family: var(--font-body);
}

.secondary-btn:hover {
  color: var(--fg);
  border-color: var(--fg);
}

.chat-input {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

#chat-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  font-size: 1rem;
  font-family: var(--font-body);
}
