/**
 * JWARDMUSCLE - Booking System Styles
 * Calendar & Scheduling Interface
 * Version: 1.0.0
 * Date: January 11, 2026
 */

/* ============================================
   BOOKING SECTION
   ============================================ */

.booking-section {
    padding: 100px 0;
    background: linear-gradient(135deg, rgba(30, 64, 175, 0.05) 0%, rgba(45, 91, 255, 0.05) 100%);
    position: relative;
}

.booking-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.booking-header {
    text-align: center;
    margin-bottom: 60px;
}

.booking-header h2 {
    font-size: 3rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 20px;
}

.booking-header p {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.8);
    max-width: 600px;
    margin: 0 auto;
}

/* ============================================
   CALENDAR COMPONENT
   ============================================ */

.booking-calendar {
    background: rgba(30, 64, 175, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 40px;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(59, 130, 246, 0.2);
}

.calendar-month-year {
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
}

.calendar-nav {
    display: flex;
    gap: 15px;
}

.calendar-nav-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(59, 130, 246, 0.3);
    background: rgba(30, 64, 175, 0.2);
    color: #3b82f6;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calendar-nav-btn:hover {
    background: rgba(59, 130, 246, 0.3);
    border-color: #3b82f6;
    transform: scale(1.1);
}

#calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
}

.calendar-day-header {
    text-align: center;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    padding: 10px;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.calendar-day.empty {
    cursor: default;
    pointer-events: none;
}

.calendar-day.past {
    color: rgba(255, 255, 255, 0.3);
    cursor: not-allowed;
}

.calendar-day.unavailable {
    color: rgba(255, 255, 255, 0.4);
    background: rgba(239, 68, 68, 0.1);
    cursor: not-allowed;
}

.calendar-day.available {
    color: rgba(255, 255, 255, 0.8);
    background: rgba(30, 64, 175, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.calendar-day.available:hover {
    background: rgba(59, 130, 246, 0.3);
    border-color: #3b82f6;
    color: #fff;
    transform: scale(1.05);
}

.calendar-day.today {
    border: 2px solid #22c55e;
    font-weight: 700;
}

.calendar-day.selected {
    background: linear-gradient(135deg, #3b82f6 0%, #2d5bff 100%);
    border-color: #3b82f6;
    color: #fff;
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(45, 91, 255, 0.4);
}

/* ============================================
   MODAL SYSTEM FOR BOOKING FLOW
   ============================================ */

/* Modal Backdrop */
/* Modal Backdrop */
.booking-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    pointer-events: none; /* Don't block clicks when hidden */
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.booking-modal-backdrop.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto; /* Allow clicks when active */
}

/* Mobile backdrop fallback - remove blur for better performance */
@media (max-width: 768px) {
    .booking-modal-backdrop {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: rgba(15, 23, 42, 0.92); /* Darker without blur */
    }
}

/* Time Slots Modal */
.time-slots-container {
    position: fixed;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    background: linear-gradient(135deg,
        rgba(51, 65, 85, 0.95) 0%,
        rgba(71, 85, 105, 0.95) 50%,
        rgba(30, 58, 138, 0.95) 100%
    );
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 2px solid rgba(148, 163, 184, 0.3);
    border-radius: 24px;
    padding: 40px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none; /* Don't block clicks when hidden */
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.time-slots-container.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto; /* Allow clicks when active */
}

/* Mobile modal optimizations - CRITICAL FIX */
@media (max-width: 768px) {
    .booking-modal-backdrop {
        /* Higher z-index than preloader (99999) */
        z-index: 999998;
        /* Prevent body scroll when modal open - CRITICAL */
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        overflow: hidden;
        /* Smooth fade transition */
        transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                    visibility 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .time-slots-container {
        /* CRITICAL: Fixed positioning to viewport */
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: linear-gradient(135deg,
            rgba(51, 65, 85, 0.98) 0%,
            rgba(71, 85, 105, 0.98) 50%,
            rgba(30, 58, 138, 0.98) 100%
        );
        padding: 25px;
        width: 95%;
        max-height: 85vh;
        border-radius: 16px;
        /* CRITICAL: Higher than preloader AND backdrop */
        z-index: 999999;
        /* Initial hidden state */
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        /* Hardware acceleration for smooth rendering */
        will-change: transform, opacity;
        transform: translate(-50%, -50%) !important;
        /* Smooth spring animation */
        transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                    visibility 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                    transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
        /* Prevent scroll issues */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        /* Touch optimization */
        touch-action: pan-y;
    }

    .time-slots-container.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Booking Form Modal */
#booking-form-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: linear-gradient(135deg,
        rgba(51, 65, 85, 0.95) 0%,
        rgba(71, 85, 105, 0.95) 50%,
        rgba(30, 58, 138, 0.95) 100%
    );
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 2px solid rgba(148, 163, 184, 0.3);
    border-radius: 24px;
    padding: 40px;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none; /* Don't block clicks when hidden */
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

#booking-form-container.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto; /* Allow clicks when active */
    transform: translate(-50%, -50%) scale(1);
}

/* Mobile booking form optimizations - CRITICAL FIX */
@media (max-width: 768px) {
    #booking-form-container {
        /* CRITICAL: Fixed positioning to viewport */
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: linear-gradient(135deg,
            rgba(51, 65, 85, 0.98) 0%,
            rgba(71, 85, 105, 0.98) 50%,
            rgba(30, 58, 138, 0.98) 100%
        );
        padding: 25px;
        width: 95%;
        max-height: 90vh;
        border-radius: 16px;
        /* CRITICAL: Higher than preloader AND backdrop */
        z-index: 999999;
        /* Initial hidden state */
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        /* Hardware acceleration for smooth rendering */
        will-change: transform, opacity;
        transform: translate(-50%, -50%) scale(0.95);
        /* Smooth spring animation */
        transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                    visibility 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                    transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
        /* Prevent scroll issues */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        /* Touch optimization */
        touch-action: pan-y;
    }

    #booking-form-container.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Modal Close Button */
.modal-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.2);
    border: 2px solid rgba(239, 68, 68, 0.5);
    color: #ef4444;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.modal-close-btn:hover {
    background: rgba(239, 68, 68, 0.4);
    border-color: #ef4444;
    transform: rotate(90deg);
}

.modal-close-btn:active {
    transform: rotate(90deg) scale(0.9);
}

/* Modal Header Adjustments */

/* Time Slots Grid */
#time-slots {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 25px;
}

