/*
 * hyper-grid · G1–G4 (docs/ui/COMPONENTI.md), più popover filtro, menu (L6), stato vuoto (K5) e skeleton (K6).
 * Solo token --hy-*. Logica in wwwroot/js/components/hyper-grid.js.
 */
.hy-grid {
    display: flex; flex-direction: column; min-height: 0;
    border-radius: var(--hy-radius-md); border: 1px solid var(--hy-glass-border);
    background: var(--hy-glass-sheen), var(--hy-glass-strong);
    box-shadow: var(--hy-glass-highlight), var(--hy-glass-shadow);
    -webkit-backdrop-filter: var(--hy-glass-blur); backdrop-filter: var(--hy-glass-blur);
    color: var(--hy-text); font-family: var(--hy-font-sans); font-size: var(--hy-text-md);
    overflow: hidden;
}
.hy-grid__spacer { flex: 1; }
.hy-visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } /* !important: deve vincere su qualsiasi regola di layout */

/* G3 · Toolbar */
.hy-grid__toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--hy-border); }
.hy-grid__search { width: 300px; max-width: 100%; }
.hy-grid__only-mobile { display: none; }
.hy-grid.is-mobile .hy-grid__only-mobile { display: inline-flex; }
.hy-grid.is-mobile .hy-grid__only-desktop { display: none; }

/* Area di raggruppamento */
.hy-grid__groupbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 42px; padding: 5px 12px; border-bottom: 1px dashed var(--hy-border); color: var(--hy-text-muted); font-size: var(--hy-text-sm); }
.hy-grid__groupbar.is-over { background: var(--hy-accent-soft); border-bottom: 1px solid var(--hy-accent); }
.hy-chip { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 4px 0 12px; border-radius: var(--hy-radius-pill); background: var(--hy-accent-soft); color: var(--hy-text); font-weight: var(--hy-weight-strong); }
.hy-chip__x { width: 22px; height: 22px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
.hy-chip__x:hover { background: var(--hy-accent-soft); }

/* G1 · Tabella */
.hy-grid__main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.hy-grid__scroll { flex: 1; min-height: 0; overflow: auto; }
.hy-grid__table { border-collapse: separate; border-spacing: 0; table-layout: fixed; min-width: 100%; }
.hy-grid__table th, .hy-grid__table td {
    height: 40px; padding: 0 10px; border-bottom: 1px solid var(--hy-border);
    text-align: left; vertical-align: middle; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hy-grid__table th {
    position: sticky; top: 0; z-index: 2; background: var(--hy-surface-header); color: var(--hy-text);
    font: var(--hy-weight-strong) var(--hy-text-sm) var(--hy-font-heading); user-select: none;
}
.hy-grid__table .is-end { text-align: right; font-variant-numeric: tabular-nums; }
.hy-grid__table th.is-pin-left, .hy-grid__table td.is-pin-left { position: sticky; left: 0; z-index: 1; background: var(--hy-surface-raised); }
.hy-grid__table th.is-pin-right, .hy-grid__table td.is-pin-right { position: sticky; right: 0; z-index: 1; background: var(--hy-surface-raised); text-align: right; }
.hy-grid__table th.is-pin-left, .hy-grid__table th.is-pin-right { z-index: 3; background: var(--hy-surface-header); }
.hy-grid__table th.is-over { box-shadow: inset 3px 0 0 var(--hy-accent); }
.hy-grid__th { display: flex; align-items: center; gap: 4px; height: 100%; }
.hy-grid__th-label { overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.hy-grid__sort { flex: none; color: var(--hy-text-muted); opacity: .45; font-size: 11px; }
.hy-grid__sort.is-on { color: var(--hy-accent-text); opacity: 1; }
.hy-grid__sort sup { margin-left: 1px; font-size: 9px; }
.hy-grid__filter-btn {
    position: relative; flex: none; margin-left: auto; width: 26px; height: 26px; border: 0; border-radius: 50%;
    background: transparent; color: var(--hy-text-muted); cursor: pointer; font-size: 11px;
}
.hy-grid__filter-btn:hover { background: var(--hy-accent-soft); color: var(--hy-text); }
.hy-grid__filter-btn.is-on { color: var(--hy-accent-text); }
.hy-grid__filter-btn.is-on::after { content: ""; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--hy-accent); }
.hy-grid__resizer { position: absolute; top: 0; right: 0; width: 6px; height: 100%; cursor: col-resize; touch-action: none; }
.hy-grid__resizer:hover, .hy-grid__resizer.is-on { background: var(--hy-accent); }
.hy-grid__table tbody tr[role="row"]:hover td { background: var(--hy-accent-soft); }
.hy-grid__table tbody tr.is-selected td { background: var(--hy-accent-soft); }
.hy-grid__table tbody tr.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--hy-accent); }
/* rowClass: righe con un fondo tenue che le distingue (es. report straordinari: festivi, weekend, ore mancanti o in eccesso) */
.hy-grid__table tbody tr.is-holiday td, .hy-card.is-holiday { background: var(--hy-info-tint); }
.hy-grid__table tbody tr.is-weekend td, .hy-card.is-weekend { background: var(--hy-success-tint); }
.hy-grid__table tbody tr.is-warning td, .hy-card.is-warning { background: var(--hy-warning-tint); }
.hy-grid__table tbody tr.is-danger td, .hy-card.is-danger { background: var(--hy-danger-tint); }
.hy-grid__table td:focus, .hy-grid__table th:focus { outline: 2px solid var(--hy-focus-ring); outline-offset: -2px; }
.hy-grid__table a { color: var(--hy-accent-text); text-decoration: none; }
.hy-grid__table a:hover { text-decoration: underline; }
.hy-grid__actions { display: inline-flex; gap: 4px; }
.hy-grid__group td { background: var(--hy-surface-header); font-weight: var(--hy-weight-strong); }
.hy-grid__group-toggle { width: 26px; height: 26px; margin-right: 4px; border: 0; border-radius: 50%; background: transparent; color: var(--hy-text); cursor: pointer; font-size: 11px; }
.hy-grid__group-count { color: var(--hy-text-muted); font-weight: var(--hy-weight-base); margin-left: 6px; }
.hy-grid__empty-row td { height: auto; white-space: normal; border-bottom: 0; }

