/* ================================================================
   Book Viewing – Frontend Styles
   Matches Expanders NZ aesthetic: warm stone palette, yellow accent
   ================================================================ */

/* ─── Reset within widget scope ─── */
.bv-widget *,
.bv-widget *::before,
.bv-widget *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ─── CSS custom property defaults (overridden by inline <style>) ─── */
.bv-widget {
    --bv-primary: #fed14d;
    --bv-primary-dark: #ddb01e;
    --bv-primary-50: rgba(254, 209, 77, 0.15);
    --bv-text: #1c1917;
    --bv-text-secondary: #57534e;
    --bv-text-muted: #a8a29e;
    --bv-bg: #ffffff;
    --bv-bg-secondary: #fafaf9;
    --bv-border: #e7e5e4;
    --bv-border-strong: #292524;
    --bv-radius: 1rem;
    --bv-radius-sm: 0.5rem;
    --bv-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ─── Widget wrapper ─── */
.bv-widget {
    font-family: var(--bv-font);
    color: var(--bv-text);
    background: var(--bv-bg);
    padding: 4rem 1rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.bv-container {
    max-width: 72rem;
    margin: 0 auto;
}

/* ─── Header ─── */
.bv-header {
    max-width: 36rem;
}

.bv-eyebrow {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--bv-text-muted);
    margin-bottom: 0.75rem;
}

.bv-title {
    font-size: clamp(1.875rem, 4vw, 2.5rem);
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--bv-text);
    line-height: 1.15;
}

.bv-desc {
    margin-top: 1rem;
    font-size: 1rem;
    color: var(--bv-text-secondary);
}

/* ─── Location cards ─── */
.bv-locations {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 2.5rem;
}

@media (min-width: 768px) {
    .bv-locations {
        grid-template-columns: 1fr 1fr;
    }
}

.bv-loc-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 1.5rem;
    border-radius: var(--bv-radius);
    border: 2px solid var(--bv-border);
    background: var(--bv-bg);
    color: var(--bv-text);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    font-family: inherit;
    line-height: inherit;
}

.bv-loc-card:hover {
    border-color: #a8a29e;
    background: var(--bv-bg-secondary);
}

.bv-loc-card:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bv-bg), 0 0 0 4px var(--bv-primary);
}

.bv-loc-card--active {
    border-color: var(--bv-border-strong);
    background: var(--bv-border-strong);
    color: #fafaf9;
}

.bv-loc-card--active:hover {
    background: #1c1917;
    border-color: #1c1917;
}

.bv-loc-badge-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.bv-loc-dot {
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 50%;
    background: #d6d3d1;
    flex-shrink: 0;
    transition: background 0.15s;
}

.bv-loc-dot--active {
    background: var(--bv-primary);
    animation: bv-pulse 2s infinite;
}

@keyframes bv-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.bv-loc-badge {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--bv-text-muted);
}

.bv-loc-card--active .bv-loc-badge {
    color: var(--bv-primary);
}

.bv-loc-name {
    margin-top: 1rem;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.bv-loc-address {
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--bv-text-secondary);
}

.bv-loc-card--active .bv-loc-address {
    color: #d6d3d1;
}

.bv-loc-desc {
    margin-top: 1rem;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--bv-text-secondary);
}

.bv-loc-card--active .bv-loc-desc {
    color: #d6d3d1;
}

.bv-loc-duration {
    margin-top: 1.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--bv-text-muted);
}

.bv-loc-card--active .bv-loc-duration {
    color: #a8a29e;
}

/* ─── Booking widget (calendar + time + form) ─── */
.bv-booking {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    margin-top: 2.5rem;
    border: 1px solid var(--bv-border);
    border-radius: var(--bv-radius);
    background: var(--bv-bg);
    overflow: hidden;
    min-height: 700px;
}

@media (min-width: 768px) {
    .bv-booking {
        grid-template-columns: 1fr 1fr;
    }
}

/* ─── Calendar panel ─── */
.bv-calendar-panel {
    padding: 1.5rem;
    border-bottom: 1px solid var(--bv-border);
}

