/* ============================================================================
   booking-widget.css — design-AGNOSTIC structural stylesheet for the booking
   widget. Layout/structure is baked in; every color, font, radius and shadow
   is a CSS custom property (--bw-*) with a neutral fallback.

   A host website skins the widget in ONE of two ways (see README.md):
     1. Override the --bw-* tokens in a :root or scoped block (recommended).
     2. Override the .bw-* classes directly with its own CSS (full control).

   The defaults below are an intentionally plain, legible neutral theme — they
   exist so the widget is usable before any theming, NOT to define a brand.
   ========================================================================== */

.bw-modal {
  /* --- design tokens (override these from the host design system) --- */
  --bw-font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --bw-overlay: rgba(0, 0, 0, 0.5);
  --bw-surface: #ffffff;          /* modal window background        */
  --bw-surface-2: #f4f4f5;        /* inputs, slot buttons, panels   */
  --bw-border: rgba(0, 0, 0, 0.12);
  --bw-text: #18181b;             /* primary text                   */
  --bw-text-muted: #71717a;       /* subtitles, secondary text      */
  --bw-accent: #2563eb;           /* selection, primary button, focus */
  --bw-accent-contrast: #ffffff;  /* text/icon on top of --bw-accent  */
  --bw-success: #16a34a;
  --bw-error: #dc2626;
  --bw-radius: 16px;
  --bw-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* === OVERLAY / CONTAINER ================================================== */
.bw-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--bw-font-family);
}
.bw-modal.is-open {
  pointer-events: auto;
  opacity: 1;
}
.bw-backdrop {
  position: absolute;
  inset: 0;
  background: var(--bw-overlay);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* === WINDOW =============================================================== */
.bw-window {
  position: relative;
  box-sizing: border-box;
  width: 90%;
  max-width: 680px;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--bw-surface);
  border: 1px solid var(--bw-border);
  box-shadow: var(--bw-shadow);
  border-radius: calc(var(--bw-radius) + 8px);
  padding: 3rem;
  color: var(--bw-text);
  transform: translateY(20px) scale(0.98);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.5s ease;
  opacity: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--bw-border) transparent;
}
.bw-modal.is-open .bw-window {
  transform: translateY(0) scale(1);
  opacity: 1;
}
.bw-window::-webkit-scrollbar { width: 10px; }
.bw-window::-webkit-scrollbar-track { background: transparent; }
.bw-window::-webkit-scrollbar-thumb {
  background: var(--bw-border);
  border-radius: 9999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

/* === CLOSE BUTTON ======================================================== */
.bw-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bw-surface-2);
  border: 1px solid var(--bw-border);
  color: var(--bw-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
}
.bw-close:hover {
  color: var(--bw-text);
  transform: rotate(90deg);
}

/* === HEADER ============================================================== */
.bw-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-right: 4rem;
}
.bw-title {
  font-size: 2rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
  color: var(--bw-text);
}
.bw-subtitle {
  font-size: 1rem;
  color: var(--bw-text-muted);
  line-height: 1.5;
  margin: 0 0 2.5rem;
}

/* language toggle (only shown when >1 language is configured) */
.bw-lang-toggle {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  background: var(--bw-surface-2);
  border: 1px solid var(--bw-border);
  border-radius: 999px;
  padding: 0.25rem;
}
.bw-lang-btn {
  background: transparent;
  border: none;
  color: var(--bw-text-muted);
  padding: 0.5rem 1rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.3s ease;
}
.bw-lang-btn.is-active {
  background: var(--bw-accent);
  color: var(--bw-accent-contrast);
}
.bw-lang-divider {
  width: 1px;
  height: 16px;
  background: var(--bw-border);
  margin: 0 0.25rem;
}

/* timezone bar — view-only display switch */
.bw-tzbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: -1rem 0 1.5rem;
  font-size: 0.85rem;
  color: var(--bw-text-muted);
}
.bw-tz-icon { font-size: 1rem; line-height: 1; }
.bw-tz-input {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--bw-border);
  background: var(--bw-surface-2);
  color: var(--bw-text);
  cursor: text;
  flex: 1 1 16rem;
  min-width: 12rem;
  max-width: 100%;
}
.bw-tz-input:focus {
  outline: none;
  border-color: var(--bw-accent, var(--bw-border));
}

