/**
 * assets/css/style.css
 * ----------------------------------------------------
 * Sezioni: 
 * 1. Variabili Globali
 * 2. Layout Generale e Correzioni Sidebar
 * 3. Sidebar (Navigazione Laterale)
 * 4. Header (Navigazione Superiore)
 * 5. Componenti (Card, Tabelle, Form, Bottoni)
 * 6. Footer
 * ----------------------------------------------------
 */

/* =================================
 * 1. VARIABILI GLOBALI E COLORI
 * ================================= */

:root {
    /* Colori Palette */
    --primary-color: #007bff;      /* Blu Metropolitano */
    --secondary-color: #6c757d;    /* Grigio Scuro Neutro */
    --success-color: #28a745;      /* Verde Brillante */
    --bg-light: #f4f7f9;           /* Sfondo Contenuto */
    --text-dark: #212529;          /* Testo Principale */
    
    /* Variabili Sidebar */
    --sidebar-width: 250px;
    --sidebar-min-width: 70px;
    --bg-color: #343a40;           /* Sfondo Sidebar */
    --nav-color: #adb5bd;          /* Testo Sidebar */
    --nav-hover-bg: #495057;       /* Hover Sidebar */
    --active-bg: #0056b3;          /* Hover Item Attivo */
    --header-bg: #212529;          /* Sfondo Header Sidebar */
}

/* =================================
 * 2. LAYOUT GENERALE E CORREZIONI SIDEBAR
 * (Risolve il problema del contenuto sotto la sidebar)
 * ================================= */
/* 1. Imposta l'altezza minima sul container principale (html e body) */

html, body {
    height: 100%;
    /* Modificato: Titillium Web come font principale */
    font-family: 'Titillium Web', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-dark);
    line-height: 1.6;
    margin: 0;
    padding: 0;
	font-size: 14px;
    background-color: var(--bg-light);
}


/* Contenitore principale del contenuto, allineato a destra della sidebar fissa */
#content-wrapper {
    /* PUSH KEY: Spinge il contenuto oltre la sidebar */
    margin-left: var(--sidebar-width); 
    padding: 20px 1.5rem;
    min-height: 100vh; /* Assicura che il contenuto copra l'altezza della viewport */
    transition: margin-left 0.3s ease-in-out;
}

/* Regole per la modalità Collapsed (sidebar ridotta) */
.collapsed #content-wrapper {
    /* Quando la sidebar si riduce, il contenuto si espande a sinistra */
    margin-left: var(--sidebar-min-width); 
}

/* Toggle Button per mobile/desktop (posizionato nel content-wrapper) */
#sidebar-toggle-btn {
    position: fixed;
    top: 15px;
    left: calc(var(--sidebar-width) + 15px);
    background: var(--primary-color);
    color: white;
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 5px;
    z-index: 1001;
    transition: left 0.3s ease-in-out;
}
.collapsed #sidebar-toggle-btn {
    /* Sposta il toggle button a sinistra con la sidebar ridotta */
    left: calc(var(--sidebar-min-width) + 15px);
}

/* Regola la spaziatura attorno ai titoli */
h2, h3 {
    color: var(--primary-color); 
    padding-bottom: 0.5rem;
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #e9ecef;
    font-weight: 700;
}

/* =================================
 * 3. SIDEBAR (NAVIGAZIONE LATERALE)
 * ================================= */

/* Base Sidebar */
#sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background-color: var(--bg-color);
    color: var(--nav-color);
    position: fixed;
    top: 0;
    left: 0;
    transition: width 0.3s ease-in-out;
    z-index: 1000;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

/* Header Sidebar */
.sidebar-header {
    padding: 20px 15px;
    background: var(--header-bg);
    border-bottom: 1px solid #495057;
    text-align: center;
}
.app-title {
    margin: 0 0 5px 0;
    color: white;
    font-size: 1.5em;
}
.user-role {
    margin: 0;
    font-size: 0.8em;
    color: var(--nav-color);
}

/* Navigazione */
.sidebar-nav {
    flex-grow: 1;
    padding: 10px 0;

}

/* Stile Generale Item */
.nav-item, .section-title {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    text-decoration: none;
    color: var(--nav-color);
    transition: background-color 0.2s, color 0.2s;
    cursor: pointer;
}

.nav-item:hover, .section-title:hover {
    background-color: var(--nav-hover-bg);
}

.nav-item.active {
    background-color: var(--primary-color);
    color: white;
}
.nav-item.active:hover {
    background-color: var(--active-bg);
}

/* Icone e Testo */
.icon {
    font-size: 1.2em;
    width: 30px; 
    text-align: center;
}
.text {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sezioni Espandibili */
.section-heading {
    color: #999;
    padding: 10px 15px;
    margin: 10px 0 5px 0;
    font-size: 0.8em;
    text-transform: uppercase;
    border-top: 1px solid #495057;
}
.section-title {
    justify-content: space-between;
}
.section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-in-out;
    background-color: #2c3136; 
}
.nav-section.expanded .section-content {
    max-height: 500px; 
}
.nav-section.expanded .arrow {
    transform: rotate(90deg);
}
.sub-item {
    padding-left: 45px; 
    font-size: 0.95em;
}
.arrow {
    transition: transform 0.3s;
}

