/*
 * Brandfine widget styles — public-site CSS.
 *
 * Design goals:
 *   1. Theme-agnostic. Every selector is scoped under
 *      `.bf-widget` so we never bleed into the host theme,
 *      and we explicitly reset properties the theme might
 *      have inherited (font-size, line-height, box-sizing,
 *      color, text-align) so the widget looks the same on
 *      Twenty Twenty-Four, Astra, Divi, Elementor, etc.
 *   2. Customisable. Every colour, radius, and font size is
 *      a CSS custom property — customers override by writing:
 *        .bf-widget { --bf-color-primary: #ff6b00; }
 *      No theme override file needed.
 *   3. Light + dark. Defaults to a clean light look; respects
 *      `prefers-color-scheme: dark` for sites that don't pin
 *      a colour scheme. Customers who want strict-light or
 *      strict-dark override the variables themselves.
 */

.bf-widget {
  /* ── Color tokens — override these to brand the widget ── */
  --bf-color-primary: #0B1F2A;
  --bf-color-primary-fg: #ffffff;
  --bf-color-primary-hover: #1a3543;
  --bf-color-accent: #2E5A6B;
  --bf-color-text: #0B1F2A;
  --bf-color-text-muted: #6b7280;
  --bf-color-border: #e5e7eb;
  --bf-color-border-strong: #d1d5db;
  --bf-color-surface: #ffffff;
  --bf-color-surface-soft: #f9fafb;
  --bf-color-surface-hover: #f3f4f6;
  --bf-color-error: #b91c1c;
  --bf-color-error-bg: #fef2f2;
  --bf-color-warning: #92400e;
  --bf-color-warning-bg: #fef3c7;
  --bf-color-success: #047857;
  --bf-color-success-bg: #ecfdf5;

  /* ── Typography ── */
  --bf-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --bf-font-size: 14px;
  --bf-font-size-sm: 12px;
  --bf-font-size-lg: 18px;
  --bf-line-height: 1.5;

  /* ── Layout ── */
  --bf-radius: 12px;
  --bf-radius-sm: 8px;
  --bf-radius-full: 999px;
  --bf-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.08);
  --bf-shadow-elevated: 0 10px 30px -12px rgba(0, 0, 0, 0.18);
  --bf-gap: 12px;
  --bf-gap-lg: 20px;
  --bf-pad: 22px;
  --bf-max-width: 520px;

  /* ── Defensive resets — undo common theme inheritance ── */
  box-sizing: border-box;
  font-family: var(--bf-font-family);
  font-size: var(--bf-font-size);
  line-height: var(--bf-line-height);
  color: var(--bf-color-text);
  text-align: left;

  display: block;
  width: 100%;
  max-width: var(--bf-max-width);
  margin: 24px 0;
}

.bf-widget *,
.bf-widget *::before,
.bf-widget *::after {
  box-sizing: border-box;
}

.bf-widget--center { margin-left: auto; margin-right: auto; }
.bf-widget--left   { margin-left: 0;    margin-right: auto; }
.bf-widget--right  { margin-left: auto; margin-right: 0;    }

/* Shell card — the visible chrome around the widget. */
.bf-widget__shell {
  background: var(--bf-color-surface);
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius);
  box-shadow: var(--bf-shadow);
  overflow: hidden;
}

.bf-widget__header {
  padding: var(--bf-pad) var(--bf-pad) 0;
}

.bf-widget__title {
  font-size: var(--bf-font-size-lg);
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--bf-color-text);
  letter-spacing: -0.01em;
}

.bf-widget__intro {
  font-size: var(--bf-font-size-sm);
  color: var(--bf-color-text-muted);
  margin: 0;
  line-height: 1.55;
}

.bf-widget__body {
  padding: var(--bf-gap-lg) var(--bf-pad) var(--bf-pad);
}

.bf-widget__noscript {
  padding: var(--bf-pad);
  margin: 0;
  font-size: var(--bf-font-size-sm);
  color: var(--bf-color-warning);
  background: var(--bf-color-warning-bg);
  border-radius: var(--bf-radius-sm);
}

/* ── Skeleton loader ───────────────────────────────────── */

.bf-widget__skeleton {
  display: flex;
  flex-direction: column;
  gap: var(--bf-gap);
}

.bf-skeleton {
  background: linear-gradient(
    90deg,
    var(--bf-color-surface-soft) 0%,
    var(--bf-color-surface-hover) 50%,
    var(--bf-color-surface-soft) 100%
  );
  background-size: 200% 100%;
  animation: bf-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--bf-radius-sm);
}

.bf-skeleton--row { height: 28px; width: 60%; }
.bf-skeleton--grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.bf-skeleton--grid > span {
  display: block;
  height: 40px;
  border-radius: var(--bf-radius-sm);
  background: linear-gradient(
    90deg,
    var(--bf-color-surface-soft) 0%,
    var(--bf-color-surface-hover) 50%,
    var(--bf-color-surface-soft) 100%
  );
  background-size: 200% 100%;
  animation: bf-shimmer 1.4s ease-in-out infinite;
}

