/* Flatpickr overrides for larger calendar */
.flatpickr-calendar {
    width: min(360px, calc(100vw - 2rem)) !important;
    font-size: 1rem !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15) !important;
    border-radius: 12px !important;
}
.flatpickr-months {
    padding: 0.5rem 0 !important;
}
.flatpickr-month {
    height: 40px !important;
}
.flatpickr-current-month {
    font-size: 1.1rem !important;
    font-weight: 600 !important;
}
@media (max-width: 400px) {
    .flatpickr-calendar {
        width: calc(100vw - 2rem) !important; /* keep the form gutter — bare 100vw overflows when offset */
        max-width: 320px !important;
    }
}
.flatpickr-day {
    width: 44px !important;
    height: 44px !important;
    line-height: 44px !important;
    font-size: 0.95rem !important;
    border-radius: 8px !important;
}
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
    background: #2A7A77 !important;
    border-color: #2A7A77 !important;
}
.flatpickr-day.today {
    border-color: #2A7A77 !important;
}
.flatpickr-day.today:hover {
    background: #e6f7f6 !important;
    color: #1a1a1a !important;
}
span.flatpickr-weekday {
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    color: #2A7A77 !important;
}
.flatpickr-innerContainer {
    padding: 0.5rem !important;
}
.flatpickr-prev-month, .flatpickr-next-month {
    padding: 0.5rem !important;
}
.flatpickr-prev-month svg, .flatpickr-next-month svg {
    width: 16px !important;
    height: 16px !important;
}

/* Booking Form Styles */
.booking-section {
    padding-top: calc(var(--header-height, 80px) + 3rem);
    padding-bottom: 4rem;
}

.booking-form {
    max-width: 100%;
    margin: 0 auto;
}

