/* ============================================================
   MODULO PRESENZE – Stili griglia cartellino
   ============================================================ */

/* ---- Layout principale ---- */
#view-presenze {
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.pres-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 16px 20px;
    gap: 16px;
    overflow: hidden;
}

/* ---- Toolbar ---- */
.pres-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.pres-toolbar .pres-select {
    background: #1e1e2e;
    border: 1px solid #313244;
    border-radius: 8px;
    color: #cdd6f4;
    padding: 8px 14px;
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    min-width: 220px;
    transition: border-color 0.2s;
}
.pres-select:focus {
    border-color: #89b4fa;
    outline: none;
}

.pres-nav-btn {
    background: #1e1e2e;
    border: 1px solid #313244;
    border-radius: 8px;
    color: #cdd6f4;
    padding: 8px 14px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.pres-nav-btn:hover {
    background: #313244;
    border-color: #89b4fa;
    color: #89b4fa;
}

.pres-month-label {
    font-size: 1.1rem;
    font-weight: 800;
    color: #cdd6f4;
    min-width: 160px;
    text-align: center;
    letter-spacing: -0.5px;
}

.pres-spacer { flex: 1; }

.pres-btn {
    background: linear-gradient(135deg, #89b4fa, #74c7ec);
    color: #1e1e2e;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Inter', sans-serif;
}
.pres-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(137, 180, 250, 0.3);
}
.pres-btn.secondary {
    background: #313244;
    color: #cdd6f4;
}
.pres-btn.secondary:hover {
    background: #45475a;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* ---- Tabs: Cartellino / Riepilogo / Dipendenti ---- */
.pres-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #313244;
    flex-shrink: 0;
}
.pres-tab {
    padding: 8px 18px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #6c7086;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -2px;
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    gap: 6px;
}
.pres-tab:hover { color: #cdd6f4; }
.pres-tab.active {
    color: #89b4fa;
    border-bottom-color: #89b4fa;
}

/* ---- Pannelli tab ---- */
.pres-panel { display: none; flex: 1; overflow: auto; }
.pres-panel.active { display: flex; flex-direction: column; }

/* ---- Wrapper griglia scrollabile ---- */
.pres-grid-wrap {
    flex: 1;
    overflow: auto;
    border-radius: 12px;
    border: 1px solid #313244;
}

/* ---- GRIGLIA CARTELLINO ---- */
.pres-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.76rem;
    font-family: 'Inter', sans-serif;
}

/* Header giorni */
.pres-table thead th {
    background: #181825;
    color: #7f849c;
    font-size: 0.65rem;
    font-weight: 800;
    text-align: center;
    padding: 4px 0.5px;
    border-bottom: 2px solid #313244;
    border-right: 1px solid #313244;
    min-width: 22px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
    letter-spacing: 0px;
}
.pres-table thead th.col-label {
    min-width: 55px;
    max-width: 65px;
    text-align: center;
    padding: 4px;
    position: sticky;
    left: 0;
    z-index: 20;
}
.pres-table thead th.col-totale {
    min-width: 45px;
    background: #1e1e2e;
    color: #89b4fa;
    font-size: 0.65rem;
    position: sticky;
    right: 0;
    z-index: 10;
}

/* Giorni weekend / festivi */
.pres-table th.day-weekend,
.pres-table td.day-weekend {
    background: #181825 !important;
    color: #45475a !important;
}
.pres-table th.day-festivo,
.pres-table td.day-festivo {
    background: #1c1c2a !important;
    color: #585b70 !important;
}
.pres-table th.day-sun { color: #f38ba8 !important; }
.pres-table th.day-sat { color: #fab387 !important; }

/* Righe evento */
.pres-table tbody tr {
    transition: background 0.1s;
}
.pres-table tbody tr:hover {
    background: rgba(137, 180, 250, 0.03);
}
.pres-table tbody td {
    border-right: 1px solid #20202c;
    border-bottom: 1px solid #20202c;
    padding: 0;
    text-align: center;
    vertical-align: middle;
}
.pres-table tbody td.col-label {
    position: sticky;
    left: 0;
    background: #1e1e2e;
    z-index: 5;
    padding: 4px;
    text-align: center;
    font-weight: 800;
    white-space: nowrap;
    border-right: 2px solid #313244;
    min-width: 55px;
    max-width: 65px;
}
.pres-table tbody td.col-totale {
    position: sticky;
    right: 0;
    background: #1e1e2e;
    font-weight: 800;
    color: #89b4fa;
    font-size: 0.78rem;
    padding: 2px;
    border-left: 2px solid #313244;
    z-index: 5;
}

/* Pallino colore evento */
.ev-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 4px;
    flex-shrink: 0;
}
.ev-label-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Input cella ore */
.pres-cell-input {
    width: 100%;
    max-width: 24px;
    background: transparent;
    border: none;
    color: #cdd6f4;
    font-size: 0.74rem;
    font-family: 'Inter', monospace;
    font-weight: 700;
    text-align: center;
    padding: 4px 1px;
    outline: none;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
}
.pres-cell-input:focus {
    background: rgba(137, 180, 250, 0.08);
    color: #89b4fa;
    border-radius: 3px;
}
.pres-cell-input:hover:not(:focus) {
    background: rgba(255,255,255,0.04);
    border-radius: 3px;
}
/* Cella con valore > 0 */
.pres-cell-input.has-value {
    font-weight: 900;
}
/* Celle weekend/festivi: disabilita input */
.pres-cell-input.locked {
    color: #45475a;
    cursor: not-allowed;
    pointer-events: none;
}

/* Riga ore teoriche (fondo) */
.row-teoriche td {
    background: #181825;
    color: #585b70;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 4px;
}
.row-teoriche td.col-label {
    color: #7f849c;
    font-weight: 800;
    background: #181825;
    text-align: center;
    padding: 4px;
    min-width: 55px;
    max-width: 65px;
}

/* ---- RIEPILOGO MENSILE ---- */
.pres-riepilogo-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.pres-riepilogo-table thead th {
    background: #181825;
    color: #89b4fa;
    font-weight: 800;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 2px solid #313244;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.pres-riepilogo-table tbody tr {
    border-bottom: 1px solid #20202c;
    transition: background 0.1s;
}
.pres-riepilogo-table tbody tr:hover { background: rgba(137, 180, 250, 0.04); }
.pres-riepilogo-table tbody td {
    padding: 10px 14px;
    color: #cdd6f4;
    vertical-align: middle;
}
.pres-riepilogo-table tbody td.nome-col {
    font-weight: 700;
    color: #f1f1f1;
}

/* Pillole riepilogo */
.pres-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    margin: 2px;
    background: rgba(137, 180, 250, 0.12);
    color: #89b4fa;
}

/* ---- GESTIONE DIPENDENTI ---- */
.pres-dip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    padding: 16px;
}
.pres-dip-card {
    background: #1e1e2e;
    border: 1px solid #313244;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.2s;
    cursor: pointer;
}
.pres-dip-card:hover {
    border-color: #89b4fa;
    box-shadow: 0 4px 16px rgba(137, 180, 250, 0.1);
    transform: translateY(-1px);
}
.pres-dip-name {
    font-size: 1rem;
    font-weight: 800;
    color: #f1f1f1;
}
.pres-dip-meta {
    font-size: 0.78rem;
    color: #7f849c;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.pres-dip-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}
.pres-dip-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

/* ---- Form dipendente ---- */
.pres-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    padding: 20px;
}
.pres-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.pres-form-group label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #7f849c;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.pres-form-group input,
.pres-form-group select,
.pres-form-group textarea {
    background: #181825;
    border: 1px solid #313244;
    border-radius: 8px;
    color: #cdd6f4;
    padding: 9px 12px;
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    transition: border-color 0.2s;
    width: 100%;
    box-sizing: border-box;
}
.pres-form-group input:focus,
.pres-form-group select:focus,
.pres-form-group textarea:focus {
    border-color: #89b4fa;
    outline: none;
    background: #1e1e2e;
}