/* Time Slot Buttons */
.time-slot-btn {
    padding: 16px 20px;
    background: linear-gradient(135deg,
        rgba(59, 130, 246, 0.15) 0%,
        rgba(99, 102, 241, 0.15) 100%
    );
    border: 2px solid rgba(148, 163, 184, 0.4);
    border-radius: 12px;
    color: #f1f5f9;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.time-slot-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    transition: left 0.5s;
}

.time-slot-btn:hover {
    background: linear-gradient(135deg,
        rgba(59, 130, 246, 0.3) 0%,
        rgba(99, 102, 241, 0.3) 100%
    );
    border-color: rgba(59, 130, 246, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.25);
}

.time-slot-btn:hover::before {
    left: 100%;
}

.time-slot-btn:active {
    transform: translateY(0);
}

.time-slot-btn.selected {
    background: linear-gradient(135deg,
        rgba(59, 130, 246, 0.5) 0%,
        rgba(99, 102, 241, 0.5) 100%
    );
    border-color: #3b82f6;
    color: #fff;
    font-weight: 700;
}

.no-slots {
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.1rem;
    padding: 30px;
    font-style: italic;
}

.time-slots-header,
.booking-form-header {
    margin-bottom: 30px;
    padding-right: 40px; /* Space for close button */
}

.time-slots-header h3,
.booking-form-header h3 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 10px;
}

.time-slots-header p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
}

/* Modal Animations */
@keyframes backdropFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Mobile Modal Adjustments */
@media (max-width: 768px) {
    .time-slots-container,
    #booking-form-container {
        width: 95vw;
        max-width: 95vw;
        max-height: 90vh;
        padding: 30px 20px;
        border-radius: 20px;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    .modal-close-btn {
        top: 15px;
        right: 15px;
        width: 36px;
        height: 36px;
        font-size: 1.3rem;
    }

    .time-slots-header,
    .booking-form-header {
        padding-right: 30px;
    }

    .time-slots-header h3,
    .booking-form-header h3 {
        font-size: 1.5rem;
    }

    #time-slots {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }

    .time-slot-btn {
        padding: 14px 16px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .time-slots-container,
    #booking-form-container {
        width: 98vw;
        max-width: 98vw;
        max-height: 95vh;
        padding: 25px 15px;
        border-radius: 15px;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    .modal-close-btn {
        top: 12px;
        right: 12px;
        width: 32px;
        height: 32px;
        font-size: 1.2rem;
    }

    .time-slots-header h3,
    .booking-form-header h3 {
        font-size: 1.3rem;
    }

    #time-slots {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 8px;
    }

    .time-slot-btn {
        padding: 12px 14px;
        font-size: 0.95rem;
    }
}

