/* =====================================================================
   Innova Tickets v2 — tema scuro ("notte")
   Attivo con <html data-bs-theme="dark">: lo imposta lo script in testa alla pagina
   (scelta salvata nel browser, altrimenti preferenza del sistema operativo).
   Bootstrap 5.3 cambia da solo i propri componenti; qui si ridefiniscono i colori
   del tema "apple" e i pochi punti che avevano colori fissi.
   ===================================================================== */

html[data-bs-theme="dark"] {
    color-scheme: dark;
    --ink: #f5f5f7;
    --ink-2: #aeaeb2;
    --ink-3: #8e8e93;
    --line: rgba(255, 255, 255, .10);
    --line-strong: rgba(255, 255, 255, .18);
    --bg: #111113;
    --card: #1c1c1e;
    --accent: #1fb3a2;          /* verde Innova schiarito: contrasto su fondo scuro */
    --accent-dark: #4fd0c0;     /* hover: sul fondo scuro si schiarisce */
    --accent-soft: rgba(31, 179, 162, .18);
    --blue: #3b93ff;
    --green: #30d158;
    --orange: #ff9f0a;
    --red: #ff453a;
    --sky: #64d2ff;
    --purple: #bf5af2;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, .55), 0 14px 34px rgba(0, 0, 0, .45);

    --bs-body-bg: var(--bg);
    --bs-body-color: var(--ink);
    --bs-emphasis-color: var(--ink);
    --bs-primary: var(--accent);
    --bs-primary-rgb: 31, 179, 162;
    --bs-link-color: var(--accent);
    --bs-link-color-rgb: 31, 179, 162;
    --bs-link-hover-color: var(--accent-dark);
    --bs-link-hover-color-rgb: 79, 208, 192;
    --bs-border-color: var(--line);
    --bs-secondary-color: var(--ink-2);
    --bs-tertiary-color: var(--ink-3);
    --bs-heading-color: var(--ink);
    --bs-secondary-bg: #2c2c2e;
    --bs-tertiary-bg: #242426;
}
html[data-bs-theme="dark"] body { background: var(--bg); color: var(--ink); }

/* ---------- barra, menu, logo ---------- */
html[data-bs-theme="dark"] .tv-nav { background: rgba(28, 28, 30, .78); }
html[data-bs-theme="dark"] .tv-menu > li > a:hover,
html[data-bs-theme="dark"] .tv-menu > li > button:hover,
html[data-bs-theme="dark"] .tv-user-btn:hover,
html[data-bs-theme="dark"] .tv-offcanvas-menu a:hover { background: rgba(255, 255, 255, .08); }
html[data-bs-theme="dark"] .tv-menu > li.active > a,
html[data-bs-theme="dark"] .tv-menu > li.active > button { background: rgba(255, 255, 255, .10); }
html[data-bs-theme="dark"] .dropdown-menu {
    background: #2c2c2e;
    --bs-dropdown-bg: #2c2c2e;
    --bs-dropdown-border-color: rgba(255, 255, 255, .08);
    --bs-dropdown-link-color: var(--ink);
    --bs-dropdown-link-hover-color: var(--ink);
    --bs-dropdown-link-hover-bg: rgba(255, 255, 255, .08);
    box-shadow: 0 10px 40px rgba(0, 0, 0, .6);
}
html[data-bs-theme="dark"] .dropdown-menu > li > a { color: var(--ink); }
html[data-bs-theme="dark"] .offcanvas { --bs-offcanvas-bg: var(--card); }
/* logo: scritta scura di giorno, chiara di notte (important: la barra forza display sulle immagini del marchio) */
html:not([data-bs-theme="dark"]) .tv-logo-night, html[data-bs-theme="dark"] .tv-logo-day { display: none !important; }

