:root {
    --bg-main: #151a22; /* Sfondo generale */
    --bg-card: #1e2532; /* Sfondo card login e sidebar */
    --text-main: #ffffff;
    --text-muted: #8b9bb4;
    --accent-blue: #3b82f6; /* Colore bottone */
    --accent-green: #10b981; /* Colore HACCP+ che useremo per dettagli */
    --border-color: #2d3748;
    --input-bg: #11151c;
    --border-radius: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
}

/* =========================================
   STILI PER LA PAGINA DI LOGIN
   ========================================= */
.login-body {
    justify-content: center;
    align-items: center;
}

.auth-card {
    background-color: var(--bg-card);
    width: 100%;
    max-width: 400px;
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    text-align: center;
    border: 1px solid var(--border-color);
}

.auth-card .logo-area {
    margin-bottom: 20px;
}

.auth-card h1 {
    font-size: 24px;
    margin-bottom: 5px;
    color: white;
}

.auth-card h1 span {
    color: var(--accent-green);
}

.auth-card .subtitle {
    color: var(--accent-green);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.auth-card .desc {
    color: var(--text-muted);
    font-size: 11px;
    margin-bottom: 30px;
}

form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    text-align: left;
}

form label {
    font-size: 13px;
    color: var(--text-main);
    margin-bottom: -10px; /* Avvicina la label all'input */
}

input[type="text"], input[type="password"] {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: white;
    padding: 12px;
    border-radius: var(--border-radius);
    font-size: 14px;
    outline: none;
}

input[type="text"]:focus, input[type="password"]:focus {
    border-color: var(--accent-blue);
}

.btn-primary {
    background-color: var(--accent-blue);
    color: white;
    border: none;
    padding: 14px;
    border-radius: var(--border-radius);
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    text-transform: uppercase;
    margin-top: 10px;
    transition: 0.2s;
}

.btn-primary:hover {
    background-color: #2563eb;
}

.toggle-text {
    margin-top: 25px;
    font-size: 13px;
    color: var(--text-muted);
}

.toggle-text span {
    color: white;
    cursor: pointer;
    text-decoration: underline;
}

.footer-login {
    margin-top: 30px;
    font-size: 10px;
    color: var(--text-muted);
}

.footer-login a {
    color: white;
    text-decoration: none;
}

/* =========================================
   STILI PER LA BACHECA (DASHBOARD)
   ========================================= */
.dashboard-layout {
    display: flex;
    width: 100%;
}

.sidebar {
    width: 250px;
    background-color: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100vh;
    padding: 20px 0;
}

.sidebar-header {
    padding: 0 20px;
}

.sidebar-header h2 {
    font-size: 18px;
    color: white;
}

.sidebar-header h2 span {
    color: var(--accent-green);
}

.sidebar-header .user-info {
    color: var(--accent-green);
    font-size: 10px;
    text-transform: uppercase;
    margin-top: 5px;
}

/* Bottone Chat alto a destra nella sidebar */
.chat-btn {
    position: absolute;
    top: 20px;
    left: 210px; /* Posizionato a filo destro della sidebar */
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: 5px;
    padding: 5px 10px;
    cursor: pointer;
}

.chat-btn:hover {
    color: white;
    border-color: white;
}

.sidebar-footer {
    padding: 0 20px;
}

.user-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px; /* Spazio tra Chat ed Esci */
    margin-bottom: 20px;
}

.user-badge {
    background-color: var(--input-bg);
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 12px;
    border: 1px solid var(--border-color);
}

.btn-esci {
    background: transparent;
    border: 1px solid #ef4444; /* Rosso */
    color: #ef4444;
    padding: 5px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
}

.btn-esci:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

.sidebar-links {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.8;
}

.sidebar-links a {
    color: var(--text-muted);
    text-decoration: none;
}

.sidebar-links a:hover {
    color: white;
}

.main-content {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
}

/* =========================================
   STILI PER LA MODALE CUSTOM
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(3px); /* Effetto sfocato per oscurare il login */
}

.modal-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 30px;
    width: 90%;
    max-width: 350px;
    text-align: center;
    box-shadow: 0 15px 30px rgba(0,0,0,0.8);
    animation: modalFadeIn 0.3s ease-out;
}

