/**
 * LeoHair Booking Wizard — wizard.css
 *
 * Fully self-contained. Uses the .lbw- prefix throughout.
 * No dependency on Astra, Elementor, or WooCommerce CSS.
 * All sizes in rem/em where possible for font-scaling.
 * Mobile-first: base styles target 320px+, overrides at 600px+.
 */

/* ── Custom properties ──────────────────────────────────────────────────── */
:root {
    --lbw-primary:        #25291e;   /* deep forest green */
    --lbw-accent:         #c9a96e;   /* warm gold */
    --lbw-accent-hover:   #b8915a;
    --lbw-bg:             #ffffff;
    --lbw-beige:          #f5f0eb;   /* warm beige accent */
    --lbw-overlay-bg:     rgba(37, 41, 30, 0.72);
    --lbw-border:         #e5ddd4;
    --lbw-text:           #2a2a2a;
    --lbw-label:          #5c5c50;
    --lbw-error-bg:       #fff2f2;
    --lbw-error-border:   #e74c3c;
    --lbw-error-text:     #c0392b;
    --lbw-radius:         12px;
    --lbw-input-radius:   6px;
    --lbw-shadow:         0 8px 48px rgba(37, 41, 30, 0.26);
    --lbw-step-size:      32px;
    --lbw-step-done:      #5a8a5a;
    --lbw-transition:     0.22s ease;
    --lbw-z:              99999;
    --lbw-font-heading:   'Cormorant Garamond', 'Palatino Linotype', Georgia, serif;
    --lbw-font-body:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Isolation reset — prevent Astra/Elementor styles leaking into modal ── */
#leohair-bw-overlay *,
#leohair-bw-overlay *::before,
#leohair-bw-overlay *::after {
    box-sizing: border-box;
}

/* Reset heading tags inside modal that Astra targets globally */
#leohair-bw-overlay h1,
#leohair-bw-overlay h2,
#leohair-bw-overlay h3,
#leohair-bw-overlay h4 {
    font-family: inherit;
    letter-spacing: 0;
    text-transform: none;
    border: none;
    padding: 0;
    background: none;
    /* Do NOT use all:unset here — let .lbw-title rule handle specifics */
}

/* ── Body lock (no scroll when modal is open) ───────────────────────────── */
body.lbw-body-lock {
    overflow: hidden;
}

/* ── Overlay ────────────────────────────────────────────────────────────── */
.lbw-overlay {
    display: none;
    position: fixed;
    inset: 0;                        /* top/right/bottom/left: 0 */
    background: var(--lbw-overlay-bg);
    z-index: var(--lbw-z);
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.lbw-overlay.lbw-overlay--visible {
    display: flex;
}

/* ── Modal container ────────────────────────────────────────────────────── */
.lbw-modal {
    position: relative;
    background: var(--lbw-bg);
    border-radius: var(--lbw-radius);
    box-shadow: var(--lbw-shadow);
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 28px 24px 24px;
    box-sizing: border-box;
    color: var(--lbw-text);
    font-family: var(--lbw-font-body);
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 600px) {
    .lbw-modal {
        padding: 36px 36px 32px;
    }
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.lbw-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}

.lbw-title {
    /* Hard reset — prevent Astra/Elementor theme styles from doubling up */
    all: unset;
    display: block;
    font-size: 1.6rem !important;
    font-weight: 600 !important;
    color: var(--lbw-primary) !important;
    line-height: 1.2 !important;
    letter-spacing: 0.01em !important;
    text-transform: none !important;
    font-family: var(--lbw-font-heading) !important;
    background: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    outline: none;
}

.lbw-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: #888;
    padding: 4px 6px;
    line-height: 1;
    border-radius: 4px;
    flex-shrink: 0;
    transition: color var(--lbw-transition), background var(--lbw-transition);
}

.lbw-close:hover,
.lbw-close:focus-visible {
    color: var(--lbw-primary);
    background: #f0f0f0;
    outline: 2px solid var(--lbw-accent);
    outline-offset: 2px;
}

/* ── Step indicator ──────────────────────────────────────────────────────── */
.lbw-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    gap: 0;
}

.lbw-step {
    width: var(--lbw-step-size);
    height: var(--lbw-step-size);
    border-radius: 50%;
    background: #e8e8e8;
    color: #888;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--lbw-transition), color var(--lbw-transition);
}

.lbw-step--active {
    background: var(--lbw-accent);
    color: #fff;
}

.lbw-step--done {
    background: var(--lbw-step-done);
    color: #fff;
}