@media (min-width: 768px) {
    .bv-calendar-panel {
        border-bottom: none;
        border-right: 1px solid var(--bv-border);
    }
}

.bv-cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.bv-cal-month {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--bv-text);
    user-select: none;
}

.bv-cal-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    border: 1px solid var(--bv-border);
    background: var(--bv-bg);
    color: var(--bv-text);
    font-size: 1.25rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    font-family: inherit;
    line-height: 1;
}

.bv-cal-nav:hover {
    background: var(--bv-bg-secondary);
    border-color: #a8a29e;
}

.bv-cal-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.bv-cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
    margin-bottom: 0.5rem;
}

.bv-cal-weekday {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--bv-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.5rem 0;
}

.bv-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
}

.bv-cal-day {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--bv-text);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    font-family: inherit;
    min-height: 2.5rem;
}

.bv-cal-day:hover:not(.bv-cal-day--disabled):not(.bv-cal-day--empty) {
    background: var(--bv-primary-50);
}

.bv-cal-day--empty {
    cursor: default;
    visibility: hidden;
}

.bv-cal-day--today {
    font-weight: 700;
    color: var(--bv-primary-dark);
}

.bv-cal-day--selected {
    background: var(--bv-primary) !important;
    color: #1c1917 !important;
    font-weight: 700;
}

.bv-cal-day--disabled {
    color: var(--bv-text-muted);
    opacity: 0.4;
    cursor: not-allowed;
    text-decoration: line-through;
}

.bv-cal-day--blocked {
    color: var(--bv-text-muted);
    opacity: 0.3;
    cursor: not-allowed;
}

/* ─── Time panel ─── */
.bv-time-panel {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.bv-time-heading {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--bv-text-secondary);
    margin-bottom: 1rem;
}

.bv-time-slots {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    flex: 1;
    align-content: start;
}

@media (min-width: 768px) {
    .bv-time-slots {
        grid-template-columns: repeat(2, 1fr);
    }
}

.bv-time-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 0.5rem;
    border: 1px solid var(--bv-border);
    border-radius: var(--bv-radius-sm);
    background: var(--bv-bg);
    color: var(--bv-text);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s, color 0.12s;
    font-family: inherit;
}

.bv-time-slot:hover {
    border-color: var(--bv-primary);
    background: var(--bv-primary-50);
}

.bv-time-slot--selected {
    border-color: var(--bv-primary);
    background: var(--bv-primary);
    color: #1c1917;
    font-weight: 600;
}

.bv-time-slot--selected:hover {
    background: var(--bv-primary-dark);
    border-color: var(--bv-primary-dark);
}

.bv-time-empty {
    grid-column: 1 / -1;
    font-size: 0.875rem;
    color: var(--bv-text-muted);
    padding: 2rem 0;
    text-align: center;
}

/* ─── Form panel (replaces time panel on mobile after date+time selected) ─── */
.bv-form-panel {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

@media (min-width: 768px) {
    .bv-form-panel {
        border-top: 1px solid var(--bv-border);
        grid-column: 1 / -1;
    }
}

.bv-form-back {
    align-self: flex-start;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 1px solid var(--bv-border);
    background: var(--bv-bg);
    color: var(--bv-text);
    font-size: 1rem;
    cursor: pointer;
    margin-bottom: 1rem;
    font-family: inherit;
    transition: background 0.12s;
}

.bv-form-back:hover {
    background: var(--bv-bg-secondary);
}

.bv-form-heading {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--bv-text);
    margin-bottom: 1.25rem;
}

.bv-field {
    margin-bottom: 1rem;
}

.bv-field label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--bv-text-secondary);
    margin-bottom: 0.375rem;
}

.bv-req {
    color: #dc2626;
}

.bv-field input,
.bv-field textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--bv-border);
    border-radius: var(--bv-radius-sm);
    background: var(--bv-bg);
    color: var(--bv-text);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: border-color 0.12s, box-shadow 0.12s;
    line-height: 1.4;
}