/* K5 · Stato vuoto */
.hy-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 16px; text-align: center; }
.hy-empty__icon { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 50%; background: var(--hy-surface-alt); border: 1px solid var(--hy-glass-border); color: var(--hy-text-muted); font-size: 22px; }
.hy-empty__title { font: var(--hy-weight-strong) var(--hy-text-lg) var(--hy-font-heading); color: var(--hy-text); }
.hy-empty__text { color: var(--hy-text-muted); }

/* K6 · Skeleton */
.hy-skeleton { display: block; height: 12px; width: 70%; border-radius: var(--hy-radius-sm); background: var(--hy-skeleton); animation: hy-pulse 1.4s ease-in-out infinite; }
@keyframes hy-pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .hy-skeleton { animation: none; } }

/* G4 · Paginazione */
.hy-grid__pager { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--hy-border); background: var(--hy-surface-header); color: var(--hy-text-muted); font-size: var(--hy-text-sm); }
.hy-grid__pager:empty { display: none; }
.hy-grid__size { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 0 12px; font-weight: var(--hy-weight-regular); }
.hy-grid__size .hy-select { width: auto; }
.hy-grid__pages { display: inline-flex; align-items: center; gap: 2px; }
.hy-grid__pages .hy-btn { color: var(--hy-text); font-variant-numeric: tabular-nums; }
.hy-grid__pages .hy-btn.is-current { background: var(--hy-accent-fill); color: var(--hy-on-accent); }
.hy-grid__dots { padding: 0 4px; }

