/*
    OODataTable - sticky header / frozen columns support

    - .oo-sticky-head: applicata al div contenitore (overflow) della tabella, blocca il <thead>
      durante lo scorrimento verticale (position: sticky sui th).
    - .oo-frozen-K (K = 1..7): blocca le prime K celle (colonne di servizio + colonne dati)
      durante lo scorrimento orizzontale. Gli offset orizzontali cumulativi sono pubblicati
      dal client js (OODataTable.js) come variabili CSS --oo-fz-0 .. --oo-fz-6 sul contenitore.
    - Le celle sticky richiedono sfondi OPACHI: le varianti striped/hover/active/dark impostano
      la variabile --oo-fz-bg a livello di riga/tabella con i colori Bootstrap 4 pre-miscelati.
    - :not([colspan]) esclude le righe speciali (blocco rendering, dettagli riga) dal blocco colonne.
    - I selettori sono ancorati con "> table >" per non influenzare eventuali tabelle annidate
      nei template delle celle.
*/

/* ==================== Sticky header ==================== */

.oo-sticky-head > table > thead > tr > th {
    position: sticky;
    top: 0;
    z-index: 3;
    background-color: var(--oo-fz-bg-head, #fff);
    /* Il bordo inferiore dell'header non segue lo sticky: lo si simula con un'ombra interna */
    box-shadow: inset 0 -1px 0 #dee2e6;
}

/* ==================== Variabili di sfondo opaco (varianti Bootstrap 4) ==================== */

.oo-sticky-head > table.table-dark,
[class*="oo-frozen-"] > table.table-dark {
    --oo-fz-bg-head: #343a40;
    --oo-fz-bg: #343a40;
}

[class*="oo-frozen-"] > table.table-striped > tbody > tr:nth-of-type(odd) {
    --oo-fz-bg: #f2f2f2;    /* rgba(0,0,0,.05) su bianco */
}

[class*="oo-frozen-"] > table.table-dark.table-striped > tbody > tr:nth-of-type(odd) {
    --oo-fz-bg: #3e444a;    /* rgba(255,255,255,.05) su #343a40 */
}

[class*="oo-frozen-"] > table > tbody > tr.table-active {
    --oo-fz-bg: #ececec;    /* rgba(0,0,0,.075) su bianco (ROW_SELECTED_CLASS) */
}

[class*="oo-frozen-"] > table.table-dark > tbody > tr.table-active {
    --oo-fz-bg: #4b545c;
}

[class*="oo-frozen-"] > table.table-hover > tbody > tr:hover {
    --oo-fz-bg: #ececec;    /* rgba(0,0,0,.075) su bianco */
}

[class*="oo-frozen-"] > table.table-dark.table-hover > tbody > tr:hover {
    --oo-fz-bg: #494f55;
}

/* ==================== Offset orizzontali delle celle bloccate ==================== */
/* Applicati per indice di cella: hanno effetto solo sulle celle rese sticky dalle regole .oo-frozen-K */

[class*="oo-frozen-"] > table > thead > tr > th:nth-child(1),
[class*="oo-frozen-"] > table > tbody > tr > td:nth-child(1):not([colspan]),
[class*="oo-frozen-"] > table > tbody > tr > th:nth-child(1):not([colspan]) { left: var(--oo-fz-0, 0px); }

[class*="oo-frozen-"] > table > thead > tr > th:nth-child(2),
[class*="oo-frozen-"] > table > tbody > tr > td:nth-child(2):not([colspan]),
[class*="oo-frozen-"] > table > tbody > tr > th:nth-child(2):not([colspan]) { left: var(--oo-fz-1, 0px); }

[class*="oo-frozen-"] > table > thead > tr > th:nth-child(3),
[class*="oo-frozen-"] > table > tbody > tr > td:nth-child(3):not([colspan]),
[class*="oo-frozen-"] > table > tbody > tr > th:nth-child(3):not([colspan]) { left: var(--oo-fz-2, 0px); }

[class*="oo-frozen-"] > table > thead > tr > th:nth-child(4),
[class*="oo-frozen-"] > table > tbody > tr > td:nth-child(4):not([colspan]),
[class*="oo-frozen-"] > table > tbody > tr > th:nth-child(4):not([colspan]) { left: var(--oo-fz-3, 0px); }

[class*="oo-frozen-"] > table > thead > tr > th:nth-child(5),
[class*="oo-frozen-"] > table > tbody > tr > td:nth-child(5):not([colspan]),
[class*="oo-frozen-"] > table > tbody > tr > th:nth-child(5):not([colspan]) { left: var(--oo-fz-4, 0px); }

[class*="oo-frozen-"] > table > thead > tr > th:nth-child(6),
[class*="oo-frozen-"] > table > tbody > tr > td:nth-child(6):not([colspan]),
[class*="oo-frozen-"] > table > tbody > tr > th:nth-child(6):not([colspan]) { left: var(--oo-fz-5, 0px); }

[class*="oo-frozen-"] > table > thead > tr > th:nth-child(7),
[class*="oo-frozen-"] > table > tbody > tr > td:nth-child(7):not([colspan]),
[class*="oo-frozen-"] > table > tbody > tr > th:nth-child(7):not([colspan]) { left: var(--oo-fz-6, 0px); }

/* ==================== Celle bloccate per numero di colonne (K = 1..7) ==================== */

.oo-frozen-1 > table > thead > tr > th:nth-child(-n+1),
.oo-frozen-1 > table > tbody > tr > td:nth-child(-n+1):not([colspan]),
.oo-frozen-1 > table > tbody > tr > th:nth-child(-n+1):not([colspan]),
.oo-frozen-2 > table > thead > tr > th:nth-child(-n+2),
.oo-frozen-2 > table > tbody > tr > td:nth-child(-n+2):not([colspan]),
.oo-frozen-2 > table > tbody > tr > th:nth-child(-n+2):not([colspan]),
.oo-frozen-3 > table > thead > tr > th:nth-child(-n+3),
.oo-frozen-3 > table > tbody > tr > td:nth-child(-n+3):not([colspan]),
.oo-frozen-3 > table > tbody > tr > th:nth-child(-n+3):not([colspan]),
.oo-frozen-4 > table > thead > tr > th:nth-child(-n+4),
.oo-frozen-4 > table > tbody > tr > td:nth-child(-n+4):not([colspan]),
.oo-frozen-4 > table > tbody > tr > th:nth-child(-n+4):not([colspan]),
.oo-frozen-5 > table > thead > tr > th:nth-child(-n+5),
.oo-frozen-5 > table > tbody > tr > td:nth-child(-n+5):not([colspan]),
.oo-frozen-5 > table > tbody > tr > th:nth-child(-n+5):not([colspan]),
.oo-frozen-6 > table > thead > tr > th:nth-child(-n+6),
.oo-frozen-6 > table > tbody > tr > td:nth-child(-n+6):not([colspan]),
.oo-frozen-6 > table > tbody > tr > th:nth-child(-n+6):not([colspan]),
.oo-frozen-7 > table > thead > tr > th:nth-child(-n+7),
.oo-frozen-7 > table > tbody > tr > td:nth-child(-n+7):not([colspan]),
.oo-frozen-7 > table > tbody > tr > th:nth-child(-n+7):not([colspan]) {
    position: sticky;
    z-index: 2;
    background-color: var(--oo-fz-bg, #fff);
}

/* Separatore visivo sull'ultima cella bloccata */
.oo-frozen-1 > table > thead > tr > th:nth-child(1),
.oo-frozen-1 > table > tbody > tr > td:nth-child(1):not([colspan]),
.oo-frozen-1 > table > tbody > tr > th:nth-child(1):not([colspan]),
.oo-frozen-2 > table > thead > tr > th:nth-child(2),
.oo-frozen-2 > table > tbody > tr > td:nth-child(2):not([colspan]),
.oo-frozen-2 > table > tbody > tr > th:nth-child(2):not([colspan]),
.oo-frozen-3 > table > thead > tr > th:nth-child(3),
.oo-frozen-3 > table > tbody > tr > td:nth-child(3):not([colspan]),
.oo-frozen-3 > table > tbody > tr > th:nth-child(3):not([colspan]),
.oo-frozen-4 > table > thead > tr > th:nth-child(4),
.oo-frozen-4 > table > tbody > tr > td:nth-child(4):not([colspan]),
.oo-frozen-4 > table > tbody > tr > th:nth-child(4):not([colspan]),
.oo-frozen-5 > table > thead > tr > th:nth-child(5),
.oo-frozen-5 > table > tbody > tr > td:nth-child(5):not([colspan]),
.oo-frozen-5 > table > tbody > tr > th:nth-child(5):not([colspan]),
.oo-frozen-6 > table > thead > tr > th:nth-child(6),
.oo-frozen-6 > table > tbody > tr > td:nth-child(6):not([colspan]),
.oo-frozen-6 > table > tbody > tr > th:nth-child(6):not([colspan]),
.oo-frozen-7 > table > thead > tr > th:nth-child(7),
.oo-frozen-7 > table > tbody > tr > td:nth-child(7):not([colspan]),
.oo-frozen-7 > table > tbody > tr > th:nth-child(7):not([colspan]) {
    box-shadow: inset -1px 0 0 #dee2e6;
}

/* L'header sticky mantiene anche l'ombra inferiore oltre al separatore laterale */
.oo-sticky-head[class*="oo-frozen-"] > table > thead > tr > th {
    box-shadow: inset 0 -1px 0 #dee2e6;
}
.oo-sticky-head.oo-frozen-1 > table > thead > tr > th:nth-child(1),
.oo-sticky-head.oo-frozen-2 > table > thead > tr > th:nth-child(2),
.oo-sticky-head.oo-frozen-3 > table > thead > tr > th:nth-child(3),
.oo-sticky-head.oo-frozen-4 > table > thead > tr > th:nth-child(4),
.oo-sticky-head.oo-frozen-5 > table > thead > tr > th:nth-child(5),
.oo-sticky-head.oo-frozen-6 > table > thead > tr > th:nth-child(6),
.oo-sticky-head.oo-frozen-7 > table > thead > tr > th:nth-child(7) {
    box-shadow: inset -1px 0 0 #dee2e6, inset 0 -1px 0 #dee2e6;
}

/* Celle d'angolo (header sticky + colonna bloccata): sopra a tutto */
.oo-sticky-head.oo-frozen-1 > table > thead > tr > th:nth-child(-n+1),
.oo-sticky-head.oo-frozen-2 > table > thead > tr > th:nth-child(-n+2),
.oo-sticky-head.oo-frozen-3 > table > thead > tr > th:nth-child(-n+3),
.oo-sticky-head.oo-frozen-4 > table > thead > tr > th:nth-child(-n+4),
.oo-sticky-head.oo-frozen-5 > table > thead > tr > th:nth-child(-n+5),
.oo-sticky-head.oo-frozen-6 > table > thead > tr > th:nth-child(-n+6),
.oo-sticky-head.oo-frozen-7 > table > thead > tr > th:nth-child(-n+7) {
    z-index: 4;
}