.form-section {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.form-section-title {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--color-primary, #4A90A4);
    color: var(--color-dark, #1a1a1a);
}

/* Service Selection Dropdown */
.service-dropdown {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.service-dropdown:focus {
    outline: none;
    border-color: var(--color-primary, #4A90A4);
}

/* A keyboard user must be able to see where focus is. Same idiom as .time-slot
   below. #4A90A4 on white measures 3.63:1 — above the 3:1 WCAG 2.2 minimum for
   user-interface components. :focus-visible keeps the ring off mouse clicks. */
.service-dropdown:focus-visible {
    outline: 3px solid var(--color-primary, #4A90A4);
    outline-offset: 2px;
}

.service-dropdown optgroup {
    font-weight: 700;
    font-size: 1.05rem;
    color: #2A7A77 !important;
    background: #f3f0ff;
    padding: 0.75rem 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.service-dropdown option {
    padding: 0.75rem 1rem;
    font-weight: 400;
    color: var(--color-dark, #1a1a1a);
    background: white;
}

/* The .custom-select-* rules that lived here styled a <div>-based dropdown that
   replaced the native <select>. That widget was removed because it was unreachable
   by keyboard (see the note in the script block). The rules went with it — nothing
   references them. Do not reinstate without a real listbox implementation. */

/* Service Details Card */
.service-details {
    margin-top: 1.5rem;
}

.service-details-card {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.05) 0%, rgba(20, 184, 166, 0.05) 100%);
    border: 2px solid var(--color-primary, #7C3AED);
    border-radius: 12px;
    padding: 1.5rem;
}

.service-details-card h3 {
    margin: 0 0 0.75rem 0;
    color: #2A7A77 !important;
    font-size: 1.25rem;
}

.service-description {
    color: var(--color-gray-700, #333);
    margin: 0 0 1rem 0;
    line-height: 1.6;
}

.service-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.service-meta-item {
    font-size: 1rem;
    color: var(--color-gray-600, #666);
}

.service-meta-item strong {
    color: var(--color-dark, #1a1a1a);
}

/* Date & Time */
.datetime-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .datetime-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* Shared label styling for non-input controls (Open Hours, Available Times).
   Matches .form-group label so the three fields in Step 2 read as one row. */
.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--color-dark, #1a1a1a);
}

/* Open Hours — read-only display styled to match the date input beside it.
   Value comes from BookingConfig::getBusinessHoursCompact() (Decision 59),
   so it cannot drift from the booking validator. Not a form control: it
   submits nothing and is not announced as editable. */
.open-hours-field {
    padding: 0.75rem 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    background: var(--color-gray-100, #f9f9fb);
    color: var(--color-gray-700, #4a4a4a);
}

/* Available Times — slot chips */
.time-slot-group {
    margin-top: 1.5rem;
}

.time-slot-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.time-slot {
    /* 48px min in both axes — meets the project's mobile tap-target standard */
    min-width: 48px;
    min-height: 48px;
    padding: 0.75rem 1.25rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: var(--color-white, #fff);
    color: var(--color-dark, #1a1a1a);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.time-slot:hover {
    border-color: var(--color-primary, #4A90A4);
    background: #e6f7f6;
}

.time-slot:focus-visible {
    outline: 3px solid var(--color-primary, #4A90A4);
    outline-offset: 2px;
}

.time-slot.is-selected {
    background: var(--color-primary, #4A90A4);
    border-color: var(--color-primary, #4A90A4);
    color: var(--color-white, #fff);
}

.time-slot-message {
    margin: 0;
    padding: 0.75rem 0;
    color: var(--color-gray-700, #4a4a4a);
}

.time-slot-status {
    margin: 0.5rem 0 0 0;
    font-size: 0.875rem;
    color: var(--color-gray-700, #4a4a4a);
}

.time-slot-status:empty {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .time-slot {
        transition: none;
    }
}

/* Form Groups */
.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.form-group--full {
    grid-column: 1 / -1;
}

@media (max-width: 768px) {
    .details-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--color-dark, #1a1a1a);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.75rem 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary, #4A90A4);
}

.form-group small {
    margin-top: 0.25rem;
    color: var(--color-gray-600, #666);
    font-size: 0.875rem;
}

.required {
    color: #e74c3c;
}

/* Booking Summary */
.booking-summary {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.booking-summary h3 {
    margin-bottom: 1rem;
    font-size: 1rem;
}

.summary-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
}

.summary-list dt {
    color: var(--color-gray-600, #666);
}

.summary-list dd {
    font-weight: 500;
    margin: 0;
}

/* Checkbox - Mobile-friendly touch targets */
.checkbox-label {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    cursor: pointer;
    padding: 0.5rem 0;
}

.checkbox-label input {
    margin-top: 0.125rem;
    width: 24px;
    height: 24px;
    min-width: 24px;
    cursor: pointer;
    accent-color: var(--color-primary, #4A90A4);
}

.checkbox-label span {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--color-gray-600, #666);
}

.checkbox-label a {
    color: var(--color-primary, #4A90A4);
}

/* Form Actions */
.form-actions {
    margin-top: 1.5rem;
    text-align: center;
}

/* Messages */
.booking-message {
    max-width: 600px;
    margin: 0 auto 2rem;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
}

.booking-message--success {
    background: #d4edda;
    border: 2px solid #28a745;
}

.booking-message--error {
    background: #f8d7da;
    border: 2px solid #dc3545;
}

.booking-message h3 {
    margin-bottom: 1rem;
}

/* Hours List */
.hours-list {
    list-style: none;
    padding: 0;
}

.hours-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #e0e0e0;
}

.hours-list li:last-child {
    border-bottom: none;
}

/* ========================================
   Mobile Optimizations for Booking Form
   ======================================== */
@media (max-width: 768px) {
    .booking-container {
        padding: 0 1rem;
    }

    .form-section {
        padding: 1.25rem;
        margin-bottom: 1.25rem;
    }

    .form-section-title {
        font-size: 1.125rem;
        margin-bottom: 1rem;
    }

    /* Larger touch targets for form inputs */
    .form-group input,
    .form-group select,
    .form-group textarea,
    .service-dropdown {
        min-height: 48px;
        padding: 0.875rem 1rem;
        font-size: 16px; /* Prevents iOS zoom */
    }

    /* Better checkbox touch area */
    .checkbox-label {
        padding: 0.75rem 0;
        gap: 0.75rem;
    }

    .checkbox-label input {
        width: 28px;
        height: 28px;
        min-width: 28px;
    }

    /* Service details card */
    .service-details-card {
        padding: 1rem;
    }

    .service-meta {
        flex-direction: column;
        gap: 0.5rem;
    }

    /* Submit button - full width on mobile */
    .form-actions .btn {
        width: 100%;
        min-height: 52px;
        font-size: 1.1rem;
    }

    /* Booking summary */
    .booking-summary {
        padding: 1rem;
    }

    /* Messages */
    .booking-message {
        padding: 1.25rem;
        margin-bottom: 1.5rem;
    }
}

@media (max-width: 480px) {
    .booking-container {
        padding: 0 0.75rem;
    }

    .form-section {
        padding: 1rem;
        border-radius: 8px;
    }

    .form-group label {
        font-size: 0.9375rem;
    }

    .checkbox-label span {
        font-size: 0.875rem;
    }

    /* Stack service price/duration */
    .service-meta-item {
        font-size: 0.9rem;
    }
}