/* Footer Sidebar (Logout) */
.sidebar-footer {
    padding: 10px 0;
    border-top: 1px solid #495057;
}
.sidebar-footer .logout {
    color: #ffc107;
}

/* Modalità Collapsed */
.collapsed #sidebar {
    width: var(--sidebar-min-width);
}
.collapsed .text,
.collapsed .user-role,
.collapsed .app-title,
.collapsed .section-heading,
.collapsed .arrow {
    display: none;
}
.collapsed .nav-item,
.collapsed .section-title {
    justify-content: center;
    padding: 12px 0;
}
.collapsed .icon {
    width: auto;
}

/* =================================
 * 4. HEADER (NAVIGAZIONE SUPERIORE)
 * ================================= */

.navbar-dark.bg-dark {
    /* Blu Metropolitano Scuro */
    background-color: #004a99 !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.navbar-brand {
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.nav-link {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9) !important;
    transition: all 0.3s ease;
}

.nav-link:hover {
    color: #ffffff !important;
    /* Aggiungi una piccola animazione di underline per l'hover */
    border-bottom: 2px solid #ffffff;
    padding-bottom: 4px;
}

/* =================================
 * 5. COMPONENTI (CARD, TABELLE, FORM, BOTTONI)
 * ================================= */

/* Card */
.card {
    border: 1px solid #dee2e6; 
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.card:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 1rem 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
}

/* Colori specifici delle card */
.card-header.bg-primary { background-color: #007bff !important; border-radius: 11px 11px 0 0 !important; font-weight: 700; color: white; }
.card-header.bg-success { background-color: #28a745 !important; color: white; }
.card-header.bg-info { background-color: #17a2b8 !important; color: white; }
.card-header.bg-warning { background-color: #ffc107 !important; color: var(--text-dark); }


/* Tabelle */
.table {
    margin-top: 15px;
    border-collapse: separate;
    border-spacing: 0 10px;
}
.table thead th {
    background-color: #e9ecef;
    color: #495057;
    border-bottom: none;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    padding: 10px 15px;
}
.table tbody tr {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.table tbody tr:hover {
    background-color: #fcfdfe;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
}


/* Form e Input */
.form-control, .form-select {
    border-radius: 8px; 
    border: 1px solid #ced4da;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(0, 123, 255, 0.25);
}


/* Pulsanti */
.btn {
    border-radius: 8px;
    font-weight: 600;
    padding: 0.5rem 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    transition: all 0.3s;
}
.btn-primary:hover {
    background-color: #0056b3; 
    border-color: #004a99;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}


/* Avvisi */
.alert {
    border-radius: 8px;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.alert-success { background-color: #d4edda; color: #155724; border-color: #c3e6cb; }
.alert-danger { background-color: #f8d7da; color: #721c24; border-color: #f5c6cb; }
.alert-warning { background-color: #fff3cd; color: #856404; border-color: #ffeeba; }
.alert-info { background-color: #d1ecf1; color: #0c5460; border-color: #bee5eb; }


/* =================================
 * 6. FOOTER
 * ================================= */


/* Stile base per lo Sticky Footer: estende la pagina */
html {
    position: relative;
    min-height: 100%; /* Garantisce che html copra l'intera altezza del viewport */
}

/* 2. Riserva spazio nel body per il footer */
body {
    /* Imposta un margin-bottom pari all'altezza del footer (120px in questo esempio) */
    margin-bottom: 120px; 
}

/* 3. Posizionamento e Stilizzazione del Footer */
.footer {
    /* La proprietà 'position: relative' è corretta per posizionarlo nel flusso del documento */
    position: relative; 
    width: 100%;
    
    /* Questa riga solleva il footer nel margine riservato del body */
    margin-top: -120px; /* DEVE corrispondere al margin-bottom del body */
    
    /* Altezza del footer, necessaria per il calcolo del margine */
    height: 120px; 

    /* Rimuovi o imposta a 'auto' se presente */
    /* bottom: 0; */ 
    
    /* Stili visivi */
    background-color: #f8f9fa;
    border-top: 1px solid #e9ecef;
    z-index: 100;
    box-shadow: none; 
    color: #495057; 
}

.footer h6 {
    color: var(--primary-color) !important;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}
.footer a {
    color: var(--primary-color);
    font-weight: 500;
}
.footer a:hover {
    color: #0056b3;
}
.footer .list-unstyled a {
    color: #6c757d !important; 
    font-weight: 400;
    transition: color 0.2s ease;
}
.footer .list-unstyled a:hover {
    color: var(--primary-color) !important;
}
.footer .text-muted.small {
    font-size: 0.75rem;
    color: #adb5bd !important;
}