/* Popover filtro stile Excel e scelta colonne */
.hy-popover {
    position: fixed; z-index: var(--hy-z-popover); width: 290px; max-height: 75vh; display: flex; flex-direction: column;
    border-radius: var(--hy-radius-md); border: 1px solid var(--hy-glass-border);
    background: var(--hy-surface-raised); color: var(--hy-text); box-shadow: var(--hy-shadow-2); font-size: var(--hy-text-sm);
}
.hy-popover .hy-filter { flex: 1; min-height: 0; overflow: auto; }
.hy-popover__foot { display: flex; justify-content: flex-end; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--hy-border); }
.hy-filter { display: flex; flex-direction: column; }
.hy-filter__sec { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--hy-border); }
.hy-filter__caption { color: var(--hy-text-muted); font-size: var(--hy-text-xs); font-weight: var(--hy-weight-strong); text-transform: uppercase; letter-spacing: .04em; }
.hy-filter__list { max-height: 240px; overflow: auto; padding: 4px 10px 8px; }
.hy-filter__opt { display: flex; align-items: center; gap: 8px; min-height: 30px; margin: 0; cursor: pointer; font-weight: var(--hy-weight-regular); }
.hy-filter__opt span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hy-filter__opt small { color: var(--hy-text-muted); font-variant-numeric: tabular-nums; }
.hy-filter__opt input { width: 16px; height: 16px; accent-color: var(--hy-accent); }
.hy-filter__all { font-weight: var(--hy-weight-strong); }
/* "Altre condizioni" (2026-10-23): voce richiudibile sotto l'elenco; con una condizione scritta l'elenco è attenuato perché non conta */
.hy-filter__more { border-top: 1px solid var(--hy-border); }
.hy-filter__more > summary { display: flex; align-items: center; gap: 6px; padding: 8px 10px; cursor: pointer; list-style: none; color: var(--hy-text-muted); font-size: var(--hy-text-sm); font-weight: var(--hy-weight-strong); }
.hy-filter__more > summary::-webkit-details-marker { display: none; }
.hy-filter__more > summary::before { content: "\f054"; font: var(--fa-font-solid); font-size: 10px; transition: transform .15s; }
.hy-filter__more[open] > summary::before { transform: rotate(90deg); }
.hy-filter__more > summary:hover { color: var(--hy-text); }
.hy-filter__more > summary:focus-visible { outline: 2px solid var(--hy-focus-ring); outline-offset: -2px; }
.hy-filter__more > .hy-filter__sec { border-bottom: 0; padding-top: 0; }
.hy-filter__list.is-off { opacity: .45; pointer-events: none; }

/* L6 · Voci di menu (popover e sheet) */
.hy-menu { display: flex; flex-direction: column; }
.hy-menu__item {
    display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border: 0; border-radius: var(--hy-radius-sm);
    background: transparent; color: var(--hy-text); text-align: left; font: inherit; cursor: pointer;
}
.hy-menu__item i { width: 16px; color: var(--hy-text-muted); }
.hy-menu__item:hover, .hy-menu__item:focus-visible { background: var(--hy-accent-soft); outline: none; }
.hy-menu__item.is-on { color: var(--hy-accent-text); font-weight: var(--hy-weight-strong); }
.hy-menu__item.is-on i { color: var(--hy-accent-text); }