@keyframes bf-shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ── Month nav ─────────────────────────────────────────── */

.bf-month {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--bf-gap);
  margin-bottom: var(--bf-gap);
}

.bf-month__label {
  font-weight: 600;
  font-size: var(--bf-font-size);
  letter-spacing: -0.01em;
}

.bf-icon-button {
  appearance: none;
  background: transparent;
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-full);
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  color: var(--bf-color-text);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.bf-icon-button:hover {
  background: var(--bf-color-surface-hover);
  border-color: var(--bf-color-border-strong);
}
.bf-icon-button:active { transform: scale(0.94); }
.bf-icon-button svg { width: 14px; height: 14px; }

/* ── Calendar ──────────────────────────────────────────── */

.bf-calendar {
  margin-bottom: var(--bf-gap-lg);
}

.bf-cal__weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--bf-color-text-muted);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--bf-color-border);
  margin-bottom: 6px;
}

.bf-cal__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.bf-cal__cell {
  position: relative;
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--bf-radius-sm);
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  font: inherit;
  color: var(--bf-color-text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.bf-cal__cell:not(.bf-cal__cell--empty):hover {
  background: var(--bf-color-surface-hover);
  border-color: var(--bf-color-border);
}

.bf-cal__day-num { font-size: 13px; font-weight: 500; }

.bf-cal__day-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--bf-color-accent);
  margin-top: 3px;
}

.bf-cal__cell--blank { cursor: default; }

.bf-cal__cell--empty {
  cursor: default;
  color: var(--bf-color-text-muted);
  opacity: 0.4;
}
.bf-cal__cell--empty:hover { background: transparent; border-color: transparent; }
.bf-cal__cell--empty .bf-cal__day-dot { display: none; }

.bf-cal__cell--today { font-weight: 700; }
.bf-cal__cell--today::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px dashed var(--bf-color-border-strong);
  border-radius: var(--bf-radius-sm);
  pointer-events: none;
}

.bf-cal__cell--selected,
.bf-cal__cell--selected:hover {
  background: var(--bf-color-primary);
  color: var(--bf-color-primary-fg);
  border-color: var(--bf-color-primary);
}
.bf-cal__cell--selected .bf-cal__day-dot { background: var(--bf-color-primary-fg); }
.bf-cal__cell--selected::after { display: none; }

/* ── Slots ─────────────────────────────────────────────── */

.bf-slots__head {
  font-size: var(--bf-font-size-sm);
  font-weight: 600;
  color: var(--bf-color-text-muted);
  margin-bottom: 8px;
}

.bf-slots__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
}

.bf-slot {
  appearance: none;
  background: var(--bf-color-surface);
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-sm);
  padding: 9px 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--bf-color-text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  font-variant-numeric: tabular-nums;
}
.bf-slot:hover {
  border-color: var(--bf-color-primary);
  background: var(--bf-color-surface-soft);
}
.bf-slot:active { transform: scale(0.97); }

.bf-empty {
  margin: 0;
  font-size: var(--bf-font-size-sm);
  color: var(--bf-color-text-muted);
  font-style: italic;
  text-align: center;
  padding: 14px;
  background: var(--bf-color-surface-soft);
  border-radius: var(--bf-radius-sm);
}

/* ── Booking form ──────────────────────────────────────── */

.bf-link-button {
  appearance: none;
  background: transparent;
  border: none;
  padding: 0 0 8px;
  color: var(--bf-color-text-muted);
  font: inherit;
  font-size: var(--bf-font-size-sm);
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.bf-link-button:hover { color: var(--bf-color-text); }
.bf-link-button svg { width: 13px; height: 13px; }

.bf-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bf-color-surface-soft);
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-full);
  font-size: var(--bf-font-size-sm);
  font-weight: 600;
  color: var(--bf-color-text);
  margin-bottom: var(--bf-gap-lg);
}
.bf-pill__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bf-color-accent);
}

.bf-form {
  display: flex;
  flex-direction: column;
  gap: var(--bf-gap);
}

.bf-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bf-label {
  font-size: var(--bf-font-size-sm);
  font-weight: 600;
  color: var(--bf-color-text);
}

.bf-required { color: var(--bf-color-error); margin-left: 1px; }
.bf-optional {
  color: var(--bf-color-text-muted);
  font-weight: 400;
  font-size: 11px;
  margin-left: 4px;
}

