/* ============================================
   MODALE COMPTE - BOTTOM SHEET SUR MOBILE
   ============================================ */

/* Mobile uniquement - Bottom Sheet comme les autres modales */
@media (max-width: 768px) {
    /* Overlay */
    #authOverlay,
    .modal-overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        background: rgba(0, 0, 0, 0.6) !important;
        backdrop-filter: blur(8px) !important;
        -webkit-backdrop-filter: blur(8px) !important;
        z-index: 99999 !important;
        opacity: 0 !important;
        visibility: hidden !important;
        transition: opacity 0.3s ease, visibility 0s 0.3s;
        pointer-events: none !important;
        display: none !important;
    }
    
    #authOverlay.active,
    .modal-overlay.active {
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        display: block !important;
        transition: opacity 0.3s ease, visibility 0s 0s;
    }
    
    /* Modale en bottom sheet - Taille réduite */
    #authModal {
        position: fixed !important;
        bottom: 0 !important;
        top: auto !important;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: auto !important;
        max-height: 75vh !important;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        border-radius: 24px 24px 0 0;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15);
        z-index: 100000 !important;
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s 0.4s, max-height 0.3s ease;
        visibility: hidden;
        pointer-events: none;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    /* Désactiver toutes les animations sur mobile */
    .form-group,
    .form-options,
    .btn,
    .auth-toggle,
    .auth-forms {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
    
    /* Mode inscription - Espacements très réduits */
    #authModal.register-mode {
        max-height: 82vh !important;
    }
    
    #authModal.register-mode .modal__content {
        padding: 22px 16px 22px;
        padding-bottom: calc(22px + env(safe-area-inset-bottom));
    }
    
    #authModal.register-mode .auth-toggle {
        margin-bottom: 12px;
    }
    
    #authModal.register-mode .auth-toggle__btn {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    #authModal.register-mode .form-group {
        margin-bottom: 9px;
    }
    
    #authModal.register-mode .form-row {
        margin-bottom: 9px;
        gap: 8px;
    }
    
    #authModal.register-mode .form-label {
        margin-bottom: 4px;
        font-size: 11.5px;
    }
    
    #authModal.register-mode .form-input {
        padding: 9px 11px;
        font-size: 16px; /* 16px minimum pour éviter le zoom automatique sur iOS */
    }
    
    #authModal.register-mode .input-with-icon .form-input {
        padding-right: 38px !important;
    }
    
    #authModal.register-mode .input-icon-btn {
        width: 28px !important;
        height: 28px !important;
        font-size: 12px !important;
    }
    
    #authModal.register-mode .form-options {
        margin-bottom: 10px;
        margin-top: 5px;
        font-size: 11.5px;
    }
    
    #authModal.register-mode .checkbox-mark {
        width: 16px;
        height: 16px;
    }
    
    #authModal.register-mode .btn {
        padding: 11px 16px;
        font-size: 13.5px;
    }
    
    #authModal.active {
        transform: translateY(0);
        visibility: visible;
        pointer-events: auto;
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s 0s;
    }
    
    /* Bouton fermer */
    .modal__close,
    #closeAuthModal {
        position: absolute;
        top: 20px;
        right: 20px;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(184, 70, 31, 0.08);
        border: none;
        border-radius: 8px;
        color: #B8461F;
        font-size: 20px;
        cursor: pointer;
        z-index: 10;
        -webkit-tap-highlight-color: transparent;
        transition: all 0.2s ease;
    }
    
    .modal__close:active,
    #closeAuthModal:active {
        background: rgba(184, 70, 31, 0.15);
        transform: scale(0.95);
    }
    
    /* Handle de drag visuel */
    #authModal::before {
        content: '';
        position: absolute;
        top: 12px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: rgba(0, 0, 0, 0.2);
        border-radius: 2px;
        z-index: 11;
    }
    
    /* Contenu de la modale - scrollable */
    .modal__content {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding: 30px 18px 22px;
        padding-bottom: calc(22px + env(safe-area-inset-bottom));
    }
    
    /* Toggle Connexion/Inscription */
    .auth-toggle {
        display: flex;
        gap: 8px;
        margin-bottom: 20px;
        position: relative;
        background: rgba(184, 70, 31, 0.05);
        border-radius: 12px;
        padding: 4px;
    }
    
    .auth-toggle__btn {
        flex: 1;
        padding: 12px 16px;
        font-size: 14px;
        font-weight: 600;
        color: #6b7280;
        background: transparent;
        border: none;
        border-radius: 10px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: all 0.3s ease;
        position: relative;
        z-index: 2;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }
    
    .auth-toggle__btn.active {
        color: white;
    }
    
    .auth-toggle__btn i {
        font-size: 12px;
    }
    
    .auth-toggle__slider {
        position: absolute;
        top: 4px;
        left: 4px;
        width: calc(50% - 4px);
        height: calc(100% - 8px);
        background: linear-gradient(135deg, #B8461F 0%, #9a3819 100%);
        border-radius: 10px;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1;
        box-shadow: 0 2px 8px rgba(184, 70, 31, 0.3);
    }
    
    .auth-toggle.register .auth-toggle__slider {
        transform: translateX(calc(100% + 4px));
    }
    
    /* Formulaires */
    .auth-forms {
        position: relative;
    }
    
    .auth-form {
        display: none;
    }
    
    .auth-form--active {
        display: block;
    }
    
    .form-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-bottom: 14px;
    }
    
    .form-group {
        margin-bottom: 14px;
    }
    
    .form-label {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 13px;
        font-weight: 600;
        color: #374151;
        margin-bottom: 6px;
    }
    
    .form-label i {
        font-size: 12px;
        color: #B8461F;
    }
    
    .form-input {
        width: 100%;
        padding: 12px 14px;
        font-size: 16px; /* 16px minimum pour éviter le zoom automatique sur iOS */
        color: #1a1a1a;
        background: rgba(255, 255, 255, 0.9);
        border: 1px solid rgba(0, 0, 0, 0.1);
        border-radius: 10px;
        transition: all 0.2s ease;
        -webkit-tap-highlight-color: transparent;
    }
    
    .form-input:focus {
        outline: none;
        border-color: #B8461F;
        background: white;
        box-shadow: 0 0 0 3px rgba(184, 70, 31, 0.1);
    }
    
    .input-with-icon {
        position: relative !important;
        display: block !important;
        width: 100% !important;
    }
    
    .input-with-icon .form-input {
        padding-right: 44px !important;
        width: 100% !important;
        display: block !important;
    }
    
    .input-icon-btn {
        position: absolute !important;
        right: 8px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        width: 32px !important;
        height: 32px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: transparent !important;
        border: none !important;
        color: #6b7280 !important;
        cursor: pointer !important;
        -webkit-tap-highlight-color: transparent !important;
        transition: all 0.2s ease !important;
        padding: 0 !important;
        margin: 0 !important;
        z-index: 10 !important;
        font-size: 14px !important;
    }
    
    .input-icon-btn i {
        font-size: 14px !important;
    }
    
    .input-icon-btn:active {
        color: #B8461F !important;
        transform: translateY(-50%) scale(0.95) !important;
    }
    
    /* Options du formulaire */
    .form-options {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 16px;
        font-size: 13px;
    }
    
    .form-checkbox {
        display: flex;
        align-items: center;
        gap: 8px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    
    .form-checkbox input[type="checkbox"] {
        display: none;
    }
    
    .checkbox-mark {
        width: 18px;
        height: 18px;
        border: 2px solid rgba(0, 0, 0, 0.2);
        border-radius: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
    }
    
    .form-checkbox input[type="checkbox"]:checked + .checkbox-mark {
        background: #B8461F;
        border-color: #B8461F;
    }
    
    .form-checkbox input[type="checkbox"]:checked + .checkbox-mark::after {
        content: '✓';
        color: white;
        font-size: 12px;
        font-weight: bold;
    }
    
    .form-link {
        color: #B8461F;
        text-decoration: none;
        font-weight: 500;
        transition: all 0.2s ease;
    }
    
    .form-link:active {
        opacity: 0.7;
    }
    
    /* Boutons */
    .btn {
        width: 100%;
        padding: 14px 20px;
        font-size: 15px;
        font-weight: 700;
        border: none;
        border-radius: 12px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }
    
    .btn--full {
        width: 100%;
    }
    
    .btn--gradient {
        background: linear-gradient(135deg, #B8461F 0%, #9a3819 100%);
        color: white;
        box-shadow: 0 4px 12px rgba(184, 70, 31, 0.3);
    }
    
    .btn--gradient:active {
        transform: scale(0.98);
        box-shadow: 0 2px 8px rgba(184, 70, 31, 0.3);
    }
    
    .btn--social {
        background: white;
        color: #374151;
        border: 1px solid rgba(0, 0, 0, 0.1);
        margin-top: 12px;
    }
    
    .btn--social:active {
        background: rgba(0, 0, 0, 0.02);
        transform: scale(0.98);
    }
    
    .btn i {
        font-size: 14px;
    }
    
    /* Divider */
    .auth-divider {
        display: flex;
        align-items: center;
        text-align: center;
        margin: 20px 0;
        color: #6b7280;
        font-size: 13px;
    }
    
    .auth-divider::before,
    .auth-divider::after {
        content: '';
        flex: 1;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    .auth-divider::before {
        margin-right: 12px;
    }
    
    .auth-divider::after {
        margin-left: 12px;
    }
}

/* Très petits écrans */
@media (max-width: 480px) {
    #authModal {
        max-height: 80vh !important;
    }
    
    #authModal.register-mode {
        max-height: 90vh !important;
    }
    
    .modal__content {
        padding: 20px 16px;
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }
    
    .modal__close,
    #closeAuthModal {
        top: 16px;
        right: 16px;
    }
    
    .auth-toggle__btn {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .form-group {
        margin-bottom: 14px;
    }
    
    .form-label {
        font-size: 12px;
    }
    
    .form-input {
        padding: 10px 12px;
        font-size: 16px; /* 16px minimum pour éviter le zoom automatique sur iOS */
    }
    
    .btn {
        padding: 12px 18px;
        font-size: 14px;
    }
    
    .form-row {
        gap: 10px;
    }
}

/* Empêcher le scroll du body quand la modale est ouverte */
body.modal-open {
    overflow: hidden;
}
