/* --- CONFIGURAZIONE BASE --- */
:root {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-color: #e0e0e0;
    --accent-color: #bb86fc;
    --danger-color: #d32f2f;
    --success-color: #27ae60;
}

* { box-sizing: border-box; }

body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
    background-color: var(--bg-color); 
    color: var(--text-color);
    margin: 0; 
    padding-bottom: 90px;
}

/* --- LAYOUT & BOX --- */
.box { background-color: var(--card-bg); padding: 20px; border-radius: 12px; margin: 15px; }
.header { text-align: center; padding: 20px; margin-bottom: 20px; }
.logo { max-width: 150px; height: auto; display: block; margin: 0 auto; }

/* --- GRIGLIE & DASHBOARD --- */
.dashboard-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); 
    gap: 20px; 
    padding: 20px;
    max-width: 900px;
    margin: 0 auto;
}

.card { 
    background: var(--card-bg); 
    padding: 25px; 
    border-radius: 16px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    border-top: 5px solid var(--accent-color);
    text-align: center;
    transition: 0.3s;
}
.card:hover { transform: translateY(-5px); box-shadow: 0 8px 20px rgba(0,0,0,0.2); }
.card a { text-decoration: none; font-weight: bold; color: var(--text-color); display: block; font-size: 1.1em; }

