/* =========================================================================
   Contogioco – tema DARK
   -------------------------------------------------------------------------
   Il toggle #cg-theme-switch mette la classe "dark-mode" sul <body>,
   mentre in origine questo file cercava "cg-dark-mode" su <html>.
   Le regole ora rispondono a entrambi:
     - html.cg-dark-mode
     - html:has(> body.dark-mode)
   Il selettore :is(...) ha specificità (0,2,2), maggiore di "html:root" di
   adeguamento_xsport_desktop.css e di "body" di Bootstrap: niente !important.
   ========================================================================= */

/* ---------- Variabili Contogioco ---------- */
:is(html.cg-dark-mode, html:has(> body.dark-mode)) {
  color-scheme: dark;
  --bg-color-001: #151e33;
  --bg-color-002: #0b1120;
  --bg-color-003: #1b2540;
  --cg-surface: #151e33;
  --cg-surface-alt: #121a2c;
  --cg-line: #26304a;
  --cg-ink: #eef1f7;
  --cg-ink-soft: #c4cad6;
  --intermediate-bar-bg-color: #151e33;
  --intermediate-bar-text-color: #eef1f7;
  --intermediate-bar-muted-text-color: #9aa3b5;
  --header-input-bg-color: #1b2540;
  --header-input-text-color: #eef1f7;
}

/* ---------- Variabili promo ---------- */
:is(html.cg-dark-mode, html:has(> body.dark-mode)),
:is(html.cg-dark-mode, html:has(> body.dark-mode)) #cg-promo-rootContainer {
  --cgr-color-bg: #0b1120;
  --cgr-color-bg-subtle: #121a2c;
  --cgr-color-card-bg: #151e33;
  --cgr-color-hero-bg: #16224a;
  --cgr-color-text: #eef1f7;
  --cgr-color-text-title: #ffffff;
  --cgr-color-text-secondary: #c4cad6;
  --cgr-color-text-label: #9aa3b5;
  --cgr-color-primary-hover: #6b9be6;
  --cgr-color-primary-strong: #cddbef;
  --cgr-color-primary-subtle: #1b2a47;
  --cgr-color-inverse-bg: #eef1f7;
  --cgr-color-inverse-text: #0d1424;
  --cgr-color-badge-active-text: #0d1424;
  --cgr-color-border: #26304a;
  --cgr-color-border-strong: #34405e;
  --cgr-color-sticky-bg: rgba(11, 17, 32, 0.92);
  --cgr-color-focus: #6b9be6;
  --cgr-color-error: #e5534b;
  --cgr-shadow-card: 0 1px 3px rgba(0, 0, 0, 0.6);
  --cgr-shadow-card-hover: 0 20px 40px rgba(0, 0, 0, 0.6);
  --cgr-promo-card-light-chip-bg: rgba(255, 255, 255, 0.12);
}

/* ---------- Variabili XSport (area sport) ---------- */
/* Sovrascrivono quelle chiare di :root in adeguamento_xsport_desktop.css */
:is(html.cg-dark-mode, html:has(> body.dark-mode)) {
  --xsport-bg: #0b1120;
  --xsport-surface: #151e33;
  --xsport-on-bg: #eef1f7;
  --xsport-on-surface: #eef1f7;

  --xsport-primary: #3d7ad6;
  --xsport-primary-light: #6b9be6;
  --xsport-primary-dark: #8fb4ee;   /* usato soprattutto come colore testo */
  --xsport-primary-text: #8fb4ee;   /* quote e testi "primary" leggibili su scuro */

  --xsport-accent: #26304a;
  --xsport-accent-light: #9aa3b5;
  --xsport-accent-dark: #eef1f7;

  --xsport-border: #26304a;

  --xsport-gray-0: #151e33;
  --xsport-gray-100: #121a2c;
  --xsport-gray-200: #1b2540;
  --xsport-gray-300: #26304a;
  --xsport-gray-400: #34405e;
  --xsport-gray-500: #8a93a8;
  --xsport-gray-600: #9aa3b5;
  --xsport-gray-700: #c4cad6;
  --xsport-gray-800: #dfe3eb;
  --xsport-gray-900: #eef1f7;

  --xsport-contrast-high: #eef1f7;
  --xsport-contrast-low: #0b1120;

  --xsport-shadow-color: rgb(0 0 0 / 50%);
  --xsport-overlay: rgb(0 0 0 / 60%);
  --xsport-hero-bg: #16224a;
  --xsport-boost-bg: #1a5fc2;
  --xsport-boost-muted: #cddbef;    /* testo chiaro sulle card boost */
  --xsport-error: #e5534b;
  --xsport-primary-soft: rgb(107 155 230 / 16%);
  --xsport-accent-soft: rgb(255 255 255 / 6%);
  --xsport-link: #8fb4ee;
  --xsport-link-hover: #cddbef;
}

