/*
 * Partner booking widget — theme-aware.
 *
 * Theme is chosen in plugin settings and applied as a class on the widget:
 *   .pbp-theme-light  → force light tokens
 *   .pbp-theme-dark   → force dark tokens
 *   .pbp-theme-auto   → follow the visitor's OS preference (prefers-color-scheme)
 *
 * All colours are driven by CSS variables so the same markup looks right on
 * a white partner site or a black one. The widget sets its own background so
 * it never inherits an unreadable colour from the host theme.
 */

.pbp-widget {
  /* Light tokens (default) */
  --pbp-bg: #ffffff;
  --pbp-surface: #f5f6fa;
  --pbp-text: #1a1a2e;
  --pbp-text-dim: #5a5f73;
  --pbp-border: #d9dce6;
  --pbp-primary: #6c5ce7;
  --pbp-primary-contrast: #ffffff;
  --pbp-danger: #e74c3c;
  --pbp-success: #22c55e;
  --pbp-radius: 12px;

  /* Consistent, roomy width on desktop/tablet; only shrinks on phones
     narrower than this. min-height keeps the box from jumping between steps. */
  position: relative;
  width: 100%;
  max-width: 760px;
  min-height: 600px;
  margin: 0 auto;
  padding: 40px 44px;
  background: var(--pbp-bg);
  color: var(--pbp-text);
  border: 1px solid var(--pbp-border);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.28);
  box-sizing: border-box;
  font-size: 16px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
}
.pbp-widget * { box-sizing: border-box; }
.pbp-widget .pbp-form { flex: 1; }


/* Dark tokens — applied when forced dark, or auto + OS prefers dark. */
.pbp-theme-dark {
  --pbp-bg: #16161f;
  --pbp-surface: #1f1f2b;
  --pbp-text: #f0f0f5;
  --pbp-text-dim: #a0a3b5;
  --pbp-border: #33333f;
  --pbp-primary: #8b7cf0;
  --pbp-primary-contrast: #ffffff;
}
@media (prefers-color-scheme: dark) {
  .pbp-theme-auto {
    --pbp-bg: #16161f;
    --pbp-surface: #1f1f2b;
    --pbp-text: #f0f0f5;
    --pbp-text-dim: #a0a3b5;
    --pbp-border: #33333f;
    --pbp-primary: #8b7cf0;
    --pbp-primary-contrast: #ffffff;
  }
}

.pbp-intro { margin-bottom: 18px; color: var(--pbp-text-dim); }

.pbp-notice {
  padding: 14px 16px;
  border-radius: 10px;
  background: #fff3cd;
  color: #664d03;
  border: 1px solid #ffe69c;
}

/* Progress */
.pbp-progress { display: flex; gap: 8px; margin-bottom: 22px; }
.pbp-progress-step {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: var(--pbp-text-dim); font-size: 12px; text-align: center;
}
.pbp-progress-step span {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--pbp-surface); border: 1px solid var(--pbp-border);
  font-weight: 700;
}
.pbp-progress-step.is-active span,
.pbp-progress-step.is-done span { background: var(--pbp-primary); color: var(--pbp-primary-contrast); border-color: var(--pbp-primary); }
.pbp-progress-step.is-active em { color: var(--pbp-primary); font-style: normal; font-weight: 600; }
.pbp-progress-step em { font-style: normal; }

/* Steps */
.pbp-step { display: none; }
.pbp-step.is-active { display: block; }
.pbp-step h3 { margin: 0 0 16px; font-size: 20px; color: var(--pbp-text) !important; }

/* Fields */
.pbp-field { margin-bottom: 16px; }
.pbp-field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.pbp-field-row .pbp-field { flex: 1; min-width: 140px; }
.pbp-field label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; color: var(--pbp-text); }
.pbp-req { color: var(--pbp-danger); }
/* Inputs — high specificity + !important to win against opinionated host
   themes (e.g. dark DJ sites that force white input backgrounds). */
.pbp-widget input.pbp-input,
.pbp-widget textarea.pbp-input {
  width: 100%; padding: 13px 15px; font-size: 16px;
  border: 2px solid var(--pbp-border) !important; border-radius: 10px;
  background-color: var(--pbp-surface) !important;
  color: var(--pbp-text) !important;
  -webkit-text-fill-color: var(--pbp-text) !important;
  box-shadow: none !important;
}
.pbp-widget textarea.pbp-input { resize: vertical; }
.pbp-widget .pbp-input::placeholder { color: var(--pbp-text-dim) !important; -webkit-text-fill-color: var(--pbp-text-dim) !important; opacity: 1; }
.pbp-widget .pbp-input:focus { outline: none; border-color: var(--pbp-primary) !important; }
/* Kill the browser autofill white-on-white on dark themes. */
.pbp-widget .pbp-input:-webkit-autofill,
.pbp-widget .pbp-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--pbp-text) !important;
  -webkit-box-shadow: 0 0 0 1000px var(--pbp-surface) inset !important;
  caret-color: var(--pbp-text);
}
.pbp-hint { margin: 6px 0 0; font-size: 13px; color: var(--pbp-text-dim); }

