/* ==========================================================================
   i-Reserve admin skin — "default" (classic)
   IRES-14218 fase 2. This file is the TOKEN CONTRACT: every --ires-* token the
   admin uses is declared here, so a skin never has to be complete and the
   bridge (theme-bridge.css) can map safely.

   Every value below is deliberately the value the classic admin already
   computes today (Bootstrap 5.3 defaults / dhtmlx defaults), so loading this
   file plus the bridge changes NOTHING visually. A skin overrides the values,
   never the mapping. Light = :root, dark = [data-bs-theme="dark"].

   Vocabulary (keep these apart):
     --bs-*         Bootstrap. Fed by the bridge, never set outside it.
     --ires-brand-* Product-mode brand values from ProductMode/{brandstyle}.
     --ires-*       THESE — the admin design tokens. A skin sets these.
     --ires_*       ires-core-library host knobs. Mapped once in the bridge.
   ========================================================================== */

:root {
    /* — Brand / accent — */
    --ires-primary:        #0d6efd;
    --ires-primary-rgb:    13, 110, 253;   /* literal triplet — CSS cannot derive it from the hex */
    --ires-primary-soft:   #e7f1ff;
    --ires-on-primary:     #fff;

    /* — Neutrals / surfaces — */
    --ires-bg:             #fff;      /* app canvas          */
    --ires-surface:        #fff;      /* cards, rows         */
    --ires-surface-2:      #f8f9fa;   /* subtle fill / hover */
    --ires-surface-hover:  #f1f3f5;   /* neutral hover       */
    --ires-sidebar:        #f8f9fa;   /* sidebar panel       */
    --ires-border:         #dee2e6;
    --ires-text:           #212529;
    --ires-muted:          rgba(33, 37, 41, .75);
    --ires-faint:          rgba(33, 37, 41, .5);

    /* — Status — */
    --ires-success:        #198754;   --ires-success-soft: #d1e7dd;
    --ires-warning:        #ffc107;   --ires-warning-soft: #fff3cd;
    --ires-danger:         #dc3545;   --ires-danger-soft:  #f8d7da;
    --ires-info:           #0dcaf0;   --ires-info-soft:    #cff4fc;
    --ires-on-success:     #fff;
    --ires-on-warning:     #000;      /* amber is light — dark label */
    --ires-on-danger:      #fff;
    --ires-on-info:        #000;
    /* Neutral action colour — Bootstrap's secondary. Used by the search-filter button skin. */
    --ires-secondary:      #6c757d;
    --ires-on-secondary:   #fff;

    /* — UI — */
    --ires-link:           #0d6efd;
    --ires-link-hover:     #0a58ca;
    --ires-focus-ring:     0 0 0 .25rem rgba(13, 110, 253, .25);
    --ires-input-bg:       #fff;
    --ires-input-border:   #dee2e6;
    --ires-placeholder:    rgba(33, 37, 41, .5);
    --ires-row-hover:      rgba(0, 0, 0, .075);
    --ires-zebra:          #f8f8f8;
    --ires-nav-hover:      rgba(0, 0, 0, .05);
    --ires-nav-active-bg:  #0d6efd;
    --ires-nav-active-fg:  #fff;
    --ires-disabled-fg:    #6c757d;
    --ires-disabled-bg:    #e9ecef;

    /* — Radius (Bootstrap scale) — */
    --ires-radius-sm:      .25rem;
    --ires-radius-md:      .375rem;
    --ires-radius-lg:      .5rem;
    --ires-radius-xl:      1rem;
    --ires-radius-pill:    50rem;

    /* — Spacing (4px base) — */
    --ires-space-1: 4px;  --ires-space-2: 8px;  --ires-space-3: 12px;
    --ires-space-4: 16px; --ires-space-5: 24px; --ires-space-6: 32px;

    /* — Elevation — */
    --ires-shadow-sm: 0 .125rem .25rem rgba(0, 0, 0, .075);
    --ires-shadow:    0 .5rem 1rem rgba(0, 0, 0, .15);

    /* — Expression tokens. A palette alone cannot carry a design language: the difference between
         two admin designs is as much "are section titles quiet uppercase labels or plain headings",
         "do cards lift or sit flat behind a hairline". Those are declared here as values with a
         no-op default, and consumed once in theme-bridge.css, so a skin still ships tokens rather
         than another sheet of selectors. — */
    --ires-label-transform: none;        /* card + block titles: none | uppercase              */
    --ires-label-tracking:  normal;
    /* inherit, not a value: the defaults have to leave a title exactly as its own CSS sized it,
       otherwise the classic skin would quietly restyle every card header and dashboard block. */
    --ires-label-size:      inherit;
    --ires-label-weight:    inherit;
    --ires-label-color:     inherit;
    --ires-heading-tracking: normal;     /* h1-h6: a grotesque often wants slightly tighter      */
    --ires-row-divider:     transparent; /* hairline between table rows instead of zebra        */

    /* — Type. The system stack stays as the fallback, so an install whose font files fail to load
         still renders exactly as it did before. — */
    --ires-font-body:    'Source Sans 3', system-ui, -apple-system, "Segoe UI", Roboto,
                         "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif,
                         "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    --ires-font-display: var(--ires-font-body);
    --ires-font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
                         "Liberation Mono", "Courier New", monospace;

    /* — Integration tokens — third-party widgets whose own defaults differ from the
         semantic tokens above. Declared separately so the bridge can map them
         unconditionally while the classic look stays byte-identical. — */
    /* dhtmlx suite derives every surface from an HSL triplet, so it needs numbers, not colors. */
    --ires-dhx-h-bg: 0;        --ires-dhx-s-bg: 0%;       --ires-dhx-l-bg: 100%;
    --ires-dhx-h-primary: 200; --ires-dhx-s-primary: 98%; --ires-dhx-l-primary: 40%;
    --ires-dhx-font-secondary:  rgba(0, 0, 0, .5);
    --ires-dhx-font-additional: rgba(0, 0, 0, .3);
    --ires-grid-header-bg:      var(--dhx-background-secondary);
}