/* .xs-lb e la DepositCard ridefiniscono alcune variabili a livello locale
   (adeguamento_xsport_desktop.css): vanno riscritte anche lì */
:is(html.cg-dark-mode, html:has(> body.dark-mode)) .xs-lb {
  --xsport-primary-dark: #8fb4ee;
}

:is(html.cg-dark-mode, html:has(> body.dark-mode)) .xs-lb-hero [class*="DepositCard_deposit"] {
  --xsport-accent: #9aa3b5;
}

/* ---------- Base pagina ---------- */
:is(html.cg-dark-mode, html:has(> body.dark-mode)) body {
  background-color: var(--bg-color-002);
  color: var(--cg-ink);
}

/* Slide dei caroselli sport (main.css le forza bianche) */
:is(html.cg-dark-mode, html:has(> body.dark-mode)) .xs-lb .swiper-slide {
  background: var(--xsport-surface);
  color: var(--xsport-on-surface);
}

/* ---------- Modali ---------- */
:is(html.cg-dark-mode, html:has(> body.dark-mode)) .modal-content,
:is(html.cg-dark-mode, html:has(> body.dark-mode)) .modal-content.nero {
  background-color: #151e33;
  color: #eef1f7;
  border-color: #26304a;
}

:is(html.cg-dark-mode, html:has(> body.dark-mode)) .modal-content .modal-header,
:is(html.cg-dark-mode, html:has(> body.dark-mode)) .modal-content .modal-footer {
  border-color: #26304a;
  color: #eef1f7;
}

:is(html.cg-dark-mode, html:has(> body.dark-mode)) .modal-content .close {
  color: #eef1f7;
}

/* ---------- Input ---------- */
:is(html.cg-dark-mode, html:has(> body.dark-mode)) #cg-header input.elemento-input,
:is(html.cg-dark-mode, html:has(> body.dark-mode)) .modal-content input.elemento-input {
  background-color: #1b2540;
  color: #eef1f7;
  border-color: #26304a;
}

:is(html.cg-dark-mode, html:has(> body.dark-mode)) input.elemento-input::placeholder {
  color: #9aa3b5;
}

:is(html.cg-dark-mode, html:has(> body.dark-mode)) input.elemento-input:-webkit-autofill {
  box-shadow: 0 0 0 1000px #1b2540 inset;
  -webkit-text-fill-color: #eef1f7;
}

/* ---------- Toast ---------- */
:is(html.cg-dark-mode, html:has(> body.dark-mode)) .cg-toast-desc-content {
  color: #eef1f7;
}

/* ---------- Scrollbar ---------- */
:is(html.cg-dark-mode, html:has(> body.dark-mode)) ::-webkit-scrollbar-track {
  background-color: #0b1120;
}

:is(html.cg-dark-mode, html:has(> body.dark-mode)) ::-webkit-scrollbar-thumb {
  background-color: #34405e;
}