/* ===================================
   MODALS - Optimisation Mobile & Desktop
   =================================== */

/* Base Modal Styles */
#videoModal,
#bookingModal {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease-out;
}

#videoModal.show,
#bookingModal.show {
    display: flex !important;
}

/* Fade in animation */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ===================================
   VIDEO MODAL
   =================================== */

#videoModal .relative {
    width: 100%;
    max-width: 64rem; /* 1024px */
    margin: 0 1rem;
    animation: slideUp 0.4s ease-out;
}

#videoModal .bg-black {
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Close button - Video Modal */
#videoModal button {
    position: absolute;
    top: -3rem;
    right: 0;
    color: white;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    padding: 0.5rem;
    transition: all 0.2s;
}

#videoModal button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* ===================================
   BOOKING MODAL
   =================================== */

#bookingModal .relative {
    width: 100%;
    max-width: 28rem; /* 448px */
    background: white;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.4s ease-out;
    max-height: 90vh;
    overflow-y: auto;
}

/* Close button - Booking Modal */
#bookingModal .absolute {
    position: absolute;
    top: -0.5rem;
    right: -0.5rem;
    background: #1f2937;
    color: white;
    border-radius: 50%;
    padding: 0.375rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
    z-index: 10;
}

#bookingModal .absolute:hover {
    background: #111827;
    transform: scale(1.1);
}

/* Form elements */
#bookingForm input,
#bookingForm select {
    width: 100%;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    outline: none;
    transition: all 0.2s;
}

#bookingForm input:focus,
#bookingForm select:focus {
    border-color: #a855f7;
    ring: 2px;
    ring-color: rgba(168, 85, 247, 0.2);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.1);
}

/* Submit button */
#bookingSubmitBtn {
    width: 100%;
    background: linear-gradient(135deg, #ec4899 0%, #a855f7 100%);
    color: white;
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.3s;
    box-shadow: 0 4px 6px -1px rgba(168, 85, 247, 0.3);
}

#bookingSubmitBtn:hover:not(:disabled) {
    background: linear-gradient(135deg, #db2777 0%, #9333ea 100%);
    box-shadow: 0 10px 15px -3px rgba(168, 85, 247, 0.4);
    transform: translateY(-2px);
}

#bookingSubmitBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===================================
   MOBILE OPTIMIZATIONS (< 640px)
   =================================== */

@media (max-width: 640px) {
    /* Video Modal Mobile */
    #videoModal .relative {
        margin: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
    }

    #videoModal .bg-black {
        border-radius: 0;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #videoModal button {
        top: 1rem;
        right: 1rem;
        background: rgba(0, 0, 0, 0.7);
        padding: 0.75rem;
        z-index: 10;
    }

    #videoModal button svg {
        width: 1.5rem;
        height: 1.5rem;
    }

    /* Booking Modal Mobile */
    #bookingModal {
        padding: 0;
        align-items: flex-end;
    }

    #bookingModal .relative {
        max-width: 100%;
        border-radius: 1.5rem 1.5rem 0 0;
        max-height: 95vh;
        animation: slideUpMobile 0.4s ease-out;
    }

    @keyframes slideUpMobile {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    /* Ajuster le padding du contenu */
    #bookingModal .p-5 {
        padding: 1.25rem;
        padding-bottom: 2rem; /* Plus d'espace en bas pour iOS */
    }

    /* Agrandir les champs de formulaire sur mobile */
    #bookingForm input,
    #bookingForm select {
        padding: 0.875rem 1rem;
        font-size: 1rem; /* Évite le zoom automatique sur iOS */
    }

    #bookingForm label {
        font-size: 0.875rem;
    }

    /* Bouton submit plus grand */
    #bookingSubmitBtn {
        padding: 1rem;
        font-size: 1rem;
        margin-top: 0.5rem;
    }

    /* En-tête du modal plus compact */
    #bookingModal h3 {
        font-size: 1.125rem;
    }

    #bookingModal .text-xs {
        font-size: 0.8125rem;
    }

    /* Icône en-tête plus petite */
    #bookingModal .w-12 {
        width: 2.5rem;
        height: 2.5rem;
    }

    /* Bouton fermer repositionné */
    #bookingModal .absolute {
        top: 0.75rem;
        right: 0.75rem;
        background: rgba(243, 244, 246, 0.95);
        color: #374151;
    }

    #bookingModal .absolute svg {
        width: 1rem;
        height: 1rem;
    }

    /* Améliorer le scroll sur mobile */
    #bookingModal .relative {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /* Grid pour date et heure plus espacé */
    #bookingForm .grid {
        gap: 0.75rem;
    }
}

/* ===================================
   TABLETTE (641px - 768px)
   =================================== */

@media (min-width: 641px) and (max-width: 768px) {
    #videoModal .relative {
        margin: 0 2rem;
    }

    #bookingModal .relative {
        max-width: 32rem;
    }
}

/* ===================================
   DESKTOP LARGE (> 1024px)
   =================================== */

@media (min-width: 1024px) {
    #videoModal .relative {
        max-width: 72rem; /* 1152px */
    }

    #bookingModal .relative {
        max-width: 30rem; /* 480px */
    }
}

/* ===================================
   ACCESSIBILITY & UX
   =================================== */

/* Focus visible pour navigation clavier */
#videoModal button:focus-visible,
#bookingModal button:focus-visible,
#bookingForm input:focus-visible,
#bookingForm select:focus-visible {
    outline: 2px solid #a855f7;
    outline-offset: 2px;
}

/* Smooth scroll pour le modal booking */
#bookingModal .relative {
    scroll-behavior: smooth;
}

/* Prévenir le zoom sur les petits écrans lors du focus */
@media (max-width: 640px) {
    #bookingForm input,
    #bookingForm select,
    #bookingForm textarea {
        font-size: 16px !important; /* Évite le zoom sur iOS */
    }
}

/* Loading state pour le bouton */
#bookingBtnLoader svg {
    display: inline-block;
    animation: spin 1s linear infinite;
}

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

/* Message de succès/erreur */
#bookingMessage {
    border-radius: 0.5rem;
    padding: 0.75rem;
    font-size: 0.875rem;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#bookingMessage.success {
    background-color: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
}

#bookingMessage.error {
    background-color: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

/* Prévenir le scroll du body quand modal ouvert */
body.modal-open {
    overflow: hidden;
    touch-action: none;
}

/* Dark mode support (optionnel) */
@media (prefers-color-scheme: dark) {
    #bookingModal .relative {
        background: #1f2937;
        color: white;
    }

    #bookingForm input,
    #bookingForm select {
        background: #374151;
        border-color: #4b5563;
        color: white;
    }

    #bookingForm label {
        color: #d1d5db;
    }

    #bookingModal .absolute {
        background: #374151;
    }
}