/* Landscape mobile orientation */
@media (max-width: 768px) and (orientation: landscape) {
    .time-slots-container,
    #booking-form-container {
        max-height: 85vh;
        overflow-y: auto;
    }
}
    font-size: 1rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 15px;
    background: rgba(30, 64, 175, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 12px;
    color: #fff;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.2);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 30px;
}

.btn-submit {
    padding: 15px 40px;
    background: linear-gradient(135deg, #3b82f6 0%, #2d5bff 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(45, 91, 255, 0.4);
}

.btn-cancel {
    padding: 15px 40px;
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-cancel:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: #ef4444;
}

/* ============================================
   BOOKING OVERLAYS & MODALS
   ============================================ */

.booking-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.booking-overlay-content {
    text-align: center;
}

.booking-spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
    border: 5px solid rgba(59, 130, 246, 0.2);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.booking-overlay-content p {
    color: #fff;
    font-size: 1.2rem;
    font-weight: 600;
}

.booking-success-modal,
.booking-error-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: modalFadeIn 0.3s ease;
}

.booking-modal-content {
    background: linear-gradient(135deg, rgba(30, 64, 175, 0.95) 0%, rgba(45, 91, 255, 0.95) 100%);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(59, 130, 246, 0.5);
    border-radius: 30px;
    padding: 60px 40px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    animation: modalSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.booking-success-icon,
.booking-error-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    font-weight: 700;
}

.booking-success-icon {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    border: 3px solid #22c55e;
}

.booking-error-icon {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 3px solid #ef4444;
}

.booking-modal-content h2 {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 20px;
}

.booking-modal-content p {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 15px;
    line-height: 1.6;
}

/* ============================================
   RESPONSIVE DESIGN - WCAG COMPLIANT MOBILE
   ============================================ */

@media (max-width: 768px) {
    .booking-section {
        padding: 60px 0;
    }

    .booking-header h2 {
        font-size: 2rem;
    }

    .booking-calendar {
        padding: 20px;
        overflow-x: auto; /* Allow horizontal scroll on very small devices */
    }

    .calendar-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .calendar-month-year {
        font-size: 1.5rem;
    }

    /* Increase nav button size for better touch targets */
    .calendar-nav-btn {
        width: 48px;
        height: 48px;
        font-size: 1.3rem;
    }

    .calendar-day-header {
        padding: 8px;
        font-size: 0.8rem;
        font-weight: 700;
    }

    #calendar-grid {
        grid-template-columns: repeat(7, minmax(44px, 1fr));
        gap: 5px;
    }

    .calendar-day {
        min-height: 44px; /* WCAG touch target minimum */
        min-width: 44px;  /* WCAG touch target minimum */
        padding: 12px;
        font-size: 0.95rem;
    }

    /* Reduce scale on hover/selected to prevent overflow on mobile */
    .calendar-day.available:hover,
    .calendar-day.selected {
        transform: scale(1.02);
    }

    /* Add touch feedback */
    .calendar-day.available:active {
        transform: scale(0.95);
    }

    #time-slots {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 10px;
    }

    .time-slot-btn {
        min-height: 44px; /* WCAG touch target minimum */
        padding: 12px 10px;
        font-size: 0.9rem;
    }

    /* Touch feedback for time slots */
    .time-slot-btn:active {
        transform: scale(0.95);
    }

    #booking-form-container {
        padding: 25px;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn-submit,
    .btn-cancel {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .booking-header h2 {
        font-size: 1.8rem;
    }

    .calendar-day-header {
        padding: 6px;
        font-size: 0.75rem;
    }

    #calendar-grid {
        grid-template-columns: repeat(7, minmax(44px, 1fr));
        gap: 5px; /* Increased from 3px for better tap accuracy */
    }

    .calendar-day {
        min-height: 44px; /* WCAG compliance - do not reduce */
        min-width: 44px;  /* WCAG compliance - do not reduce */
        font-size: 1rem;  /* Increased from 0.85rem for WCAG readability */
        border-radius: 8px;
        padding: 10px;
    }

    #time-slots {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px; /* Increased for better spacing */
    }

    .time-slot-btn {
        min-height: 48px; /* Slightly larger for better usability */
        font-size: 0.95rem;
    }
}

/* ============================================
   FIX FOR POSITION FIXED WITH TRANSFORMED PARENTS
   When body or any parent has transform, position:fixed
   no longer positions relative to viewport.
   Solution: Use viewport units for positioning.
   ============================================ */

.time-slots-container.active {
    /* Use vh/vw units instead of percentages */
    top: 50vh !important;
    left: 50vw !important;
    /* Transform for centering */
    transform: translate(-50%, -50%) !important;
}

.booking-modal-backdrop.active {
    /* Ensure backdrop covers viewport regardless of parent transforms */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
}
