/* ==============================
   INDEX - SMARTPHONES PORTRAIT
   Version corrigée 100% fonctionnelle
============================== */
@media screen and (max-width: 768px) and (orientation: portrait) {

    body {
        flex-direction: column;
        align-items: center;
        padding: 0 10px;
        overflow-x: hidden;
        margin-top: 0;
    }

    /* ==============================
       PANNEAU UTILISATEUR - TOUT EN HAUT + Z-INDEX HAUT
    ============================== */
    .user-panel {
        position: relative;
        top: auto;
        right: auto;
        display: flex;
        justify-content: center;
        gap: 8px;
        margin: 12px auto 8px;
        width: 100%;
        max-width: 350px;
        flex-wrap: nowrap;
        order: -1;
        z-index: 9999; /* Toujours au-dessus de tout */
    }

    #consoleBtnTop,
    #userBtn {
        padding: 8px 12px;
        font-size: 0.75rem;
        border-radius: 8px;
        font-weight: 600;
        flex: 1;
        min-width: 130px;
        max-width: 160px;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        transition: all 0.2s ease;
    }

    #consoleBtnTop {
        background: rgba(34, 197, 94, 0.12);
        border: 1.5px solid #22c55e;
        color: #22c55e;
        box-shadow: 0 0 10px rgba(34, 197, 94, 0.2);
    }

    #userBtn {
        background: rgba(0, 234, 255, 0.12);
        border: 1.5px solid #00eaff;
        color: #00eaff;
        box-shadow: 0 0 10px rgba(0, 234, 255, 0.2);
    }

    /* MENU DÉROULANT UTILISATEUR - TOUJOURS DEVANT */
    #userInfo {
        position: absolute;
        top: 100%;
        left: 50%;
        transform: translateX(-50%);
        width: 200px;
        margin-top: 10px;
        padding: 14px;
        background: rgba(22, 26, 34, 0.98);
        backdrop-filter: blur(15px);
        border: 1.5px solid #00eaff;
        border-radius: 10px;
        box-shadow: 0 8px 25px rgba(0, 234, 255, 0.4);
        z-index: 10000; /* Au-dessus de TOUT */
        display: none;
        font-size: 0.88rem;
    }

    #userInfo.show { display: block; }

    #userInfo::before {
        content: '';
        position: absolute;
        top: -10px;
        left: 50%;
        transform: translateX(-50%);
        border: 10px solid transparent;
        border-bottom-color: #00eaff;
    }

    /* ==============================
       LOGO + PHOTO + TEXTE
    ============================== */
    header { margin-top: 5px; }
    .logo-img { width: 140px; }
    .profile-photo { width: 110px; height: 110px; margin-top: 8px; }

    .intro-text {
        width: 90%;
        max-width: 340px;
        margin   : 15px auto 20px;
        padding  : 14px 16px;
        font-size: 0.84rem;
        line-height: 1.4;
        border-radius: 10px;
    }

    /* ==============================
       MENU CARTES
    ============================== */
    .menu {
        margin: 10px 0 60px;
        gap: 20px;
        flex-direction: column;
        align-items: center;
    }

    .card {
        width: 100%;
        max-width : 300px;
        min-height: 250px;
        border-radius: 10px;
    }

    .card img { height: 170px; object-fit: cover; }

    /* ==============================
       MODALE CONNEXION / INSCRIPTION - TAILLE PARFAITE
    ============================== */
    .modal.active {
        padding: 10px;
        align-items: center; /* Changé de flex-start à center */
        padding-top: 5vh; /* Réduit pour éviter le dépassement */
    }
    
    .modal-content {
        width: 90% !important;
        max-width: 300px !important;
        min-width: 250px !important;
        padding: 15px 12px !important;
        border-radius: 10px;
        box-shadow: 0 8px 20px rgba(0, 234, 255, 0.25);
        margin: 0 auto;
        max-height: 85vh; /* Limite la hauteur maximum */
        overflow-y: auto; /* Ajoute le défilement si nécessaire */
    }
    
    .modal-content h2 {
        font-size: 1.2rem;
        margin-bottom: 10px;
        padding: 0 5px;
    }
    
    .modal-content input {
        padding: 8px 10px;
        font-size: 0.85rem;
        margin: 4px 0;
        height: 38px;
        box-sizing: border-box; /* Empêche le dépassement */
        width: 100%;
    }
    
    .modal-content button {
        padding: 10px;
        font-size: 0.9rem;
        margin-top: 8px;
        height: 42px;
    }
    
    .modal-content .message {
        font-size: 0.78rem;
        padding: 6px;
        margin: 5px 0;
        line-height: 1.2;
    }
    
    .modal-content .switch-form {
        font-size: 0.78rem;
        margin-top: 8px;
        padding: 0 5px;
    }
    
    /* Espacement réduit pour petits écrans */
    .modal-content form {
        margin: 0;
        padding: 0;
    }
    
    /* Très petits écrans (iPhone SE, etc.) */
    @media screen and (max-width: 375px) and (max-height: 670px) {
        .modal-content {
            max-width: 260px !important;
            padding: 12px 10px !important;
        }
        .modal-content h2 { 
            font-size: 1.15rem; 
            margin-bottom: 8px;
        }
        .modal-content input { 
            font-size: 0.82rem; 
            padding: 7px;
            height: 36px;
            margin: 3px 0;
        }
        .modal-content button {
            padding: 9px;
            font-size: 0.85rem;
            margin-top: 6px;
            height: 40px;
        }
    }
}