/* ==========================================================================
   DARK — Bootstrap 5.3 color-mode neutrals, so the classic admin has a
   coherent dark palette the moment a skin is activated. The remaining light
   literals in the base CSS are tokenised in fase 3 (IRES-14218).
   ========================================================================== */
[data-bs-theme="dark"] {
    --ires-primary:        #6ea8fe;
    --ires-primary-rgb:    110, 168, 254;
    --ires-primary-soft:   #031633;
    --ires-on-primary:     #000;

    --ires-bg:             #212529;
    --ires-surface:        #2b3035;
    --ires-surface-2:      #343a40;
    --ires-surface-hover:  #3a4046;
    --ires-sidebar:        #2b3035;
    --ires-border:         #495057;
    --ires-text:           #dee2e6;
    --ires-muted:          rgba(222, 226, 230, .75);
    --ires-faint:          rgba(222, 226, 230, .5);

    --ires-success:        #75b798;   --ires-success-soft: #051b11;
    --ires-warning:        #ffda6a;   --ires-warning-soft: #332701;
    --ires-danger:         #ea868f;   --ires-danger-soft:  #2c0b0e;
    --ires-info:           #6edff6;   --ires-info-soft:    #032830;
    --ires-on-success:     #000;
    --ires-on-warning:     #000;
    --ires-on-danger:      #000;
    --ires-on-info:        #000;
    --ires-secondary:      #8c959e;
    --ires-on-secondary:   #000;

    --ires-link:           #6ea8fe;
    --ires-link-hover:     #8bb9fe;
    --ires-focus-ring:     0 0 0 .25rem rgba(110, 168, 254, .25);
    --ires-input-bg:       #2b3035;
    --ires-input-border:   #495057;
    --ires-placeholder:    rgba(222, 226, 230, .5);
    --ires-row-hover:      rgba(255, 255, 255, .075);
    --ires-zebra:          #262a2e;
    --ires-nav-hover:      rgba(255, 255, 255, .06);
    --ires-nav-active-bg:  #6ea8fe;
    --ires-nav-active-fg:  #000;
    --ires-disabled-fg:    #6c757d;
    --ires-disabled-bg:    #343a40;

    --ires-shadow-sm: 0 .125rem .25rem rgba(0, 0, 0, .3);
    --ires-shadow:    0 .5rem 1rem rgba(0, 0, 0, .4);
    --ires-row-divider: transparent;

    --ires-dhx-h-bg: 210;      --ires-dhx-s-bg: 11%;      --ires-dhx-l-bg: 15%;
    --ires-dhx-h-primary: 217; --ires-dhx-s-primary: 98%; --ires-dhx-l-primary: 71%;
    --ires-dhx-font-secondary:  rgba(222, 226, 230, .72);
    --ires-dhx-font-additional: rgba(222, 226, 230, .55);
    --ires-grid-header-bg:      var(--ires-bg);
}

/* ==========================================================================
   LEGACY CHROME (IRES-14218 fase 3)

   The pre-token admin CSS carries its own palette: i-Reserve green #93c30f, blue #1f6c89, and
   some twenty shades of grey — one per spot, grown over the years. Those files now read their
   colour as `var(--ires-legacy-x, #original)`.

   The trick is WHERE these are declared. In light they are deliberately NOT declared, so every
   `var()` falls through to the literal that was already there and the classic admin renders
   pixel-for-pixel as before. They ARE declared for dark, because there is no classic dark to
   preserve — the legacy palette simply collapses onto the skin's semantic tokens, plus a
   lightened version of the two i-Reserve identity colours so the product still reads as itself.

   That also makes the convergence in fase 4 a one-file edit: declare these in :root pointing at
   the semantic tokens, review the result, done — no second sweep through 59 CSS files.

   A skin is expected to declare the whole set for light as well (see themes/gasto/css/theme.css),
   otherwise its screens keep showing i-Reserve's greys.
   ========================================================================== */
[data-bs-theme="dark"] {
    /* Identity colours — lightened for contrast on a dark surface, hue kept. */
    --ires-legacy-primary:      #a5d61a;   /* light: #93c30f */
    --ires-legacy-on-primary:   #10160a;
    --ires-legacy-link:         #7fc3dd;   /* light: #1f6c89 */

    /* Neutrals — no reason for a second palette in dark: follow the semantic tokens. */
    --ires-legacy-text:         var(--ires-text);
    --ires-legacy-muted:        var(--ires-muted);
    --ires-legacy-faint:        var(--ires-faint);
    --ires-legacy-border:       var(--ires-border);
    --ires-legacy-surface:      var(--ires-surface);
    --ires-legacy-surface-2:    var(--ires-surface-2);
    --ires-legacy-sidebar:      var(--ires-sidebar);
    --ires-legacy-row-hover:    var(--ires-row-hover);
    --ires-legacy-nav-hover:    var(--ires-nav-hover);
    --ires-legacy-disabled-bg:  var(--ires-disabled-bg);
    --ires-legacy-disabled-fg:  var(--ires-disabled-fg);

    /* Status. */
    --ires-legacy-success:      var(--ires-success);
    --ires-legacy-success-soft: var(--ires-success-soft);
    --ires-legacy-danger:       var(--ires-danger);
    --ires-legacy-danger-soft:  var(--ires-danger-soft);
    --ires-legacy-warning:      var(--ires-warning);
    --ires-legacy-info:         var(--ires-info);
}
