/* ─────────────────────────────────────────────
   Design tokens
   ───────────────────────────────────────────── */
:root {
  --color-bg:           #f8fafc;
  --color-surface:      #ffffff;
  --color-border:       #e2e8f0;
  --color-border-focus: #3b82f6;
  --color-primary:      #1d4ed8;
  --color-primary-hover:#1e40af;
  --color-primary-text: #ffffff;
  --color-text:         #1e293b;
  --color-text-muted:   #64748b;
  --color-text-light:   #94a3b8;
  --color-success:      #0f766e;
  --color-error:        #dc2626;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-card: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-btn:  0 1px 2px rgba(0,0,0,.1);

  --font-sans: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont,
               'Helvetica Neue', Arial, sans-serif;

  --container-max: 1080px;
  --col-left:  62%;
  --col-right: 35%;
  --gap:       3%;
}

/* ─────────────────────────────────────────────
   Reset & base
   ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}
a:hover { color: var(--color-primary-hover); }

/* ─────────────────────────────────────────────
   Layout helpers
   ───────────────────────────────────────────── */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 24px;
}

.container.container--narrow {
  max-width: 480px;
}

/* ─────────────────────────────────────────────
   Site header
   ───────────────────────────────────────────── */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  gap: 16px;
}

.site-header__brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -0.02em;
}

/* ─────────────────────────────────────────────
   Breadcrumb
   ───────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.breadcrumb__sep { color: var(--color-text-light); }

.breadcrumb__item {
  text-decoration: none;
}

.breadcrumb__item[href]:hover {
  text-decoration: underline;
}

.breadcrumb__item--active {
  color: var(--color-text);
  font-weight: 600;
}

.breadcrumb__item--link {
  color: var(--color-text-muted);
  text-decoration: none;
}

.breadcrumb__item--link:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

/* ─────────────────────────────────────────────
   Main / page title
   ───────────────────────────────────────────── */
.main { padding: 36px 0 72px; }

.page-title-wrap { margin-bottom: 28px; }

.page-title {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.page-subtitle {
  margin-top: 4px;
  font-size: 0.9375rem;
  color: var(--color-text-muted);
}

/* ─────────────────────────────────────────────
   Two-column booking layout
   ───────────────────────────────────────────── */
.booking-layout {
  display: flex;
  align-items: flex-start;
  gap: var(--gap);
}

.booking-left  { flex: 0 0 var(--col-left);  min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.booking-right { flex: 0 0 var(--col-right); min-width: 0; }

.price-sticky {
  position: sticky;
  top: 80px; /* clears sticky header */
}

/* ─────────────────────────────────────────────
   Cards
   ───────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-card);
}

.card__heading {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.015em;
  margin-bottom: 22px;
}

/* ─────────────────────────────────────────────
   Form
   ───────────────────────────────────────────── */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}
.form-group:last-child { margin-bottom: 0; }

.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
}

.form-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  appearance: none;
}

.form-input::placeholder { color: var(--color-text-light); }

.form-input:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

.form-input.is-invalid {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px rgba(220,38,38,.1);
}

.form-error {
  font-size: 0.8125rem;
  color: var(--color-error);
  min-height: 1em;
}

/* Select */
.select-wrap { position: relative; }

.form-select {
  padding-right: 36px;
  cursor: pointer;
  background-color: var(--color-surface);
}

.select-arrow {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* ─────────────────────────────────────────────
   Rental policy
   ───────────────────────────────────────────── */
.policy-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.policy-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.policy-item__icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #dcfce7;
  color: #15803d;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.policy-item__title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
}

.policy-item__body {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  line-height: 1.65;
}

.policy-footer {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--color-border);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* ─────────────────────────────────────────────
   Booking protection widget overrides
   ───────────────────────────────────────────── */
#booking-protection-mount {
  display: none;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#booking-protection-mount.is-visible {
  display: block;
}

#booking-protection-mount.is-visible.is-animated {
  opacity: 1;
  transform: translateY(0);
}

#booking-protection-mount .bpw-card {
  max-width: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

/* The widget always renders its "Upgrade your booking and receive a
 * refund..." paragraph (.bpw-desc) with an inline display:none whenever
 * safelyProductsApiEndpoint is configured, which this integration always
 * does — !important is required to beat that inline style. Only shown for
 * a locked existing policy (see .policy-locked in app.js), where it's
 * useful context in place of the other options this app hides for that case. */
