:root {
    --nav-height: 60px;
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 0px; /* Si può impostare a 70px per icone visibili */
    --primary-color: #2c3e50;
    --accent-color: #3498db;
    --bg-light: #f4f7f6;
    --text-color: #333;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', sans-serif;
}

body {
    background-color: var(--bg-light);
    overflow-x: hidden;
}

/* NAVBAR */
.navbar {
    height: var(--nav-height);
    background: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
}

.nav-left { display: flex; align-items: center; gap: 20px; }
.logo { font-weight: bold; font-size: 1.2rem; color: var(--primary-color); }

.btn-icon {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--primary-color);
}

/* POPUP UTENTE */
.user-menu-container { position: relative; }
.user-popup {
    position: absolute;
    right: 0;
    top: 50px;
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 8px;
    width: 180px;
    display: none; /* Nascosto di base */
    flex-direction: column;
    overflow: hidden;
}

.user-popup.active { display: flex; }
.user-popup a {
    padding: 12px 15px;
    text-decoration: none;
    color: var(--text-color);
    font-size: 14px;
    transition: background 0.2s;
}

.user-popup a:hover { background: #f8f9fa; }
.user-popup a.logout { border-top: 1px solid #eee; color: #e74c3c; }

/* LAYOUT WRAPPER */
.wrapper {
    display: flex;
    margin-top: var(--nav-height);
    min-height: calc(100vh - var(--nav-height) - 40px);
}

/* Container Statistiche */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    text-align: center;
    border-bottom: 4px solid #ddd;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-desc {
    color: #777;
    font-size: 0.9rem;
    text-transform: uppercase;
    margin-top: 5px;
}

/* Colori stati */
.color-success { color: #27ae60; }
.color-warning { color: #f39c12; }
.color-danger { color: #e74c3c; }

/* Grid per le tabelle */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 25px;
}

.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    overflow: hidden;
}

.card-header {
    padding: 15px 20px;
    background: #fcfcfc;
    border-bottom: 1px solid #eee;
}

.card-header.border-danger { border-left: 5px solid #e74c3c; }

/* Tabelle */
.card-body { padding: 0; }
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 12px 20px;
    text-align: left;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
}

.data-table th { background: #fafafa; color: #666; }

/* Badge stili */
.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    color: white;
}
.badge-info { background: #3498db; }
.badge-warning { background: #f1c40f; color: #333; }
.badge-secondary { background: #95a5a6; }
.badge-danger { background: #e74c3c; }

/* Mobile Adjustments */
@media (max-width: 600px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .data-table th, .data-table td { padding: 8px 10px; font-size: 12px; }
}


/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary-color);
    color: white;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 999;
}

.sidebar.collapsed {
    margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-nav { list-style: none; padding: 20px 0; }
.sidebar-nav li a {
    display: flex;
    align-items: center;
    padding: 15px 25px;
    color: #bdc3c7;
    text-decoration: none;
    transition: 0.3s;
}

.sidebar-nav li a i { width: 30px; font-size: 1.1rem; }
.sidebar-nav li a:hover { background: #34495e; color: white; }

.sidebar-footer {
    padding: 20px;
    background: #1a252f;
    font-size: 13px;
}

/* CONTENT AREA */
.content {
    flex-grow: 1;
    padding: 30px;
    transition: all 0.3s ease;
}

/* FOOTER */
.footer-bottom {
    height: 40px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #777;
    border-top: 1px solid #ddd;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        height: 100%;
    }
    .sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-width)); }
    .sidebar:not(.collapsed) { margin-left: 0; }
}