/* === SCHEDULER SHELL ===================================================== */
.bw-scheduler {
  width: 100%;
  min-height: 400px;
  border-radius: var(--bw-radius);
  background: var(--bw-surface-2);
  border: 1px dashed var(--bw-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* loader */
.bw-loader {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  text-align: center;
}
.bw-spinner {
  width: 4rem;
  height: 4rem;
  border: 4px solid var(--bw-border);
  border-top-color: var(--bw-accent);
  border-radius: 50%;
  animation: bw-spin 1s linear infinite;
  margin: 0 auto 1rem;
}
.bw-loader-text {
  color: var(--bw-text-muted);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}
.bw-fetch-error {
  color: var(--bw-error);
  padding: 1rem;
  text-align: center;
  margin: 0.5rem 0 0;
}

/* interactive area */
.bw-interactive {
  padding: 1.5rem;
  width: 100%;
  box-sizing: border-box;
}
.bw-carousel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* horizontal date strip */
.bw-date-list {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 0.5rem;
  scrollbar-width: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.bw-date-list::-webkit-scrollbar { display: none; }

/* time grid (scrolls natively) */
.bw-time-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.5rem;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 0.25rem;
  scrollbar-width: auto;
  scrollbar-color: var(--bw-accent) var(--bw-surface-2);
}
.bw-empty {
  color: var(--bw-text-muted);
  font-size: 0.875rem;
  margin: 0;
}

/* slot buttons (shared by dates + times) */
.bw-slot {
  background: var(--bw-surface);
  border: 1px solid var(--bw-border);
  border-radius: 8px;
  color: var(--bw-text);
  padding: 0.875rem 1rem;
  font: inherit;
  font-size: 0.95rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}
.bw-date-list .bw-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  scroll-snap-align: start;
  flex-shrink: 0;
  min-width: 80px;
  padding: 1rem 0.5rem;
}
.bw-date-day {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--bw-text-muted);
}
.bw-date-date {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--bw-text);
}
.bw-slot:hover:not(:disabled) {
  border-color: var(--bw-accent);
  transform: translateY(-2px);
}
.bw-slot.is-selected {
  border-color: var(--bw-accent);
  color: var(--bw-accent);
  box-shadow: inset 0 0 0 1px var(--bw-accent);
}
.bw-slot:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* === BOOKING FORM ======================================================== */
.bw-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px dashed var(--bw-border);
}
.bw-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.bw-form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.bw-form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--bw-text);
  letter-spacing: 0.02em;
}
.bw-form-group input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bw-surface-2);
  border: 1px solid var(--bw-border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  color: var(--bw-text);
  font: inherit;
  font-size: 1rem;
  transition: all 0.3s ease;
}
.bw-form-group input::placeholder { color: var(--bw-text-muted); }
.bw-form-group input:focus {
  outline: none;
  border-color: var(--bw-accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--bw-accent) 20%, transparent);
}

/* submit */
.bw-submit {
  margin-top: 1rem;
  width: 100%;
  min-height: 54px;
  background: var(--bw-accent);
  color: var(--bw-accent-contrast);
  border: none;
  border-radius: 999px;
  padding: 1.25rem 2rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}
.bw-submit:hover:not(:disabled) { transform: translateY(-2px); }
.bw-submit:disabled { opacity: 0.7; cursor: not-allowed; }
.bw-btn-loader {
  width: 20px;
  height: 20px;
  border: 2px solid color-mix(in srgb, var(--bw-accent-contrast) 30%, transparent);
  border-top-color: var(--bw-accent-contrast);
  border-radius: 50%;
  animation: bw-spin 0.8s linear infinite;
}

/* === SUCCESS ============================================================= */
.bw-success {
  text-align: center;
  padding: 2rem 0;
}
.bw-success-icon { margin-bottom: 1rem; color: var(--bw-success); }
.bw-success h4 { font-size: 1.5rem; font-weight: 600; margin: 0 0 0.5rem; }
.bw-success p { color: var(--bw-text-muted); margin: 0; }

@keyframes bw-spin { to { transform: rotate(360deg); } }

/* === RESPONSIVE (short viewports / phones in landscape) ================== */
@media screen and (max-height: 500px) {
  .bw-modal { align-items: flex-start; padding-top: 0.25rem; }
  .bw-window { max-height: 98dvh; padding: 0.75rem; border-radius: 8px; }
  .bw-title { font-size: 1.1rem; margin-bottom: 0.25rem; }
  .bw-subtitle { font-size: 0.85rem; margin-bottom: 0.75rem; }
  .bw-scheduler { min-height: 0; }
  .bw-time-list { max-height: 120px; }
}
@media screen and (max-width: 560px) {
  .bw-window { padding: 1.5rem; }
  .bw-header { padding-right: 3.5rem; }
  .bw-form-grid { grid-template-columns: 1fr; }
}
