
/* Transizione fluida generale */
.nav-container * { transition: all 0.25s ease-in-out; }

.nav-title {
    text-decoration: none; color: #3E2723; font-weight: bold; font-size: 20px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1); text-align: center; white-space: nowrap;
    display: block; flex-shrink: 1;
}

/* --- SIDEBAR LATERALE --- */
#sideMenu {
    height: 100vh;
    width: 300px;
    position: fixed;
    top: 0;
    left: 0; 
    transform: translateX(-110%); 
    will-change: transform;
    background: rgba(10, 10, 10, 0.85); 
    backdrop-filter: blur(15px); 
    -webkit-backdrop-filter: blur(15px);
    box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    z-index: 3000; /* 🔴 Alzato per stare sopra al tasto accedi */
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    padding-top: 80px;
    padding-bottom: 150px; 
    overflow-y: auto; 
    overflow-x: hidden; 
    scrollbar-width: none; 
    -ms-overflow-style: none; 
    overscroll-behavior: none; 
}

#sideMenu::-webkit-scrollbar { display: none; }
#sideMenu.active { transform: translateX(0) !important; }

.menu-link {
    display: block;
    padding: 20px 30px;
    color: #ffffff !important; 
    text-decoration: none !important;
    font-size: 18px;
    font-weight: bold;
    border-left: 5px solid transparent;
    font-family: sans-serif;
    cursor: pointer;
    z-index: 2001;
    background: rgba(255, 255, 255, 0.05);
    margin-bottom: 2px;
}

.menu-link:hover {
    background: rgba(255, 255, 255, 0.15);
    border-left: 5px solid #A31A58;
    padding-left: 45px;
    color: #ff6eb4 !important; 
}

#menuBtn { transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important; }

#menuBtn.menu-btn-active {
    background: transparent !important;
    box-shadow: none !important;
    color: white !important;
    font-size: 28px !important;
    padding: 10px 20px !important;
    width: 60px !important;
    position: absolute;
    top: 15px; 
    left: 15px;
    z-index: 3005; /* 🔴 Alzato per stare sopra al menu stesso */
}

.username-text {
    color: #3E2723;
    font-weight: bold;
    text-decoration: none;
    white-space: nowrap;
    transition: font-size 0.2s;
    /* FIX PER L'ALLINEAMENTO */
    display: inline-flex !important;
    align-items: center !important;
    line-height: 1 !important; 
    height: 100%; /* Forza l'altezza a quella del contenitore padre */
    vertical-align: middle;
}

/* Stile Icona DM */
.dm-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    margin-right: 5px;
    cursor: pointer;
}
.dm-icon-svg {
    width: 22px;
    height: 22px;
    fill: #3E2723;
    transition: transform 0.2s;
}
.dm-icon-wrapper:hover .dm-icon-svg {
    transform: scale(1.1) rotate(-10deg);
}
.dm-badge {
    position: absolute;
    top: -8px; /* Spinto più in alto */
    right: -8px; /* Spinto più in fuori a destra */
    background: #e74c3c;
    color: white;
    font-size: 8px; /* Testo più piccolo */
    font-weight: bold;
    padding: 1px 3px; /* Meno ingombro interno */
    min-width: 10px; /* Dimensioni base ridotte */
    height: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    border: 1.5px solid white; /* Bordo leggermente più fine */
    line-height: 1;
    box-sizing: content-box;
    z-index: 10;
}