#booking-protection-mount.policy-locked .bpw-desc {
  display: block !important;
}

.protection-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.protection-loading[hidden] {
  display: none;
}

.protection-loading__spinner {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: protection-loading-spin 0.7s linear infinite;
}

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

/* ─────────────────────────────────────────────
   Price details card
   ───────────────────────────────────────────── */
.card--price { padding: 24px; }

.price-image {
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 16px;
  line-height: 0;
}

.price-image img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}

.price-property {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 20px;
}

.price-property__name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.price-property__id {
  margin-top: 3px;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.price-reservation {
  margin-top: 12px;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.price-reservation__id {
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
}

.price-divider {
  height: 1px;
  background: var(--color-border);
  margin: 16px 0;
}

.price-lines {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.price-line {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  font-size: 0.9rem;
}

.price-line__label-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.price-line__label { color: var(--color-text-muted); }
.price-line__amount { font-weight: 500; color: var(--color-text); }

.price-line__sublabel {
  font-size: 0.75rem;
  color: var(--color-text-light);
}

.price-line--sub .price-line__label {
  font-size: 0.8125rem;
  padding-left: 12px;
  color: var(--color-text-light);
}
.price-line--sub .price-line__amount { font-size: 0.8125rem; color: var(--color-text-light); }

.price-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.price-total__label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
}

.price-total__amount {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
}

/* ─────────────────────────────────────────────
   Confirm button
   ───────────────────────────────────────────── */
.btn-confirm {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 14px 24px;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.6;
  color: var(--color-primary-text);
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  letter-spacing: 0.01em;
}

.btn-confirm:hover {
  background: var(--color-primary-hover);
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
  transform: translateY(-1px);
}

.btn-confirm:active {
  transform: translateY(1px);
  box-shadow: var(--shadow-btn);
}

.btn-confirm:disabled {
  background: var(--color-text-light);
  cursor: not-allowed;
  box-shadow: none;
}

.btn-create {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 14px 24px;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.6;
  text-align: center;
  text-decoration: none;
  color: var(--color-primary-text);
  background: var(--color-success);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  letter-spacing: 0.01em;
}

.btn-create:hover {
  background: #0b5c56;
  color: var(--color-primary-text);
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
  transform: translateY(-1px);
}

.btn-create:active {
  transform: translateY(1px);
  box-shadow: var(--shadow-btn);
}

.price-note {
  margin-top: 10px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-text-light);
}

/* ─────────────────────────────────────────────
   Look up reservation
   ───────────────────────────────────────────── */
.lookup-hint {
  margin-top: 16px;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--color-text-light);
}

/* ─────────────────────────────────────────────
   Error snackbar
   ───────────────────────────────────────────── */
.snackbar-container {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(90vw, 420px);
  pointer-events: none;
}

.snackbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--color-error);
  color: var(--color-primary-text);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
  font-size: 0.875rem;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: auto;
}

.snackbar.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.snackbar__message { flex: 1; }

.snackbar__close {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

/* ─────────────────────────────────────────────
   Booking confirmation page
   ───────────────────────────────────────────── */
.page-title--confirmed {
  display: flex;
  align-items: center;
  gap: 12px;
}

.confirmation-check { flex-shrink: 0; }

.confirmation-error {
  padding: 24px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  text-align: center;
}

.confirmation-error__message {
  color: var(--color-error);
  margin-bottom: 16px;
}

.status-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  vertical-align: middle;
}

.status-badge--active    { background: #dcfce7; color: #15803d; }
.status-badge--claim     { background: #fef9c3; color: #854d0e; }
.status-badge--inactive  { background: #f1f5f9; color: var(--color-text-muted); }
.status-badge--neutral   { background: #f1f5f9; color: var(--color-text-muted); }

/* ─────────────────────────────────────────────
   Responsive
   ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .booking-layout {
    flex-direction: column;
  }

  .booking-left,
  .booking-right {
    flex: none;
    width: 100%;
  }

  .booking-right {
    order: -1; /* price summary first on mobile */
  }

  .price-sticky {
    position: static;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .main { padding: 24px 0 48px; }
  .card { padding: 20px; }
  .page-title { font-size: 1.375rem; }
}
