:root {
    /* PALETTE */
    --primary: #718355;       /* Verde Oliva Scuro */
    --primary-hover: #5d6b46;
    --secondary: #87986A;
    --accent: #B5C99A;
    --light: #CFE1B9;
    --lightest: #E9F5DB;

    /* SYSTEM */
    --bg-body: #F4F7F9;
    --bg-card: #FFFFFF;
    --text-main: #2D3748;
    --text-muted: #718096;
    --border: #E2E8F0;
    --danger: #E53E3E;
    --success: #38A169;
    --sidebar-width: 260px;
    --header-height: 64px;
}

* { box-sizing: border-box; }

/* 5. ALL MAIUSC (Tranne eccezioni) */
body {
    margin: 0;
    font-family: 'Segoe UI', sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    text-transform: uppercase; /* TESTO MAIUSCOLO GLOBALE */
    font-size: 14px; /* Base leggermente più piccola per il maiuscolo */
}

/* Eccezioni Maiuscolo */
input[type="email"], input[type="password"] { text-transform: none; }
.lowercase-override { text-transform: none; }

/* 4. SIDEBAR & LINKS */
a { text-decoration: none; color: inherit; } /* NO SOTTOLINEATURA */
ul { list-style: none; padding: 0; }

/* LAYOUT */
.app-shell { display: grid; grid-template-columns: var(--sidebar-width) 1fr; min-height: 100vh; }
.app-aside { background: var(--primary); color: white; display: flex; flex-direction: column; padding: 1rem; position: sticky; top: 0; height: 100vh; z-index: 50; transition: transform 0.3s ease; }
.app-main { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.app-header { height: var(--header-height); background: var(--bg-card); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 2rem; flex-shrink: 0; }
.content-area { flex: 1; overflow-y: auto; padding: 2rem; position: relative; }

/* COMPONENTS */
.card { background: var(--bg-card); border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); padding: 1.5rem; margin-bottom: 1.5rem; }

.btn { padding: 0.6rem 1.2rem; border-radius: 6px; border: none; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; transition: 0.2s; text-transform: uppercase; letter-spacing: 0.5px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: rgba(0,0,0,0.05); color: var(--text-main); }

.input { width: 100%; padding: 0.8rem; border: 1px solid var(--border); border-radius: 6px; font-size: 1rem; }
.input:focus { outline: none; border-color: var(--primary); background: var(--lightest); }

/* TABLE */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 1rem; border-bottom: 2px solid var(--border); color: var(--text-muted); font-size: 0.75rem; letter-spacing: 1px; }
td { padding: 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background-color: #f8fafc; }

/* 3. MOBILE FIXES */
@media (max-width: 768px) {
    .app-shell { display: block; } /* Rimuove grid su mobile */

    .app-aside {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 80%;
        max-width: 300px;
        transform: translateX(-100%); /* Nascosta di default */
        box-shadow: 2px 0 10px rgba(0,0,0,0.2);
    }
    .app-aside.open { transform: translateX(0); } /* Visibile se open */
    .app-header { padding: 0 1rem; }
    .content-area { padding: 1rem; }

    /* Login Mobile Fix */
    body { height: auto; min-height: 100vh; }
    .card { padding: 1.5rem; }
}

/* --- ZENITH UI COMPONENTS --- */
/* 1. TOGGLE SWITCH */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #cbd5e0; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
input:checked + .slider { background-color: var(--success); }
input:checked + .slider:before { transform: translateX(18px); }

/* 2. MODAL (Zenith Style) */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; backdrop-filter: blur(2px); }
.modal-content { background: white; padding: 2rem; border-radius: 12px; width: 100%; max-width: 500px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); animation: slideUp 0.3s ease; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: 1rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: 1rem; margin-top: 2rem; }

/* 3. USER PROFILE HEADER */
.user-profile-widget { display: flex; align-items: center; gap: 12px; padding: 6px 12px; background: rgba(0,0,0,0.03); border-radius: 30px; border: 1px solid rgba(0,0,0,0.05); }
.user-avatar { width: 32px; height: 32px; background: var(--primary); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 14px; }
.user-info { display: flex; flex-direction: column; line-height: 1.1; text-align: right; }
.user-name { font-weight: 600; font-size: 0.85rem; color: var(--text-main); }
.user-role { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* HEADER PROFILE & DROPDOWN */
.profile-container { position: relative; }
.header-avatar {
    width: 40px; height: 40px;
    background: var(--primary); color: white;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; cursor: pointer;
    transition: transform 0.2s;
}
.header-avatar:hover { transform: scale(1.05); }
.profile-dropdown { position: absolute; top: 50px; right: 0; width: 240px; background: white; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); border: 1px solid var(--border); z-index: 1000; display: none; flex-direction: column; overflow: hidden; }
.profile-dropdown.open { display: flex; animation: fadeIn 0.2s ease; }

.dropdown-info { padding: 16px; background: var(--lightest); border-bottom: 1px solid var(--border); }
.dropdown-name { font-weight: 700; color: var(--text-main); font-size: 0.9rem; margin-bottom: 4px; }
.dropdown-email { font-size: 0.75rem; color: var(--text-muted); word-break: break-all; text-transform: lowercase; }

.dropdown-item { padding: 12px 16px; display: flex; align-items: center; gap: 10px; cursor: pointer; transition: background 0.2s; color: var(--text-main); font-size: 0.9rem; }
.dropdown-item:hover { background: #f8fafc; }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: #FFF5F5; }

/* SIDEBAR MINI MODE */
:root {
    --sidebar-width: 260px;
    --sidebar-mini: 70px;
}

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    transition: grid-template-columns 0.3s ease;
}

.app-shell.mini-mode {
    grid-template-columns: var(--sidebar-mini) 1fr;
}

.app-aside {
    width: 100%;
    overflow: hidden;
    transition: width 0.3s ease;
}

/* MINI MODE (Desktop Chiusa) */
.app-shell.mini-mode .app-aside .nav-text,
.app-shell.mini-mode .app-aside .logo-text,
.app-shell.mini-mode .app-aside .admin-label {
    opacity: 0;
    visibility: hidden;
    width: 0;
    display: none;
}

.app-shell.mini-mode .app-aside .btn {
    justify-content: center !important;
    padding: 0.8rem 0;
}

/* DROPDOWN EMAIL FIX */
.dropdown-email {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    word-break: break-all;
    text-transform: lowercase;
}

/* MOBILE OVERRIDE */
@media (max-width: 768px) {
    .app-shell { display: block; }
    .app-shell.mini-mode { display: block; }

    .app-aside {
        position: fixed;
        transform: translateX(-100%);
        width: 80%;
        z-index: 100;
    }
    .app-aside.open { transform: translateX(0); }

    .app-aside .nav-text { display: inline-block !important; }
    .app-aside .btn { justify-content: flex-start !important; }
}
