/**
 * IDESVI — Elenco: stile moderno
 * ============================================================
 * Da includere in index.php dopo gli altri CSS:
 *   <link rel="stylesheet" href="assets/css/elenco.css">
 * ============================================================
 */

/* ============================================================
   CONTENITORE PRINCIPALE
   ============================================================ */

#lista_tabella {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.10);
    overflow: hidden;
    border: 1px solid #e0e6ed;
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 13px;
}


/* ============================================================
   TOOLBAR BOTTONI
   ============================================================ */

#toolbar_elenco {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #2c3e50 0%, #3d5166 100%);
    border-bottom: 1px solid #1a252f;
    flex-wrap: wrap;
}

/* Separatore tra gruppi di bottoni */
.btn-group-elenco {
    display: flex;
    gap: 4px;
    align-items: center;
}

.btn-sep-elenco {
    width: 1px;
    height: 26px;
    background: rgba(255,255,255,0.2);
    margin: 0 4px;
}

/* Bottone base */
.btn-elenco {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border: none;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    white-space: nowrap;
    color: #fff;
    background: rgba(255,255,255,0.12);
    letter-spacing: 0.2px;
}

.btn-elenco:hover {
    background: rgba(255,255,255,0.22);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.20);
}

.btn-elenco:active {
    transform: translateY(0);
    box-shadow: none;
}

/* Varianti colore */
.btn-elenco.verde    { background: #27ae60; }
.btn-elenco.verde:hover { background: #219a52; }

.btn-elenco.rosso    { background: #e74c3c; }
.btn-elenco.rosso:hover { background: #c0392b; }

.btn-elenco.blu      { background: #2980b9; }
.btn-elenco.blu:hover { background: #2471a3; }

.btn-elenco.arancio  { background: #e67e22; }
.btn-elenco.arancio:hover { background: #ca6f1e; }

.btn-elenco.grigio   { background: rgba(255,255,255,0.08); }
.btn-elenco.grigio:hover { background: rgba(255,255,255,0.18); }

/* Bottone ristampa — nascosto di default */
#btn_ristampa_tabella {
    visibility: hidden;
}

/* Label pagina attiva nella toolbar */
#label_pagina_elenco {
    margin-left: auto;
    font-size: 11px;
    color: rgba(255,255,255,0.55);
    font-style: italic;
    white-space: nowrap;
}


/* ============================================================
   WRAPPER TABELLA (scrollabile)
   ============================================================ */

#wrapper_tabella {
    overflow-y: auto;
    overflow-x: auto;
    flex: 1;
    /* L'altezza viene impostata via JS (DIMheight) */
}

/* Scrollbar moderna */
#wrapper_tabella::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}
#wrapper_tabella::-webkit-scrollbar-track {
    background: #f1f1f1;
}
#wrapper_tabella::-webkit-scrollbar-thumb {
    background: #bdc3c7;
    border-radius: 4px;
}
#wrapper_tabella::-webkit-scrollbar-thumb:hover {
    background: #95a5a6;
}


/* ============================================================
   TABELLA
   ============================================================ */

#tabella_elenco {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

/* TESTATA FISSA — sticky con z-index */
#tabella_elenco thead th {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #f0f4f8;
    color: #2c3e50;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 12px;
    border-bottom: 2px solid #d0d9e3;
    border-right: 1px solid #dde3ea;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

#tabella_elenco thead th:last-child {
    border-right: none;
}

#tabella_elenco thead th:hover {
    background: #e3eaf2;
}

/* Icona ordinamento nell'intestazione */
#tabella_elenco thead th .sort-icon {
    display: inline-block;
    margin-left: 4px;
    opacity: 0.4;
    font-size: 10px;
}
#tabella_elenco thead th.sorted-asc  .sort-icon,
#tabella_elenco thead th.sorted-desc .sort-icon {
    opacity: 1;
    color: #2980b9;
}

/* RIGHE BODY */
#tabella_elenco tbody tr {
    cursor: pointer;
    transition: background 0.12s;
    border-bottom: 1px solid #edf0f4;
}

#tabella_elenco tbody tr:last-child {
    border-bottom: none;
}

/* Riga pari/dispari */
#tabella_elenco tbody tr:nth-child(even) {
    background: #fafbfc;
}
#tabella_elenco tbody tr:nth-child(odd) {
    background: #ffffff;
}

/* Hover riga */
#tabella_elenco tbody tr:hover {
    background: #eaf3fb !important;
}

/* Riga selezionata (checkbox spuntato) */
#tabella_elenco tbody tr.riga-selezionata {
    background: #d6eaf8 !important;
    border-left: 3px solid #2980b9;
}

/* Celle */
#tabella_elenco tbody td {
    padding: 8px 12px;
    color: #34495e;
    font-size: 13px;
    border-right: 1px solid #edf0f4;
    vertical-align: middle;
}

