/* =================================================================ati
   CONFIGURAZIONE BASE & VARIABILI
   ========================================================================== */
: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 & STRUTTURA GENERALE
   ========================================================================== */
.box { 
    background-color: var(--card-bg); 
    padding: 20px; 
    border-radius: 12px; 
    border: 1px solid #333; 
    margin: 15px auto; 
    max-width: 900px;
}

.header { 
    text-align: center; 
    padding: 20px; 
    margin-bottom: 20px; 
}

.logo { 
    max-width: 150px; 
    height: auto; 
    display: block; 
    margin: 0 auto; 
}

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

.hidden { 
    display: none !important; 
}

/* ==========================================================================
   HEADER PRINCIPALE & NAVBAR
   ========================================================================== */
.main-header {
    background: #000;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #444;
}

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

.logo-container img {
    width: 40px;
    height: 40px;
    border-radius: 5px;
}

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

.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; 
}

/* ==========================================================================
   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; 
}

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

.border-action { border-top-color: #3498db; }
.border-admin  { border-top-color: #e67e22; }
.border-danger { border-top-color: var(--danger-color); }

/* ==========================================================================
   FORM, INPUT & ETICHETTE
   ========================================================================== */
.form-group { 
    margin-bottom: 15px; 
}

label { 
    display: block; 
    margin-top: 10px; 
    margin-bottom: 5px;
    font-size: 0.9em; 
    color: var(--text-color);
}

input, select { 
    width: 100%; 
    padding: 12px; 
    margin: 8px 0; 
    background: #2c2c2c; 
    color: white; 
    border: 1px solid #444; 
    border-radius: 8px; 
    font-size: 16px; 
    box-sizing: border-box;
}

.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; 
}

.filter-bar { 
    margin-bottom: 20px; 
}

.filter-bar select {
    width: 100%;
    padding: 10px;
    background: #2c2c2c;
    color: white;
    border: 1px solid #444;
    border-radius: 6px;
}

/* ==========================================================================
   PULSANTI
   ========================================================================== */
.btn-salva { 
    width: 100%; 
    border: none; 
    padding: 16px; 
    border-radius: 8px; 
    font-weight: bold; 
    margin-top: 15px; 
    cursor: pointer; 
    color: white; 
    background-color: var(--success-color); 
}

.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; 
}

.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; }

/* ==========================================================================
   TABELLE & DATI
   ========================================================================== */
.table-container {
    overflow-x: auto;
    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;
    margin-top: 10px;
    font-size: 0.9em;
}

th {
    background: #252525;
    padding: 12px 15px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #aaa;
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 2px solid #444;
}

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

tr:hover { 
    background-color: #2a2a2a; 
    transition: background 0.2s ease; 
}

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

/* Specifico per tabelle utente o scure particolari */
.table-utenti { 
    width: 100%; 
    border-collapse: collapse; 
    margin-top: 10px; 
}

.table-utenti td { 
    border-bottom: 1px solid #333; 
    padding: 12px 5px; 
}

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

/* Colonna ore (allineata a destra con accento verde) */
td:last-child {
    text-align: right;
    font-weight: bold;
    color: #4CAF50;
}

/* ==========================================================================
   STORICO & SEZIONI GIORNATA
   ========================================================================== */
.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; 
}

/* ==========================================================================
   MESSAGGI FLASH & INFO
   ========================================================================== */
.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; 
}

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

.text-muted { 
    color: #888; 
}

/* ==========================================================================
   PAGINA DI LOGIN
   ========================================================================== */
.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; 
}

/* ==========================================================================
   MEDIA QUERIES (RESPONSIVE & STAMPA)
   ========================================================================== */
@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; }
    .box {
        max-width: 1200px;
        width: 92%;
    }
    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;
    }
    
    .table-responsive {
        font-size: 0.85rem;
    }
}

@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; 
    }
    
    .note-stampa { 
        display: block !important; 
    }
}