/* --- FORM & INPUT --- */
input, select { 
    width: 100%; padding: 12px; margin: 8px 0; 
    background: #2c2c2c; color: white; 
    border: 1px solid #444; border-radius: 8px; font-size: 16px; 
}
.input-ok { border: 2px solid #2e7d32 !important; box-shadow: 0 0 5px rgba(46, 125, 50, 0.5) !important; }
.input-error { border: 2px solid #c62828 !important; box-shadow: 0 0 5px rgba(198, 40, 40, 0.5) !important; }

/* --- PULSANTI --- */
.btn-salva { width: 100%; border: none; padding: 16px; border-radius: 8px; font-weight: bold; margin-top: 15px; cursor: pointer; color: white; }
.btn-success { background-color: var(--success-color); }
.btn-edit { background-color: #1976d2; }
.btn-add-cantiere { background:#555; color:white; border:none; padding:10px; width:100%; margin-top:10px; border-radius:8px; cursor: pointer; }
.btn-modifica { padding: 10px; background: #e0e0e0; text-decoration:none; color:black; border-radius:5px; font-size: 0.9em; }
.btn-elimina { padding: 10px; background: #ffebee; text-decoration:none; color: var(--danger-color); border-radius:5px; font-size: 0.9em; }

/* --- STORICO --- */
.box-riepilogo { background: #333; padding: 15px; border-radius: 8px; margin-bottom: 20px; border: 1px solid #ddd; }
.giornata-card { border: 1px solid #ddd; margin-bottom: 10px; padding: 15px; border-radius: 8px; background: var(--card-bg); }
.giornata-header { cursor: pointer; padding: 5px; }
.giornata-info { display: flex; justify-content: space-between; font-size: 1.1em; }
.dettagli-giornata { margin-top: 15px; padding-top: 10px; border-top: 1px solid #eee; }
.btn-azione-container { margin-top: 15px; display: flex; gap: 15px; }
.hidden { display: none; }

/* --- NAVBAR --- */
.navbar {
    position: fixed; bottom: 0; left: 0; width: 100%; background: #000;
    display: flex; justify-content: space-around; padding: 15px 0;
    border-top: 1px solid #444; z-index: 9999;
}
.navbar a { text-decoration: none; color: #888; font-size: 14px; }
.navbar a.active { color: var(--accent-color); font-weight: bold; }



    /* Stile base tabella */
.table-container {
    overflow-x: auto; /* Mantiene la compatibilità mobile */
    margin-top: 20px;
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #181818;
    border-radius: 8px;
    overflow: hidden;
    table-layout: auto;
}

/* Migliora la leggibilità su monitor */
th {
    background: #252525;
    padding: 12px 15px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #bbb;
    position: sticky;
    top: 0;
    z-index: 10;
}

td {
    padding: 10px 15px;
    border-bottom: 1px solid #333;
    font-size: 0.95rem;
}

/* Effetto riga (molto utile su PC) */
tr:hover {
    background-color: #2a2a2a;
    transition: background 0.2s ease;
}

/* Colonna ore (allineata a destra, più leggibile) */
td:last-child {
    text-align: right;
    font-weight: bold;
    color: #4CAF50; /* Un tocco di colore verde per le ore */
}

tr:nth-child(even) { background-color: #1a1a1a; }



/* --- MESSAGGI FLASH --- */
.flash-msg { 
    padding: 15px; border: 1px solid; border-radius: 8px; 
    margin-bottom: 20px; text-align: center; font-weight: bold; cursor: pointer; 
}
.flash-success { background: #e8f5e9; color: #2e7d32; border-color: #2e7d32; }
.flash-danger { background: #ffebee; color: #c62828; border-color: #c62828; }

/* --- OTTIMIZZAZIONI DASHBOARD --- */
.card-full { grid-column: 1 / -1; }

/* Assicuriamoci che i bordi delle card siano visibili */
.border-action { border-top-color: #3498db; }
.border-admin  { border-top-color: #e67e22; }
.border-danger { border-top-color: var(--danger-color); }

/* --- LOGIN PAGE --- */
.login-card { 
    max-width: 350px; 
    margin: 0 auto; 
    text-align: left; 
    border-top: 5px solid var(--accent-color);
}
.login-title { text-align: center; margin-top: 0; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; color: var(--text-color); }

/* --- HEADER PULITO --- */
.main-header {
    background: #000;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between; /* spinge verso i lati  */
    align-items: center;
    border-bottom: 2px solid #444;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-container img {
    width: 40px; /* Dimensione fissa piccola per l'header */
    height: 40px;
    border-radius: 5px;
}

.user-info {
    font-size: 0.9em;
    text-align: right;
}

/* --- GESTIONE UTENTI E TABELLE --- */
.table-utenti { width: 100%; border-collapse: collapse; margin-top: 10px; }
.table-utenti td { border-bottom: 1px solid #333; padding: 12px 5px; }
.text-muted { color: #888; }

/* Bottoni di azione piccoli */
.btn-group-actions { display: flex; gap: 5px; justify-content: flex-end; }
.btn-small { 
    padding: 5px 10px; border: none; border-radius: 4px; 
    cursor: pointer; color: white; font-size: 11px; text-decoration: none; 
}
.btn-blue { background: #1976d2; }
.btn-red { background: #d32f2f; }

.link-back { display: block; text-align: center; margin-top: 20px; color: #888; text-decoration: none; }

/* Stile per i form nelle impostazioni */
.box { 
    background: #1e1e1e; 
    padding: 20px; 
    border-radius: 12px; 
    border: 1px solid #333; 
    max-width: 400px; 
    margin: 20px auto; 
    color: #e0e0e0;
}

label { display: block; margin-top: 10px; font-size: 0.9em; }

input { 
    width: 100%; padding: 10px; margin-top: 5px; 
    background: #2c2c2c; border: 1px solid #444; 
    color: white; border-radius: 6px; box-sizing: border-box; 
}

.btn-salva { 
    background: #2e7d32; border: none; padding: 10px; 
    border-radius: 6px; color: white; cursor: pointer; 
}

.info-box { 
    margin-top: 30px; border-top: 1px solid #444; 
    padding-top: 20px; color: #888; font-size: 0.85em; text-align: center;
}

/* Stile per il menu di ordinamento */
.filter-bar { margin-bottom: 20px; }
.filter-bar select {
    width: 100%;
    padding: 10px;
    background: #2c2c2c;
    color: white;
    border: 1px solid #444;
    border-radius: 6px;
}

/* Stile per la tabella */
table { 
    width: 100%; 
    border-collapse: collapse; 
    margin-top: 10px; 
    font-size: 0.9em; 
}
th { 
    background: #252525; 
    color: #aaa; 
    padding: 12px; 
    text-align: left; 
    border-bottom: 2px solid #444; 
}
td { 
    padding: 12px; 
    border-bottom: 1px solid #333; 
}
tr:hover { background: #252525; }

/* Stili per la pagina gestione_cantieri */
.box { 
    background: #1e1e1e; 
    padding: 20px; 
    border-radius: 12px; 
    margin-top: 20px;
}

.table-dark { 
    background-color: #1e1e1e !important; 
    color: #e0e0e0; 
}

/* --- MEDIA QUERY --- */
@media (min-width: 768px) {
    input[name="ore_cantieri[]"], select, input[type="time"] {
        padding: 15px 20px !important;
        font-size: 1.1rem;
    }
    .container {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 20px;
    }
    /* Media Query per rendere la tabella leggibile su dispositivi diversi */
    .table-responsive {
        font-size: 0.85rem; /* Rimpicciolisce il testo su mobile */
    }
} /* <--- CHIUSURA CORRETTA DELLA MEDIA QUERY A 768px */

/* STAMPA: FUORI dalle altre media query */
@media print {
    .navbar, .btn, .btn-salva, .btn-modifica, .btn-elimina, .no-print, .filter-bar, .link-back { 
        display: none !important; 
    }
    
    body { background: white !important; color: black !important; padding: 0 !important; }
    
    .box, table { 
        background: white !important; 
        color: black !important; 
        border: 1px solid #ccc !important; 
        width: 100% !important; 
        margin: 0 !important; 
    }
    .container { width: 100% !important; max-width: 100% !important; margin: 0 !important; }
    .scheda-cantiere { border: none !important; box-shadow: none !important; }
    
    th { background: #eee !important; color: black !important; }
    
    /* Forza la visibilità delle note se sono in un div */
    .note-stampa { display: block !important; }


}
/* --- GESTIONE RESPONSIVE PROGRAMMAZIONE --- */
@media (max-width: 767.98px) {
    .vista-pc { display: none !important; }
    .vista-mobile { display: block !important; }
}

@media (min-width: 768px) {
    .vista-pc { display: block !important; }
    .vista-mobile { display: none !important; }
}