.lbw-step-line {
    flex: 1;
    height: 2px;
    background: #e8e8e8;
    max-width: 60px;
}

/* ── Error notice ─────────────────────────────────────────────────────────── */
.lbw-error {
    background: var(--lbw-error-bg);
    border: 1px solid var(--lbw-error-border);
    color: var(--lbw-error-text);
    border-radius: var(--lbw-input-radius);
    padding: 10px 14px;
    font-size: 0.9rem;
    margin-bottom: 16px;
    line-height: 1.45;
}

/* ── Step label ──────────────────────────────────────────────────────────── */
.lbw-step-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--lbw-label);
    margin: 0 0 20px;
}

/* ── Form fields ─────────────────────────────────────────────────────────── */
.lbw-field {
    margin-bottom: 18px;
}

.lbw-field label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--lbw-label);
    margin-bottom: 6px;
}

.lbw-field label span[aria-hidden] {
    color: var(--lbw-error-text);
    margin-left: 2px;
}

.lbw-field input[type="text"],
.lbw-field input[type="tel"],
.lbw-field input[type="date"],
.lbw-field select,
.lbw-field textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid var(--lbw-border);
    border-radius: var(--lbw-input-radius);
    font-size: 1rem;
    font-family: inherit;
    color: var(--lbw-text);
    background: #fafafa;
    transition: border-color var(--lbw-transition), box-shadow var(--lbw-transition);
    appearance: auto; /* keep native date/select chrome for accessibility */
}

.lbw-field input[type="text"]:focus,
.lbw-field input[type="tel"]:focus,
.lbw-field input[type="date"]:focus,
.lbw-field select:focus,
.lbw-field textarea:focus {
    outline: none;
    border-color: var(--lbw-accent);
    box-shadow: 0 0 0 3px rgba(184, 148, 90, 0.18);
    background: #fff;
}

#lbw-service {
    border-color: rgba(37, 41, 30, 0.2);
}

#lbw-service:focus {
    border-color: #C9A84C;
    box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.2);
}

.lbw-field textarea {
    resize: vertical;
    min-height: 80px;
}

/* ── Phone row: country code dropdown + number input side by side ─────────── */
.lbw-phone-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.lbw-phone-row select {
    flex: 0 0 auto;
    width: auto;
    min-width: 100px;
    max-width: 130px;
    padding-right: 8px;
    font-size: 0.95rem;
}

.lbw-phone-row input[type="tel"] {
    flex: 1 1 0;
    min-width: 0; /* prevent overflow in flex */
}

/* ── Action buttons row ──────────────────────────────────────────────────── */
.lbw-actions {
    margin-top: 24px;
    display: flex;
    justify-content: flex-end;
}

.lbw-actions--split {
    justify-content: space-between;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.lbw-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 11px 22px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    line-height: 1;
    transition: background var(--lbw-transition), color var(--lbw-transition), opacity var(--lbw-transition);
    white-space: nowrap;
}

.lbw-btn:focus-visible {
    outline: 2px solid var(--lbw-accent);
    outline-offset: 3px;
}

/* Primary / Next / Submit */
.lbw-btn--next,
.lbw-btn--submit {
    background: var(--lbw-accent);
    color: #fff;
}

.lbw-btn--next:hover,
.lbw-btn--submit:hover {
    background: var(--lbw-accent-hover);
}

.lbw-btn--next:disabled,
.lbw-btn--submit:disabled {
    opacity: 0.55;
    cursor: default;
}

/* Back / Secondary */
.lbw-btn--back {
    background: #f0f0f0;
    color: var(--lbw-label);
}

.lbw-btn--back:hover {
    background: #e4e4e4;
}

/* Submit button — wider on small screens */
.lbw-btn--submit {
    padding: 12px 26px;
    font-size: 1rem;
}

/* ── Slot status message (no slots available / loading) ─────────────────── */
.lbw-slots-status {
    font-size: 0.875rem;
    color: var(--lbw-label);
    margin-top: 6px;
    font-style: italic;
}

/* ── Spinner ──────────────────────────────────────────────────────────────── */
.lbw-spinner {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--lbw-radius);
    z-index: 10;
}

.lbw-spinner__ring {
    width: 44px;
    height: 44px;
    border: 4px solid #e0e0e0;
    border-top-color: var(--lbw-accent);
    border-radius: 50%;
    animation: lbw-spin 0.75s linear infinite;
}

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

/* ── Mobile tweaks ───────────────────────────────────────────────────────── */
@media (max-width: 420px) {
    .lbw-modal {
        padding: 20px 16px 18px;
    }

    .lbw-title {
        font-size: 1.15rem;
    }

    .lbw-btn--submit {
        font-size: 0.9rem;
        padding: 11px 16px;
    }
}