.bv-field select {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--bv-border);
    border-radius: var(--bv-radius-sm);
    background: var(--bv-bg);
    color: var(--bv-text);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: border-color 0.12s, box-shadow 0.12s;
    line-height: 1.4;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2357534e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6l6 -6'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

.bv-field input:focus,
.bv-field textarea:focus,
.bv-field select:focus {
    outline: none;
    border-color: var(--bv-primary);
    box-shadow: 0 0 0 3px var(--bv-primary-50);
}

.bv-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.bv-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9375rem;
    color: var(--bv-text);
    line-height: 1.4;
    padding: 0.375rem 0;
}

.bv-checkbox-label input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    margin-top: 0.125rem;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--bv-primary-dark);
}

.bv-checkbox-label span {
    user-select: none;
}

.bv-field-hint {
    font-size: 0.75rem;
    color: var(--bv-text-muted);
    margin-top: 0.375rem;
    line-height: 1.5;
}

.bv-terms-text {
    font-size: 0.8125rem;
    color: var(--bv-text-secondary);
    margin: 1rem 0;
    line-height: 1.5;
}

.bv-terms-text a {
    color: var(--bv-text);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.bv-terms-text a:hover {
    color: var(--bv-primary-dark);
}

.bv-field input.bv-field-invalid,
.bv-field textarea.bv-field-invalid {
    border-color: #dc2626;
}

.bv-field-error {
    font-size: 0.75rem;
    color: #dc2626;
    margin-top: 0.25rem;
    min-height: 1em;
}

/* ─── Submit button ─── */
.bv-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--bv-radius-sm);
    background: var(--bv-primary);
    color: #1c1917;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s, transform 0.1s;
    font-family: inherit;
    margin-top: 0.5rem;
}

.bv-submit:hover {
    background: var(--bv-primary-dark);
}

.bv-submit:active {
    transform: scale(0.98);
}

.bv-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ─── Spinner ─── */
.bv-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(28, 25, 23, 0.3);
    border-top-color: #1c1917;
    border-radius: 50%;
    animation: bv-spin 0.6s linear infinite;
}

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

/* ─── Success panel ─── */
.bv-success {
    margin-top: 2.5rem;
    border: 1px solid var(--bv-border);
    border-radius: var(--bv-radius);
    padding: 3rem 2rem;
    text-align: center;
    background: var(--bv-bg);
}

.bv-success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background: #22c55e;
    color: #fff;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.bv-success h3 {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--bv-text);
    margin-bottom: 0.5rem;
}

.bv-success p {
    font-size: 0.9375rem;
    color: var(--bv-text-secondary);
    margin-bottom: 1.5rem;
    max-width: 28rem;
    margin-left: auto;
    margin-right: auto;
}

.bv-success .bv-submit {
    width: auto;
    padding: 0.75rem 2rem;
}

/* ─── Contact fallback ─── */
.bv-contact-fallback {
    margin-top: 2rem;
    text-align: center;
}

.bv-contact-fallback p {
    font-size: 0.875rem;
    color: var(--bv-text-secondary);
    line-height: 1.7;
}

.bv-contact-fallback a {
    font-weight: 500;
    color: var(--bv-text);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.12s;
}

.bv-contact-fallback a:hover {
    color: var(--bv-primary-dark);
}

/* ─── Responsive: form below calendar on desktop ─── */
@media (min-width: 768px) {
    .bv-booking {
        grid-template-columns: 1fr 1fr;
    }

    .bv-booking.bv-booking--show-form {
        grid-template-columns: 1fr 1fr;
    }

    .bv-booking.bv-booking--show-form .bv-form-panel {
        grid-column: 1 / -1;
    }
}

/* ─── Mobile: stack calendar, time, form vertically ─── */
@media (max-width: 767px) {
    .bv-booking {
        grid-template-columns: 1fr;
    }

    .bv-time-panel {
        border-top: 1px solid var(--bv-border);
    }

    .bv-form-panel {
        border-top: 1px solid var(--bv-border);
    }

    .bv-time-slots {
        grid-template-columns: repeat(3, 1fr);
    }
}