.modal-card h2 {
    color: white;
    font-size: 20px;
    margin-bottom: 15px;
}

.modal-card h2.success {
    color: var(--accent-green);
}

.modal-card h2.error {
    color: #ef4444;
}

.modal-card p {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 25px;
    line-height: 1.5;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   NUOVO BOTTONE CHAT & SELECT SINDACATO
   ========================================= */
.btn-chat {
    flex: 1; /* Fa espandere il bottone per occupare tutto lo spazio libero */
    background-color: var(--accent-blue);
    border: 1px solid var(--accent-blue);
    color: white;
    padding: 8px 10px;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-weight: bold;
    font-size: 12px;
    transition: 0.2s;
}

.btn-chat:hover {
    background-color: #2563eb;
}

.sidebar-header .user-badge-top {
    display: inline-block;
    background-color: var(--input-bg);
    color: var(--text-muted);
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 10px;
    border: 1px solid var(--border-color);
    margin-left: 8px;
    vertical-align: middle;
}

/* =========================================
   MOBILE RESPONSIVE (Bottom Navigation)
   ========================================= */

/* Nascondiamo la top-bar mobile di default sui PC */
.mobile-top-bar {
    display: none;
}
/* Nascondiamo la bottom-bar mobile di default sui PC */
.mobile-bottom-bar {
    display: none;
}

/* Nascondiamo il footer mobile sui PC */
.mobile-footer {
    display: none;
}

@media (max-width: 768px) {
    .dashboard-layout {
        flex-direction: column;
    }

    /* Nascondiamo la sidebar laterale classica su mobile */
    .sidebar {
        display: none; 
    }

    /* TOP BAR MOBILE (Logo e Info Utente) */
    .mobile-top-bar {
        display: flex;
        justify-content: space-between;
        align-items: center;
        background-color: var(--bg-card);
        padding: 15px 20px;
        border-bottom: 1px solid var(--border-color);
        position: fixed;
        top: 0;
        width: 100%;
        z-index: 100;
    }

    .mobile-top-bar h2 {
        font-size: 16px;
        color: white;
    }

    .mobile-top-bar h2 span {
        color: var(--accent-green);
    }

    .mobile-user-info {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
    }

    .mobile-user-info #mobile-user-name {
        font-size: 11px;
        color: var(--accent-green);
        text-transform: uppercase;
    }
    
    .mobile-user-info #mobile-username-badge {
        font-size: 9px;
        background-color: var(--input-bg);
        color: var(--text-muted);
        padding: 2px 6px;
        border-radius: 10px;
        border: 1px solid var(--border-color);
        margin-top: 3px;
    }

    /* MAIN CONTENT (Aggiungiamo padding per le barre fisse) */
    .main-content {
        padding: 80px 20px 90px 20px; /* Top, Right, Bottom, Left */
        width: 100%;
    }

    /* BOTTOM BAR MOBILE (Navigazione) */
    .mobile-bottom-bar {
        display: flex;
        justify-content: space-around;
        align-items: center;
        background-color: var(--bg-card);
        padding: 10px;
        border-top: 1px solid var(--border-color);
        position: fixed;
        bottom: 0;
        width: 100%;
        z-index: 100;
        box-shadow: 0 -5px 15px rgba(0,0,0,0.3);
    }

    .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        color: var(--text-muted);
        background: none;
        border: none;
        font-size: 10px;
        cursor: pointer;
        padding: 5px 15px;
    }

    .nav-item i {
        font-size: 20px;
        margin-bottom: 5px;
        font-style: normal;
    }

    .nav-item.active {
        color: var(--accent-green);
    }
    
    .nav-item.logout {
        color: #ef4444;
    }

    /* Mostriamo il footer mobile */
    .mobile-footer {
        display: block;
        text-align: center;
        margin-top: 50px;
        margin-bottom: 20px;
        font-size: 10px;
        color: var(--text-muted);
        line-height: 1.8;
    }
    
    .mobile-footer a {
        color: var(--text-muted);
        text-decoration: none;
    }
}