/* --- REGOLE MOBILE GENERALI --- */
@media (max-width: 768px) {
    /* 🚀 MENU A COMPARSA PIÙ GRANDE, LARGO E SCURO */
    #sideMenu { 
        width: 260px !important;       /* Torna alla larghezza classica */
        max-width: 100% !important; 
        background: rgba(10, 10, 10, 0.85) !important; /* Sfondo originale */
    }
    .menu-link { 
        font-size: 16px !important;    /* Testo originale */
        padding: 15px 20px !important; /* Padding originale */
    }
    #menuBtn.menu-btn-active { 
        font-size: 24px !important;    /* X di chiusura standard */
        width: 50px !important; 
    }
    #btnWrapper { width: 85px !important; }
    
    .user-section { gap: 2px !important;}
    .dm-icon-wrapper { margin-right: 8px !important; /* Lascia spazio al numerino per non toccare l'avatar */}
    .dm-icon-svg { width: 20px; height: 20px; }
    .username-text { 
        font-size: 11px !important; 
        max-width: 70px !important;       /* Larghezza massima per il nome */
        white-space: nowrap !important;   /* Mantiene tutto su una riga */
        overflow: hidden !important;      /* Nasconde l'eccesso */
        text-overflow: ellipsis !important; /* FORZA la comparsa dei tre puntini */
        display: inline-block !important; /* Necessario per far funzionare text-overflow */
        vertical-align: middle !important;
    }
    .nav-avatar-img { width: 22px !important; height: 22px !important; }

    .dm-modal-container {
        width: 85% !important;    
        height: 55vh !important;    
        max-height: 400px !important;
        border-radius: 12px !important;
        transition: transform 0.3s ease;
    }

    #dmModal {
        align-items: flex-start !important; 
        padding-top: 5vh !important; 
    }

    .dm-modal-header h3 { font-size: 13px !important; }
    .chat-row strong { font-size: 12px !important; }
    .chat-row p { font-size: 10px !important; }
    .chat-row img { width: 32px !important; height: 32px !important; }
    
    #dmInput, #chatSearch, #userListSearch { 
        font-size: 13px !important; 
        padding: 6px 10px !important; 
        height: 30px !important; 
    }

    /* FIX X SU MOBILE: sovrascrive il valore desktop */
    #dmHeaderRight {
        position: absolute !important;
        right: 15px !important; /* Spazio dal bordo destro */
        top: 50% !important;
        transform: translateY(-50%) !important; /* Centra verticalmente */
        width: 30px !important;
        height: 30px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    #dmHeaderRight button {
        font-size: 28px !important; /* Leggermente più piccola per mobile */
        line-height: 1 !important;
    }

}

/* --- STILI MODALE DM --- */
#dmModal {
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0,0,0,0.7); 
    z-index: 5000; 
    align-items: center; 
    justify-content: center; 
    backdrop-filter: blur(5px);
}
.dm-modal-container {
    padding: 0 !important;
    background: white; 
    width: 95%; 
    max-width: 450px; 
    height: 80vh; 
    border-radius: 15px; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
    position: relative; 
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}

/* HEADER: Assetto per PC */
.dm-modal-header {
    position: relative; 
    display: flex !important;
    justify-content: center; 
    align-items: center;     
    background: #A31A58; 
    min-height: 55px;
    width: 100% !important; 
    box-sizing: border-box !important; 
    padding: 0 !important; 
    margin: 0 !important;
    color: white;
}

#dmHeaderRight {
    position: absolute;
    right: -120px; /* VALORE PC */
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

#dmHeaderLeft {
    position: absolute;
    left: 15px;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    z-index: 100;
}

#dmHeaderRight button {
    background: none;
    border: none;
    color: white;
    font-size: 32px; 
    cursor: pointer;
    line-height: 0; 
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#dmTitleContainer {
    max-width: 60%; 
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    pointer-events: none; 
}

textarea {
    display: block;
    width: 100%;
}

.chat-input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: env(safe-area-inset-bottom);
}

#dmInput {
    font-size: 16px !important;
}

.nav-container img, 
.nav-container a {
    -webkit-touch-callout: none; /* Impedisce il menu popup su iOS/Android */
}

/* Blocco totale del tieni premuto sull'avatar della navbar per Mobile */
.nav-avatar-img {
    -webkit-touch-callout: none; /* Disabilita il menu contestuale su iOS Safari */
    -webkit-user-select: none;   /* Chrome, Safari, Opera */
    -khtml-user-select: none;     /* Konqueror HTML */
    -moz-user-select: none;        /* Firefox */
    -ms-user-select: none;         /* IE / Edge */
    user-select: none;             /* Standard */
}

.nav-title.logo-link{
    display: flex;
    align-items: center;
    height: 50px;
    overflow: hidden;
}

.logo-img{
    height: 25px;
    width: 160px;
    object-fit: cover;
    display: block;
    transition: all 0.25s ease;
}