/* Quantity stepper */
.pbp-qty { display: flex; align-items: stretch; max-width: 220px; }
.pbp-qty-btn {
  width: 48px; border: 0; cursor: pointer; font-size: 22px; font-weight: 700;
  background: var(--pbp-primary); color: var(--pbp-primary-contrast);
}
.pbp-qty-btn:first-child { border-radius: 10px 0 0 10px; }
.pbp-qty-btn:last-child { border-radius: 0 10px 10px 0; }
.pbp-qty .pbp-input { text-align: center; border-radius: 0; border-left: 0; border-right: 0; }

/* Channel cards — segmented, clearly-selectable tiles instead of raw radios. */
.pbp-channels { display: flex; gap: 10px; }
.pbp-channel { flex: 1; cursor: pointer; }
.pbp-channel input { position: absolute; opacity: 0; pointer-events: none; }
.pbp-channel-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 14px 8px; border: 2px solid var(--pbp-border);
  border-radius: 12px; background: var(--pbp-surface); transition: all 0.15s;
}
.pbp-channel-num { font-size: 22px; font-weight: 800; color: var(--pbp-text); line-height: 1; }
.pbp-channel-label { font-size: 12px; color: var(--pbp-text-dim); }
.pbp-channel input:checked + .pbp-channel-card {
  border-color: var(--pbp-primary);
  background: color-mix(in srgb, var(--pbp-primary) 14%, var(--pbp-surface));
}
.pbp-channel input:checked + .pbp-channel-card .pbp-channel-num { color: var(--pbp-primary); }
.pbp-channel input:focus-visible + .pbp-channel-card { outline: 2px solid var(--pbp-primary); outline-offset: 2px; }

/* Address autocomplete suggestions */
.pbp-address-field { position: relative; }
.pbp-suggestions {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 20;
  background: var(--pbp-bg); border: 1px solid var(--pbp-border);
  border-radius: 10px; margin-top: 4px; overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.pbp-suggestion { padding: 10px 12px; cursor: pointer; font-size: 14px; color: var(--pbp-text); }
.pbp-suggestion:hover { background: var(--pbp-surface); }

/* Calendar availability dots (green/yellow/red under each day).
   flatpickr appends its calendar to <body>, so these are document-scoped
   (not under .pbp-widget) and anchor the dot on the day cell. */
.flatpickr-day { position: relative; }
.pbp-date-dot {
  position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%);
  width: 6px; height: 6px; border-radius: 50%; pointer-events: none;
}

/* Honeypot — visually and from-AT hidden, but present in the DOM. */
.pbp-hp {
  position: absolute !important; left: -9999px !important;
  width: 1px; height: 1px; overflow: hidden;
}

/* Availability */
.pbp-availability { margin: 10px 0 0; font-size: 14px; color: var(--pbp-text-dim); }
.pbp-availability.is-ok { color: var(--pbp-success); }
.pbp-availability.is-bad { color: var(--pbp-danger); }

/* Actions */
.pbp-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 22px; }
.pbp-actions .pbp-next, .pbp-actions .pbp-submit { margin-left: auto; }
.pbp-btn {
  padding: 12px 22px; font-size: 16px; font-weight: 600; cursor: pointer;
  border-radius: 10px; border: 2px solid transparent;
}
.pbp-btn-primary { background: var(--pbp-primary); color: var(--pbp-primary-contrast); }
.pbp-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.pbp-btn-secondary { background: transparent; color: var(--pbp-text); border-color: var(--pbp-border); }

/* Message + success */
.pbp-message { margin: 12px 0 0; font-size: 14px; color: var(--pbp-danger); }
.pbp-success { text-align: center; padding: 30px 10px; }
/* Force heading/paragraph colours so opinionated host themes can't render
   them dark-on-dark (e.g. a theme's default dark h3 colour). */
.pbp-widget .pbp-success h3,
.pbp-widget .pbp-success p { color: var(--pbp-text) !important; }
.pbp-success-icon {
  width: 60px; height: 60px; margin: 0 auto 14px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--pbp-success); color: #fff !important; font-size: 30px;
}
.pbp-booking-ref { color: var(--pbp-text-dim); }

/* Co-brand credit line with logo at the bottom of the widget. */
.pbp-cobrand {
  margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--pbp-border);
  display: flex; justify-content: center;
}
.pbp-cobrand-link { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.pbp-cobrand-logo {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 5px 10px; border-radius: 8px; background: #16161f; flex-shrink: 0;
}
.pbp-cobrand-logo img { height: 18px; width: auto; display: block; }
.pbp-cobrand-text { font-size: 13px; color: var(--pbp-text-dim); }
.pbp-cobrand-text strong { color: var(--pbp-primary); font-weight: 700; }
.pbp-cobrand-link:hover .pbp-cobrand-text strong { text-decoration: underline; }

/* Phones: fill available space, drop the height lock so short steps don't
   leave a big empty box, tighten padding. */
@media (max-width: 600px) {
  .pbp-widget { max-width: 100%; min-height: 0; padding: 22px 18px; }
  .pbp-field-row { flex-direction: column; gap: 0; }
  .pbp-step h3 { font-size: 18px; }
}