.bf-input,
.bf-textarea {
  appearance: none;
  background: var(--bf-color-surface);
  border: 1px solid var(--bf-color-border);
  border-radius: var(--bf-radius-sm);
  padding: 9px 12px;
  font: inherit;
  font-size: var(--bf-font-size);
  line-height: 1.5;
  color: var(--bf-color-text);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.bf-input:focus,
.bf-textarea:focus {
  outline: none;
  border-color: var(--bf-color-accent);
  box-shadow: 0 0 0 3px rgba(46, 90, 107, 0.18);
}

.bf-textarea {
  resize: vertical;
  min-height: 72px;
  font-family: var(--bf-font-family);
}

.bf-honeypot {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Select dropdown — match the bf-input look. */
select.bf-input {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--bf-color-text-muted) 50%),
                    linear-gradient(135deg, var(--bf-color-text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

/* Checkbox row — inline checkbox + label, doesn't follow the
   standard label-above-input layout. */
.bf-checkbox {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  font-size: var(--bf-font-size-sm);
  color: var(--bf-color-text);
  line-height: 1.5;
}
.bf-checkbox input[type="checkbox"] {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  accent-color: var(--bf-color-accent);
  cursor: pointer;
  flex-shrink: 0;
}

.bf-submit {
  appearance: none;
  background: var(--bf-color-primary);
  color: var(--bf-color-primary-fg);
  border: none;
  border-radius: var(--bf-radius-sm);
  padding: 11px 18px;
  font: inherit;
  font-size: var(--bf-font-size);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  margin-top: 4px;
}
.bf-submit:hover { background: var(--bf-color-primary-hover); }
.bf-submit:active { transform: scale(0.99); }
.bf-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.bf-fineprint {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--bf-color-text-muted);
  line-height: 1.5;
}

/* ── State cards (success / error) ─────────────────────── */

.bf-state-card {
  text-align: center;
  padding: 18px 4px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.bf-state-card__icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #ffffff;
}

.bf-state-card--success .bf-state-card__icon { background: var(--bf-color-success); }
.bf-state-card--error   .bf-state-card__icon { background: var(--bf-color-error);   }

.bf-state-card__icon svg { width: 22px; height: 22px; }

.bf-state-card__title {
  font-size: var(--bf-font-size-lg);
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.bf-state-card__body {
  margin: 0;
  font-size: var(--bf-font-size-sm);
  color: var(--bf-color-text-muted);
  max-width: 360px;
}

/* ── Banner ────────────────────────────────────────────── */

.bf-banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: var(--bf-gap);
  border-radius: var(--bf-radius-sm);
  font-size: var(--bf-font-size-sm);
  line-height: 1.5;
}
.bf-banner--warning {
  background: var(--bf-color-warning-bg);
  color: var(--bf-color-warning);
  border: 1px solid rgba(146, 64, 14, 0.18);
}
.bf-banner__close {
  appearance: none;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  color: inherit;
  opacity: 0.7;
}
.bf-banner__close:hover { opacity: 1; }

/* ── Responsive ────────────────────────────────────────── */

@media (max-width: 480px) {
  .bf-widget {
    --bf-pad: 16px;
    --bf-gap-lg: 14px;
  }
  .bf-cal__day-num { font-size: 12px; }
  .bf-slots__grid {
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  }
}

/* ── Dark scheme — only when host site doesn't pin one ── */

@media (prefers-color-scheme: dark) {
  .bf-widget:not(.bf-widget--force-light) {
    --bf-color-primary: #f9fafb;
    --bf-color-primary-fg: #0b1f2a;
    --bf-color-primary-hover: #e5e7eb;
    --bf-color-accent: #38bdf8;
    --bf-color-text: #f3f4f6;
    --bf-color-text-muted: #9ca3af;
    --bf-color-border: #2d3748;
    --bf-color-border-strong: #4b5563;
    --bf-color-surface: #111827;
    --bf-color-surface-soft: #1f2937;
    --bf-color-surface-hover: #374151;
    --bf-color-error-bg: rgba(185, 28, 28, 0.18);
    --bf-color-warning-bg: rgba(146, 64, 14, 0.18);
    --bf-color-success-bg: rgba(4, 120, 87, 0.18);
  }
}

/* ─── "Your appointments" (logged-in read-back) ─────────────── */
.bf-mine { margin-bottom: 18px; }
.bf-mine__list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.bf-mine__item {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; border: 1px solid #e5e7eb; border-radius: 8px;
  font-size: 13px; background: #fafafa;
}
.bf-mine__when { font-weight: 600; }
.bf-mine__status {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: #e5e7eb; color: #374151; white-space: nowrap;
}
.bf-mine__item--confirmed .bf-mine__status { background: #dcfce7; color: #166534; }
.bf-mine__item--pending .bf-mine__status   { background: #fef3c7; color: #92400e; }
.bf-mine__item--rejected .bf-mine__status,
.bf-mine__item--cancelled .bf-mine__status { background: #fee2e2; color: #991b1b; }
.bf-mine__cancel { margin-left: auto; font-size: 12px; }
.bf-mine__reason { flex-basis: 100%; font-size: 12px; color: #6b7280; }