/* ── Flatpickr date input ────────────────────────────────────────────────── */
/*
 * The .lbw-date-input is the underlying <input type="text"> that Flatpickr
 * attaches to. It inherits all .lbw-field input styles; these rules only
 * override Flatpickr-specific behaviour.
 */
.lbw-date-input {
    cursor: pointer;
}

.lbw-date-input:read-only {
    background: #fafafa;
}

/* ── Flatpickr calendar popup — brand overrides ──────────────────────────── */
/*
 * Scope all overrides inside #leohair-bw-overlay so they only affect the
 * wizard calendar and never bleed into other Flatpickr instances on the page.
 * Flatpickr appends .flatpickr-calendar to <body> — use the data attribute
 * added by Flatpickr's "appendTo" equivalent (below we use the global selector
 * but prefix with .flatpickr-calendar for safety; Flatpickr's own specificity
 * is low so these will win without !important on most properties).
 */

/* Container */
.flatpickr-calendar {
    font-family: inherit;
    border-radius: var(--lbw-radius, 12px);
    box-shadow: var(--lbw-shadow, 0 8px 40px rgba(0,0,0,0.22));
    border: 1px solid var(--lbw-border, #e0e0e0);
    padding: 12px;
}

/* Month navigation header */
.flatpickr-months {
    padding: 0 4px 8px;
}

.flatpickr-prev-month svg,
.flatpickr-next-month svg {
    fill: var(--lbw-accent, #b8945a);
}

.flatpickr-prev-month:hover svg,
.flatpickr-next-month:hover svg {
    fill: var(--lbw-accent-hover, #9e7a3f);
}

.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year {
    font-weight: 600;
    color: var(--lbw-primary, #1a1a1a);
}

/* Weekday row */
.flatpickr-weekday {
    color: var(--lbw-label, #555);
    font-size: 0.78rem;
    font-weight: 600;
}

/* Day cells */
.flatpickr-day {
    border-radius: 6px;
    color: var(--lbw-text, #333);
    font-size: 0.875rem;
}

.flatpickr-day:hover,
.flatpickr-day:focus {
    background: rgba(184, 148, 90, 0.12);
    border-color: transparent;
    color: var(--lbw-primary, #1a1a1a);
}

/* Today */
.flatpickr-day.today {
    border-color: var(--lbw-accent, #b8945a);
}

.flatpickr-day.today:hover {
    background: var(--lbw-accent, #c9a96e);
    border-color: var(--lbw-accent, #c9a96e);
    color: #fff;
}

/* Selected day */
.flatpickr-day.selected,
.flatpickr-day.selected:hover,
.flatpickr-day.selected:focus,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
    background: var(--lbw-accent, #b8945a);
    border-color: var(--lbw-accent, #b8945a);
    color: #fff;
}

/* Disabled days */
.flatpickr-day.flatpickr-disabled,
.flatpickr-day.flatpickr-disabled:hover {
    color: #ccc;
    background: transparent;
    border-color: transparent;
    cursor: not-allowed;
    text-decoration: line-through;
    text-decoration-color: #ddd;
}

/* Days outside current month */
.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
    color: #bbb;
}

/* ── Flatpickr mobile-responsive ─────────────────────────────────────────── */
@media (max-width: 420px) {
    .flatpickr-calendar {
        font-size: 0.85rem;
    }

    .flatpickr-day {
        font-size: 0.8rem;
        height: 34px;
        line-height: 34px;
        max-width: 34px;
    }
}

/* ── Hold countdown bar ───────────────────────────────────────────────────── */
.lbw-hold-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 14px;
    padding: 8px 14px;
    border-radius: var(--lbw-input-radius);
    background: #fdf6e9;
    border: 1px solid #e8c97a;
    color: #7a5800;
    font-size: 0.82rem;
    font-family: var(--lbw-font-body);
    line-height: 1.4;
}

.lbw-hold-bar__icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.lbw-hold-bar__time {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
    font-size: 0.92rem;
    color: #5c3d00;
}

/* Pulse when under 3 minutes */
.lbw-hold-bar--urgent {
    background: #fff3f0;
    border-color: #e87a5a;
    color: #8b2a00;
}

.lbw-hold-bar--urgent .lbw-hold-bar__time {
    color: #c0390a;
    animation: lbw-pulse 1s ease-in-out infinite;
}

@keyframes lbw-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.55; }
}