/* hover desktop */
.logo-link:hover .logo-img{
    transform: scale(1.08);
    filter: drop-shadow(0 0 10px #A31A58);
}

/* 📱 MOBILE */
@media (max-width: 768px){
    .logo-img{
        height: 18px;
        width: 120px;
    }
}

.logo-link, .logo-link img {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
    outline: none;
}


/* Impedisce il trascinamento (drag) su TUTTI gli elementi dell'header */
.nav-container img, 
.nav-container a {
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
    pointer-events: auto; /* Manteniamo i click attivi */
}

           /* ==========================================
       STILI MINI-PLAYER GLOBALE (IL NUNZIONE) 
       ========================================== */
       #global-mini-player {
        display: none; 
        position: fixed;
        top: 61px; 
        left: 0;
        width: 100%;
        height: 56px; /* Altezza fissa e stabile */
        background: rgba(10, 10, 10, 0.82);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        z-index: 1999;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
        box-sizing: border-box;
        padding: 6px 16px 10px 16px; /* Spazio inferiore per la barra */
        align-items: center;
        justify-content: space-between;
    }

    #global-mini-player.player-active {
        display: flex !important;
    }

    .mini-player-left {
        display: flex;
        align-items: center;
        gap: 10px;
        flex: 1;
        min-width: 0;
    }

    #mini-player-cover {
        width: 38px;
        height: 38px;
        border-radius: 6px;
        object-fit: cover;
        border: 1px solid rgba(255, 255, 255, 0.1);
        flex-shrink: 0;
    }

    .mini-player-info {
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    #mini-player-title {
        font-family: system-ui, -apple-system, sans-serif;
        font-size: 13px;
        font-weight: 600;
        color: #ffffff;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.3;
    }

    #mini-player-time {
        font-family: 'Courier New', Courier, monospace;
        font-size: 11px;
        font-weight: bold;
        color: #aaaaaa;
        line-height: 1.2;
    }

    .mini-player-right {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-shrink: 0;
    }

    /* BARRA DI SCORRIMENTO INTELLIGENTE AD ADATTAMENTO TOTALE */
    #mini-player-seeker {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 4px;
        accent-color: #A31A58;
        cursor: pointer;
        background: rgba(255, 255, 255, 0.15);
        border: none;
        margin: 0;
        padding: 0;
        -webkit-appearance: none;
        appearance: none;
        z-index: 10;
        transition: height 0.1s ease;
    }

    #mini-player-seeker:hover {
        height: 6px;
    }

    /* Pulsanti tondi perfettamente calibrati */
    .mini-player-btn {
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.08);
        color: #ffffff;
        font-size: 13px;
        cursor: pointer;
        width: 32px;
        height: 32px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        transition: all 0.2s ease-in-out;
        padding: 0;
        margin: 0;
    }

    .mini-player-btn:hover {
        background: rgba(163, 26, 88, 0.85);
        color: #ffffff;
        border-color: rgba(255, 255, 255, 0.2);
        box-shadow: 0 0 10px rgba(163, 26, 88, 0.4);
    }

    /* 📱 FIX TOTALIZZANTE PER DISPOSITIVI MOBILE */
    @media (max-width: 768px) {
        #global-mini-player {
            top: 54px; /* Sotto la navbar mobile */
            height: 52px;
            padding: 4px 10px 8px 10px;
        }
        #mini-player-cover {
            width: 32px;
            height: 32px;
        }
        #mini-player-title {
            font-size: 11px;
            max-width: 110px; /* Impedisce di spingere i bottoni */
        }
        #mini-player-time {
            font-size: 10px;
        }
        .mini-player-right {
            gap: 4px; /* Compattazione millimetrica */
        }
        .mini-player-btn {
            width: 28px;
            height: 28px;
            font-size: 11px;
        }
    }

/* La navbar occupa 61px */
body {
    padding-top: 61px !important; 
    transition: padding-top 0.3s ease;
}

/* Quando il player è visibile, aggiungiamo lo spazio del player (circa 49px) */
body.player-is-visible {
    padding-top: 110px !important; /* 61px (nav) + 49px (player) */
}

/* Navbar e Player fissi */
.nav-container { top: 0; height: 61px; z-index: 2000; }
#global-mini-player { 
    top: 61px; 
    height: 49px; /* Definiamo un'altezza precisa */
    z-index: 1999; 
}