/* Loader */
.pres-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: #7f849c;
    gap: 12px;
    font-size: 1rem;
}

/* Highlight "oggi" */
.pres-table th.day-today {
    background: rgba(137, 180, 250, 0.15) !important;
    color: #89b4fa !important;
    border-bottom: 2px solid #89b4fa !important;
}
.pres-table td.day-today {
    background: rgba(137, 180, 250, 0.04);
}

/* Toast save feedback */
.pres-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #a6e3a1;
    color: #1e1e2e;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 800;
    font-size: 0.88rem;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    animation: pres-toast-in 0.3s ease;
}
@keyframes pres-toast-in {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* Sfondi differenziati per Ferie, Malattia e Ore Lavorate */
.pres-table tr[data-codice="FP"] td:not(.col-label):not(.col-totale) {
    background: rgba(137, 180, 250, 0.08) !important;
}
.pres-table tr[data-codice="FP"] .pres-cell-input {
    background: rgba(137, 180, 250, 0.05);
    color: #89b4fa !important;
}

.pres-table tr[data-codice="M1"] td:not(.col-label):not(.col-totale) {
    background: rgba(243, 139, 168, 0.08) !important;
}
.pres-table tr[data-codice="M1"] .pres-cell-input {
    background: rgba(243, 139, 168, 0.05);
    color: #f38ba8 !important;
}

/* Sfondo riga ore di lavoro (in fondo) */
.pres-table tr.row-teoriche:nth-last-child(1) {
    background: rgba(166, 227, 161, 0.08) !important;
}
.pres-table tr.row-teoriche:nth-last-child(1) td {
    color: #a6e3a1 !important;
}
