/* =============================================================================
   CRMIS - themes.
   Tout passe par des variables : un nouveau theme ou une nouvelle couleur
   principale ne touche que ce fichier.
   - Theme : <html data-theme="light|dark">, absent = celui du systeme.
   - Couleur principale : <html data-accent="agroplus|foret|ocean|ardoise|aubergine">.
   ============================================================================= */

/* --- Couleurs principales : une valeur pour le clair (-l), une pour le sombre (-d) --- */
:root,
:root[data-accent="agroplus"] {
  --a-l: #22802f; --a-l-strong: #1a6624; --a-l-soft: #e3f1e4;
  --a-d: #4cbf5c; --a-d-strong: #72d27f; --a-d-soft: #1c3320;
}
:root[data-accent="foret"] {
  --a-l: #2f6f4f; --a-l-strong: #24563d; --a-l-soft: #e2eee7;
  --a-d: #5fae86; --a-d-strong: #84c7a4; --a-d-soft: #1b2e25;
}
:root[data-accent="ocean"] {
  --a-l: #0f7a72; --a-l-strong: #0b5f59; --a-l-soft: #dff0ee;
  --a-d: #2fb5a7; --a-d-strong: #5dcbbf; --a-d-soft: #142f2c;
}
:root[data-accent="ardoise"] {
  --a-l: #46617a; --a-l-strong: #364c60; --a-l-soft: #e6ecf1;
  --a-d: #8aa6c0; --a-d-strong: #a9c0d5; --a-d-soft: #1f2830;
}
:root[data-accent="aubergine"] {
  --a-l: #7a3f6e; --a-l-strong: #613257; --a-l-soft: #f2e6ef;
  --a-d: #c785b8; --a-d-strong: #d9a5cd; --a-d-soft: #2e1f2b;
}

/* --- Theme clair (defaut) --- */
:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --surface: #fcfcfb;
  --surface-2: #f0f2ee;
  --surface-3: #e6e9e3;
  --text: #0f1a12;
  --text-2: #4c564e;
  --muted: #7f877f;
  --border: rgba(15, 26, 18, 0.11);
  --border-strong: rgba(15, 26, 18, 0.20);
  --shadow: 0 1px 2px rgba(15, 26, 18, 0.06), 0 8px 24px rgba(15, 26, 18, 0.06);
  --shadow-lg: 0 20px 60px rgba(15, 26, 18, 0.18);
  --accent: var(--a-l);
  --accent-strong: var(--a-l-strong);
  --accent-soft: var(--a-l-soft);
  --on-accent: #ffffff;
  --danger: #c0392b;
  --danger-soft: #fbe9e7;

  /* Graphiques (palette categorielle validee, ordre fixe) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --grid: #e1e0d9;
  --axis: #c3c2b7;

  /* Environnements */
  --env-dev: #5a67d8;
  --env-test: #c77700;
  --env-prod: #c0392b;
}

/* --- Theme sombre : systeme sombre (sauf choix "clair"), ou choix "sombre" --- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e110f;
    --surface: #171a18;
    --surface-2: #1e2220;
    --surface-3: #282d2a;
    --text: #eef1ec;
    --text-2: #bcc4bd;
    --muted: #8a928b;
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.18);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.55);
    --accent: var(--a-d);
    --accent-strong: var(--a-d-strong);
    --accent-soft: var(--a-d-soft);
    --on-accent: #0b130d;
    --danger: #e66767;
    --danger-soft: #3a1d1c;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --grid: #2c2c2a;
    --axis: #383835;
    --env-dev: #8b95ee;
    --env-test: #f0a530;
    --env-prod: #ef6b5b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e110f;
  --surface: #171a18;
  --surface-2: #1e2220;
  --surface-3: #282d2a;
  --text: #eef1ec;
  --text-2: #bcc4bd;
  --muted: #8a928b;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.55);
  --accent: var(--a-d);
  --accent-strong: var(--a-d-strong);
  --accent-soft: var(--a-d-soft);
  --on-accent: #0b130d;
  --danger: #e66767;
  --danger-soft: #3a1d1c;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --grid: #2c2c2a;
  --axis: #383835;
  --env-dev: #8b95ee;
  --env-test: #f0a530;
  --env-prod: #ef6b5b;
}