/* ---------- superfici semitrasparenti: da nero a bianco ---------- */
html[data-bs-theme="dark"] .list-group { --bs-list-group-bg: transparent; --bs-list-group-color: var(--ink); --bs-list-group-action-hover-bg: rgba(255, 255, 255, .05); --bs-list-group-action-color: var(--ink); --bs-list-group-action-hover-color: var(--ink); }
html[data-bs-theme="dark"] .tv-group-head { background: rgba(255, 255, 255, .04); }
html[data-bs-theme="dark"] .tv-pill-default, html[data-bs-theme="dark"] .tv-pill-secondary,
html[data-bs-theme="dark"] .badge-soft-default, html[data-bs-theme="dark"] .badge-soft-secondary,
html[data-bs-theme="dark"] .tv-count:not([class*="is-"]), html[data-bs-theme="dark"] .tv-seg, html[data-bs-theme="dark"] .tv-kbd,
html[data-bs-theme="dark"] .tv-files a, html[data-bs-theme="dark"] .tv-evgroup-count,
html[data-bs-theme="dark"] .tv-event .tv-event-icon, html[data-bs-theme="dark"] .tv-bubble .tv-group { background: rgba(255, 255, 255, .10); }
html[data-bs-theme="dark"] .tv-files a:hover { background: rgba(255, 255, 255, .16); }
html[data-bs-theme="dark"] .tv-pill-dark { background: var(--ink); color: #111113; }
html[data-bs-theme="dark"] .tv-seg a.active { background: #3a3a3c; box-shadow: 0 1px 3px rgba(0, 0, 0, .5); }
html[data-bs-theme="dark"] .tv-event .detail,
html[data-bs-theme="dark"] .card-body.viz-tiles .viz-tile { background: rgba(255, 255, 255, .05); }

/* etichette colorate: testo schiarito, sfondo un po' più deciso */
html[data-bs-theme="dark"] .tv-pill-success, html[data-bs-theme="dark"] .badge-soft-success { background: rgba(48, 209, 88, .18); color: #7ee29a; }
html[data-bs-theme="dark"] .tv-pill-danger, html[data-bs-theme="dark"] .badge-soft-danger, html[data-bs-theme="dark"] .label-danger { background: rgba(255, 69, 58, .20); color: #ff8a82; }
html[data-bs-theme="dark"] .tv-pill-warning, html[data-bs-theme="dark"] .badge-soft-warning, html[data-bs-theme="dark"] .label-warning { background: rgba(255, 159, 10, .20); color: #ffc259; }
html[data-bs-theme="dark"] .tv-pill-info, html[data-bs-theme="dark"] .badge-soft-info { background: rgba(100, 210, 255, .18); color: #8fdcff; }
html[data-bs-theme="dark"] .tv-pill-primary, html[data-bs-theme="dark"] .badge-soft-primary { color: #6fdccd; }
html[data-bs-theme="dark"] .tv-tile-icon.is-orange { color: #ffb340; }
html[data-bs-theme="dark"] .list-group-item-warning { background: rgba(255, 159, 10, .16); color: #ffc259; }
html[data-bs-theme="dark"] .list-group-item-danger { background: rgba(255, 69, 58, .16); color: #ff8a82; }
html[data-bs-theme="dark"] .alert-success { --bs-alert-bg: rgba(48, 209, 88, .14); --bs-alert-color: #7ee29a; --bs-alert-border-color: transparent; }
html[data-bs-theme="dark"] .alert-danger { --bs-alert-bg: rgba(255, 69, 58, .15); --bs-alert-color: #ff8a82; --bs-alert-border-color: transparent; }
html[data-bs-theme="dark"] .alert-warning { --bs-alert-bg: rgba(255, 159, 10, .15); --bs-alert-color: #ffc259; --bs-alert-border-color: transparent; }
html[data-bs-theme="dark"] .alert-info { --bs-alert-bg: rgba(100, 210, 255, .13); --bs-alert-color: #8fdcff; --bs-alert-border-color: transparent; }
html[data-bs-theme="dark"] .alert .alert-link { color: inherit; }

/* ---------- pulsanti ---------- */
html[data-bs-theme="dark"] .btn-light {
    --bs-btn-bg: rgba(255, 255, 255, .08); --bs-btn-color: var(--ink);
    --bs-btn-hover-bg: rgba(255, 255, 255, .14); --bs-btn-hover-color: var(--ink);
    --bs-btn-active-bg: rgba(255, 255, 255, .18); --bs-btn-active-color: var(--ink);
    --bs-btn-disabled-bg: rgba(255, 255, 255, .05); --bs-btn-disabled-color: var(--ink-3);
}
html[data-bs-theme="dark"] .btn-outline-secondary { --bs-btn-hover-bg: rgba(255, 255, 255, .08); }
/* verde pieno un po' più scuro dell'accento: testo bianco leggibile */
html[data-bs-theme="dark"] .btn-primary { --bs-btn-bg: #12897b; --bs-btn-border-color: #12897b; --bs-btn-color: #fff; --bs-btn-hover-bg: #17a090; --bs-btn-hover-border-color: #17a090; --bs-btn-hover-color: #fff; --bs-btn-active-bg: #17a090; --bs-btn-active-border-color: #17a090; --bs-btn-disabled-bg: #12897b; --bs-btn-disabled-border-color: #12897b; }

html[data-bs-theme="dark"] .tv-step-num { background: #12897b; }
/* testi colorati di Bootstrap: le tinte standard sono troppo scure sul fondo notte */
html[data-bs-theme="dark"] .text-danger { color: #ff6b61 !important; }
html[data-bs-theme="dark"] .text-warning { color: #ffc259 !important; }
html[data-bs-theme="dark"] .text-success { color: #7ee29a !important; }
html[data-bs-theme="dark"] .text-info { color: #8fdcff !important; }
html[data-bs-theme="dark"] .text-primary { color: #6fdccd !important; }
html[data-bs-theme="dark"] .navbar-inverse { background: #2c2c2e; }

/* ---------- moduli ---------- */
html[data-bs-theme="dark"] .form-control,
html[data-bs-theme="dark"] .form-select { background-color: #2c2c2e; border-color: rgba(255, 255, 255, .14); color: var(--ink); }
html[data-bs-theme="dark"] .form-control::placeholder { color: var(--ink-3); }
html[data-bs-theme="dark"] .form-control:disabled, html[data-bs-theme="dark"] .form-control[readonly] { background-color: #242426; }
html[data-bs-theme="dark"] .form-check-input { background-color: #2c2c2e; border-color: rgba(255, 255, 255, .3); }
html[data-bs-theme="dark"] .form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
html[data-bs-theme="dark"] .input-group-text { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .14); color: var(--ink-2); }
html[data-bs-theme="dark"] .file-drop-zone { border-color: rgba(255, 255, 255, .18); background: rgba(255, 255, 255, .03); }
html[data-bs-theme="dark"] .file-drop-zone-title { color: var(--ink-3); }
/* Select2 (Krajee) */
html[data-bs-theme="dark"] .select2-container .select2-selection { background-color: #2c2c2e; border-color: rgba(255, 255, 255, .14); color: var(--ink); }
html[data-bs-theme="dark"] .select2-container .select2-selection__rendered { color: var(--ink); }
html[data-bs-theme="dark"] .select2-container .select2-selection.select2-selection--single .select2-selection__placeholder { color: var(--ink-3); }
html[data-bs-theme="dark"] .tv-count.is-success { color: #111113; }
html[data-bs-theme="dark"] .select2-dropdown { background-color: #2c2c2e; border-color: rgba(255, 255, 255, .14); color: var(--ink); }
html[data-bs-theme="dark"] .select2-search__field { background-color: #1c1c1e; color: var(--ink); border-color: rgba(255, 255, 255, .14); }
html[data-bs-theme="dark"] .select2-results__option--highlighted { background-color: var(--accent) !important; color: #0b1f1c !important; }
html[data-bs-theme="dark"] .select2-container .select2-selection__choice { background: rgba(255, 255, 255, .1); border-color: transparent; color: var(--ink); }

/* ---------- tabelle, griglie, schede ---------- */
html[data-bs-theme="dark"] .table { --bs-table-color: var(--ink); --bs-table-hover-bg: rgba(255, 255, 255, .04); --bs-table-hover-color: var(--ink); --bs-table-striped-bg: rgba(255, 255, 255, .025); --bs-table-striped-color: var(--ink); }
html[data-bs-theme="dark"] .grid-view .filters td, html[data-bs-theme="dark"] .kv-grid-table .filters td { background: rgba(255, 255, 255, .03); }
html[data-bs-theme="dark"] .kv-page-summary td { background: rgba(255, 255, 255, .05) !important; }
html[data-bs-theme="dark"] .kv-grid-table thead th, html[data-bs-theme="dark"] .kv-grid-table thead td { background: transparent; }
/* griglie Krajee: intestazione, piede e intestazione fissa hanno il bianco nel loro CSS */
html[data-bs-theme="dark"] .kv-table-header, html[data-bs-theme="dark"] .kv-table-footer, html[data-bs-theme="dark"] .kv-table-float { background: var(--card); }
/* righe evidenziate (ritardi, anomalie): Bootstrap forza il testo scuro, qui torna chiaro */
html[data-bs-theme="dark"] tr.table-danger > td, html[data-bs-theme="dark"] tr.table-warning > td, html[data-bs-theme="dark"] tr.table-success > td, html[data-bs-theme="dark"] tr.table-info > td,
html[data-bs-theme="dark"] .table > tbody > tr.danger > td, html[data-bs-theme="dark"] .table > tbody > tr.warning > td { --bs-table-color: var(--ink); color: var(--ink); }
html[data-bs-theme="dark"] tr.table-success, html[data-bs-theme="dark"] tr.table-warning, html[data-bs-theme="dark"] tr.table-danger, html[data-bs-theme="dark"] tr.table-info { --bs-table-hover-bg: rgba(255, 255, 255, .06); --bs-table-hover-color: var(--ink); --bs-table-striped-bg: rgba(255, 255, 255, .025); --bs-table-striped-color: var(--ink); --bs-table-active-bg: rgba(255, 255, 255, .08); --bs-table-active-color: var(--ink); }
html[data-bs-theme="dark"] tr.table-danger > td { --bs-table-bg: rgba(255, 69, 58, .14); background-color: rgba(255, 69, 58, .14) !important; }
html[data-bs-theme="dark"] tr.table-warning > td { --bs-table-bg: rgba(255, 159, 10, .13); background-color: rgba(255, 159, 10, .13) !important; }
/* anteprima allegati (fileinput) */
html[data-bs-theme="dark"] .file-preview, html[data-bs-theme="dark"] .file-input .file-caption { background: transparent; border-color: var(--line); }
html[data-bs-theme="dark"] .file-preview-frame { background: rgba(255, 255, 255, .05); border-color: var(--line); box-shadow: none; }
html[data-bs-theme="dark"] .pagination { --bs-pagination-active-color: #111113; --bs-pagination-bg: transparent; --bs-pagination-color: var(--ink); --bs-pagination-hover-bg: rgba(255, 255, 255, .08); --bs-pagination-disabled-bg: transparent; }
html[data-bs-theme="dark"] .nav-tabs { --bs-nav-tabs-link-active-bg: var(--card); --bs-nav-tabs-link-active-border-color: var(--line) var(--line) var(--card); }
html[data-bs-theme="dark"] .nav-tabs > li.active > a { background: var(--card); border-color: var(--line) var(--line) var(--card); }
html[data-bs-theme="dark"] .nav-pills > li.active > a { background: var(--ink); color: #111113; }
/* schede a pillola attive: fondo chiaro (colore del testo) e testo scuro, come di giorno ma invertito */
html[data-bs-theme="dark"] .nav-pills { --bs-nav-pills-link-active-color: #111113; }
html[data-bs-theme="dark"] .thumbnail { background: var(--card); }
html[data-bs-theme="dark"] .modal-content { background: var(--card); box-shadow: 0 20px 60px rgba(0, 0, 0, .7); }
html[data-bs-theme="dark"] .popover, html[data-bs-theme="dark"] .popover-x { --bs-popover-bg: #2c2c2e; background: #2c2c2e; border-color: rgba(255, 255, 255, .08); color: var(--ink); }
html[data-bs-theme="dark"] .popover-x .popover-header, html[data-bs-theme="dark"] .popover-x .popover-title { background: rgba(255, 255, 255, .05); color: var(--ink); }

/* ---------- cronologia a chat ---------- */
html[data-bs-theme="dark"] .tv-timeline { background: #161618; }
html[data-bs-theme="dark"] .tv-msg-row.is-other .tv-bubble { background: #2c2c2e; }
html[data-bs-theme="dark"] .tv-msg-row.is-mine .tv-bubble { background: #1f3b2a; }
html[data-bs-theme="dark"] .tv-msg-row.is-mine .tv-bubble .tv-who { color: #7ee29a; }
html[data-bs-theme="dark"] .tv-msg-row.is-mine .tv-bubble .tv-comment-head { background: rgba(126, 226, 154, .08); }
html[data-bs-theme="dark"] .tv-bubble .tv-comment-head { background: rgba(255, 255, 255, .04); }
html[data-bs-theme="dark"] .tv-bubble { box-shadow: 0 1px 1px rgba(0, 0, 0, .4); }
html[data-bs-theme="dark"] .tv-bubble.g-sistema { background: #242426 !important; }
html[data-bs-theme="dark"] .tv-timeline > .tv-event,
html[data-bs-theme="dark"] .tv-evgroup-toggle,
html[data-bs-theme="dark"] .tv-evgroup-list { background: rgba(255, 255, 255, .06); }
html[data-bs-theme="dark"] .tv-evgroup-toggle:hover { background: rgba(255, 255, 255, .10); }
html[data-bs-theme="dark"] .tv-day span { background: #2c2c2e; box-shadow: none; }
/* colori per gruppo più chiari: leggibili su fondo scuro */
html[data-bs-theme="dark"] .g-cat { --g: #6ea8e8; --g-soft: rgba(110, 168, 232, .16); }
html[data-bs-theme="dark"] .g-innova { --g: #4fc9a8; --g-soft: rgba(79, 201, 168, .16); }
html[data-bs-theme="dark"] .g-helpdesk { --g: #f0a53a; --g-soft: rgba(240, 165, 58, .16); }
html[data-bs-theme="dark"] .g-sinergia { --g: #b48ae6; --g-soft: rgba(180, 138, 230, .16); }
html[data-bs-theme="dark"] .g-amministrazione { --g: #a4b0b8; --g-soft: rgba(164, 176, 184, .16); }
html[data-bs-theme="dark"] .g-sistema, html[data-bs-theme="dark"] .g-altro { --g: #a1a1a6; --g-soft: rgba(255, 255, 255, .08); }
html[data-bs-theme="dark"] .tv-msg-avatar[class*="g-"] { color: #111113; }

/* ---------- statistiche ---------- */
html[data-bs-theme="dark"] .viz-root { --viz-1: #4a95ec; --viz-2: #f07a4a; --viz-3: #2cc48c; --viz-4: #8a7ae0; --viz-bad: #ff6b5f; --viz-grid: rgba(255, 255, 255, .09); }
html[data-bs-theme="dark"] .viz-hbar-row:hover { background: rgba(255, 255, 255, .05); }
html[data-bs-theme="dark"] .viz-lines .viz-hit:hover rect { fill: rgba(255, 255, 255, .05); }
html[data-bs-theme="dark"] .viz-lines .viz-point, html[data-bs-theme="dark"] .viz-lines .viz-hit:hover .viz-dot { stroke: var(--card); }

/* ---------- esploso ricambi: il disegno tecnico resta su fondo bianco ---------- */
html[data-bs-theme="dark"] .tv-keep-light { background: #fff; color: #1d1d1f; }

/* ---------- pulsante giorno / notte ---------- */
.tv-theme-toggle { width: 34px; height: 34px; padding: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.tv-theme-toggle .bi-sun { display: none; }
html[data-bs-theme="dark"] .tv-theme-toggle .bi-sun { display: inline; }
html[data-bs-theme="dark"] .tv-theme-toggle .bi-moon-stars { display: none; }

/* la stampa resta sempre chiara */
@media print {
    html[data-bs-theme="dark"] { --bg: #fff; --card: #fff; --ink: #1d1d1f; --ink-2: #6e6e73; --ink-3: #86868b; --line: rgba(0, 0, 0, .08); }
    html[data-bs-theme="dark"] body { background: #fff; color: #1d1d1f; }
}
html[data-bs-theme="dark"] .tv-count.is-danger { background: #d7372e; }

html[data-bs-theme="dark"] .tv-kpi.is-ok { color: #6fdc8c; background: rgba(52, 199, 89, .18); }
html[data-bs-theme="dark"] .tv-kpi.is-warn { color: #ffc766; background: rgba(255, 159, 10, .2); }
html[data-bs-theme="dark"] .tv-kpi.is-bad { color: #ff8f85; background: rgba(255, 69, 58, .2); }
html[data-bs-theme="dark"] .viz-delta.is-good { color: #6fdc8c; }
html[data-bs-theme="dark"] .viz-delta.is-bad { color: #ff8f85; }