#tabella_elenco tbody td:last-child {
    border-right: none;
}

/* Celle numeriche (allineate a destra) */
#tabella_elenco tbody td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: 'Courier New', monospace;
}

/* Prima colonna (N.) */
#tabella_elenco thead th:first-child,
#tabella_elenco tbody td:first-child {
    text-align: center;
    width: 40px;
    color: #95a5a6;
    font-size: 11px;
}

/* Colonna checkbox */
#tabella_elenco td input[type="checkbox"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: #2980b9;
}

/* Icona azioni sulla riga */
#tabella_elenco td .fa {
    color: #7f8c8d;
    transition: color 0.15s;
}
#tabella_elenco tr:hover td .fa {
    color: #2980b9;
}


/* ============================================================
   RIGA TOTALI (in fondo alla tabella)
   ============================================================ */

#tabella_elenco tfoot td {
    padding: 9px 12px;
    background: #eaf0f6;
    font-weight: 700;
    font-size: 13px;
    color: #2c3e50;
    border-top: 2px solid #c8d6e5;
    position: sticky;
    bottom: 0;
    z-index: 10;
}


/* ============================================================
   BARRA STATO / CONTATORE RIGHE
   ============================================================ */

#statusbar_elenco {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px;
    background: #f8f9fa;
    border-top: 1px solid #e0e6ed;
    font-size: 11px;
    color: #7f8c8d;
}

#statusbar_elenco .contatore {
    font-weight: 600;
    color: #2c3e50;
}

#statusbar_elenco .hint {
    font-style: italic;
}


/* ============================================================
   PANNELLO FILTRI (popup colonna)
   ============================================================ */

#filtri_tabella {
    position: fixed;
    z-index: 1050;
    background: #ffffff;
    border: 1px solid #d0d9e3;
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.15);
    padding: 14px;
    min-width: 220px;
    max-width: 300px;
}

#titolo_filtro {
    font-size: 12px;
    color: #2c3e50;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #edf0f4;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#filtri_tabella input[type="text"],
#filtri_tabella input[type="number"],
#filtri_tabella select {
    width: 100%;
    padding: 6px 9px;
    border: 1px solid #d0d9e3;
    border-radius: 5px;
    font-size: 12px;
    color: #2c3e50;
    background: #f8f9fa;
    transition: border-color 0.15s;
    box-sizing: border-box;
    margin-bottom: 6px;
}

#filtri_tabella input:focus,
#filtri_tabella select:focus {
    border-color: #2980b9;
    outline: none;
    background: #fff;
}

.btn-chiudi-filtro {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    font-size: 16px;
    color: #bdc3c7;
    cursor: pointer;
    line-height: 1;
    padding: 2px 5px;
    border-radius: 3px;
}
.btn-chiudi-filtro:hover {
    color: #e74c3c;
    background: #fdf2f0;
}

.btn-applica-filtro {
    width: 100%;
    margin-top: 8px;
    padding: 7px;
    background: #2980b9;
    color: #fff;
    border: none;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-applica-filtro:hover {
    background: #2471a3;
}


/* ============================================================
   PANNELLO ORDINAMENTO COLONNE
   ============================================================ */

#seq_tabella {
    position: fixed;
    z-index: 1050;
    background: #ffffff;
    border: 1px solid #d0d9e3;
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.15);
    padding: 14px;
    min-width: 240px;
}

#seq_tabella .titolo-seq {
    font-size: 12px;
    font-weight: 700;
    color: #2c3e50;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #edf0f4;
}


/* ============================================================
   STATO VUOTO / ERRORE
   ============================================================ */

.elenco-vuoto {
    text-align: center;
    padding: 50px 20px;
    color: #95a5a6;
}

.elenco-vuoto .fa {
    font-size: 42px;
    margin-bottom: 14px;
    display: block;
    opacity: 0.35;
}

.elenco-vuoto p {
    font-size: 14px;
    margin: 0;
}

.elenco-errore {
    text-align: center;
    padding: 20px;
    color: #e74c3c;
    font-size: 13px;
}


/* ============================================================
   LOADER
   ============================================================ */

#img_load {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
    background: rgba(255,255,255,0.85);
    padding: 18px 24px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    font-size: 13px;
    color: #2c3e50;
    display: none;
    align-items: center;
    gap: 10px;
}


/* ============================================================
   RESPONSIVE — schermi piccoli
   ============================================================ */

@media (max-width: 768px) {
    #toolbar_elenco {
        gap: 4px;
        padding: 8px 10px;
    }

    .btn-elenco {
        padding: 5px 8px;
        font-size: 11px;
    }

    .btn-elenco span.label-btn {
        display: none;  /* nasconde testo, mostra solo icona */
    }

    #tabella_elenco thead th,
    #tabella_elenco tbody td {
        padding: 7px 8px;
        font-size: 12px;
    }
}