/* G2 · Lista a card (smartphone) */
.hy-cards { display: flex; flex-direction: column; gap: 8px; padding: 10px; }
.hy-cards__section {
    position: sticky; top: 0; z-index: 1; padding: 8px 4px; font: var(--hy-weight-strong) var(--hy-text-sm) var(--hy-font-heading);
    background: var(--hy-glass-strong); color: var(--hy-text);
}
.hy-card {
    padding: 14px; border-radius: var(--hy-radius-md); border: 1px solid var(--hy-glass-border);
    background: var(--hy-glass-sheen), var(--hy-glass); color: var(--hy-text);
}
.hy-card.is-tappable { cursor: pointer; }
.hy-card.is-tappable:focus-visible { outline: 2px solid var(--hy-focus-ring); outline-offset: 2px; }
.hy-card__head { display: flex; align-items: flex-start; gap: 8px; }
.hy-card__title { flex: 1; min-width: 0; font-weight: var(--hy-weight-strong); overflow-wrap: anywhere; padding-top: 6px; }
.hy-card__body { margin-top: 4px; }
.hy-card__row { font-size: var(--hy-text-sm); margin-top: 3px; overflow-wrap: anywhere; }
.hy-card__label { color: var(--hy-text-muted); }
.hy-card a { color: var(--hy-accent-text); text-decoration: none; }
.hy-card--skeleton { display: flex; flex-direction: column; gap: 10px; }
.hy-cards__more { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 10px 16px; color: var(--hy-text-muted); font-size: var(--hy-text-sm); }

@media (max-width: 767.98px) {
    .hy-grid__toolbar { padding: 10px; }
    .hy-grid__search { width: 100%; }
    .hy-grid__toolbar .hy-btn--sm { height: 44px; }
    .hy-menu__item { min-height: 48px; }
    .hy-card__head .hy-btn--icon { width: 44px; height: 44px; margin: -8px -8px 0 0; }
    .hy-filter__list { max-height: none; }
    .hy-filter__opt { min-height: 44px; }
}

/* Testo lungo in una cella: una riga con i puntini, testo completo nel tooltip (come clipMode EllipsisWithTooltip di Syncfusion) */
.hy-clip { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Totali (G4) nel piede e nelle intestazioni dei gruppi */
.hy-grid__totals { margin-left: 12px; color: var(--hy-text); font-weight: var(--hy-weight-strong); white-space: nowrap; }

/* Albero (opzione tree): rientro per livello, freccia o spazio della freccia, testo che si accorcia */
.hy-grid__tree { display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; }
.hy-grid__tree .hy-grid__group-toggle { flex: none; }
.hy-grid__tree-leaf { flex: none; display: inline-block; width: 28px; }
.hy-grid__tree-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* Cella su più righe (es. commessa con note e cliente): testo principale e righe secondarie più piccole */
.hy-grid__stack { line-height: 1.25; white-space: normal; padding: 4px 0; }
.hy-grid__sub { font-size: 12px; color: var(--hy-text-muted); }
.hy-grid__sub.is-clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; } /* testo lungo (sommari): al massimo due righe */

/* Intestazioni a due livelli (headerGroups): riga di gruppo alta 30px, i titoli delle colonne restano fermi sotto */
.hy-grid__table th.hy-grid__hgroup { height: 30px; text-align: center; font-size: 12px; color: var(--hy-text-muted); border-bottom: 1px solid var(--hy-border); border-inline: 1px solid var(--hy-border); }
.hy-grid__table th.hy-grid__hgroup.is-empty { border-inline-color: transparent; }
.hy-grid__table.has-hgroups thead tr:not(.hy-grid__hgroups) th { top: 30px; }

/* Righe espandibili (detail): freccia nella prima cella, dettaglio su --hy-surface-alt sotto la riga */
.hy-grid__detail-toggle { width: 24px; height: 24px; margin-right: 6px; border: 0; border-radius: 50%; background: transparent; color: var(--hy-text); cursor: pointer; font-size: 11px; vertical-align: middle; }
.hy-grid__detail-toggle:hover { background: var(--hy-accent-soft); }
.hy-grid__detail > td { height: auto; padding: 12px 16px; white-space: normal; background: var(--hy-surface-alt); }
.hy-card__detail { margin-top: 8px; }
.hy-card__detail > summary { cursor: pointer; color: var(--hy-accent-text); font-weight: var(--hy-weight-strong); min-height: 32px; display: flex; align-items: center; }
