/* ============================================================================
   BreezeFSM / MyShop / ERP - MODERN DESIGN SYSTEM
   design-system.css - theme tokens. Load FIRST of the six.

   ---------------------------------------------------------------------------
   THE ONE RULE THAT MAKES THIS SAFE
   ---------------------------------------------------------------------------
   Every selector in this file and its five siblings is scoped under

       [data-bz-theme="nextgen"]   or   [data-bz-theme="dark"]

   on <html>. "Standard" sets data-bz-theme="standard", which NOTHING here
   matches - so the default experience is byte-for-byte the application as it
   is today. A user who never touches the switch cannot be affected by any of
   this, and turning the switch back to Standard is a complete, guaranteed
   revert with no cache to clear.

   That is deliberate. A re-skin of 733 existing views cannot be proven safe by
   inspection; it can only be made safe by being opt-in and instantly
   reversible.

   ---------------------------------------------------------------------------
   WHY data-bz-theme AND NOT data-theme
   ---------------------------------------------------------------------------
   data-theme is ALREADY IN USE by login-modern.css, where it means light/dark
   only (:root[data-theme="dark"], :root:not([data-theme="light"]) under
   prefers-color-scheme). Overloading it with a third value would have made
   every one of those existing rules mis-fire.

   So the app theme gets its own attribute, and bz-theme.js sets BOTH:

       Standard -> data-bz-theme="standard"  data-theme="light"
       Modern   -> data-bz-theme="nextgen"    data-theme="light"
       Dark     -> data-bz-theme="dark"      data-theme="dark"

   Pinning data-theme rather than leaving it absent is what makes the choice
   stick: without it, a machine set to dark at OS level would drag the sign-in
   screen dark through prefers-color-scheme even after the user had explicitly
   chosen Standard. An explicit choice must beat an ambient one.

   ---------------------------------------------------------------------------
   BROWSER FLOOR: CHROME 59 (per Docs/UI-Design-System.md)
   ---------------------------------------------------------------------------
   Custom properties (49+), CSS Grid (57+) and -webkit-backdrop-filter (47+)
   are all in. Deliberately NOT used anywhere in these files:
     :has()            105+
     gap on flexbox    84+   (grid-gap on GRID is 57+ and is used)
     display:contents  65+
     color-mix / oklch far newer
   Every backdrop-filter is paired with an opaque-enough background so the
   panel is still readable when the blur is ignored.
   ============================================================================ */

/* ---------------------------------------------------------------------------
   1. MODERN (light) - the palette from the brief
--------------------------------------------------------------------------- */
[data-bz-theme="nextgen"] {
    --bz-primary:        #2563EB;
    --bz-primary-600:    #1D4ED8;
    --bz-primary-700:    #1E40AF;
    --bz-secondary:      #3B82F6;
    --bz-accent:         #60A5FA;

    --bz-sidebar-from:   #061B55;
    --bz-sidebar-to:     #03113D;

    --bz-bg:             #F4F8FF;
    --bz-bg-2:           #EAF2FF;
    --bz-surface:        #FFFFFF;
    --bz-surface-2:      #F8FBFF;

    --bz-text:           #14213D;
    --bz-muted:          #64748B;
    --bz-heading:        #0F1B36;

    --bz-success:        #22C55E;
    --bz-success-ink:    #15803D;
    --bz-warning:        #F59E0B;
    --bz-warning-ink:    #B45309;
    --bz-danger:         #EF4444;
    --bz-danger-ink:     #B91C1C;
    --bz-info:           #3B82F6;

    --bz-border:         #DCE7F7;
    --bz-border-2:       #C7D9F0;
    --bz-ring:           rgba(37, 99, 235, .28);

    /* Glass. The rgba background is what a browser without backdrop-filter
       falls back to, so it is opaque enough to read against on its own. */
    --bz-glass:          rgba(255, 255, 255, .78);
    --bz-glass-2:        rgba(255, 255, 255, .62);
    --bz-glass-brd:      rgba(255, 255, 255, .70);
    --bz-blur:           14px;

    --bz-shadow-sm:      0 1px 2px rgba(15, 27, 54, .06), 0 1px 3px rgba(15, 27, 54, .05);
    --bz-shadow:         0 4px 14px rgba(15, 27, 54, .07), 0 2px 6px rgba(15, 27, 54, .04);
    --bz-shadow-lg:      0 18px 44px rgba(15, 27, 54, .12), 0 6px 16px rgba(15, 27, 54, .06);
    --bz-shadow-brand:   0 8px 22px rgba(37, 99, 235, .28);

    --bz-r-sm:  8px;
    --bz-r:     12px;
    --bz-r-lg:  16px;
    --bz-r-xl:  22px;
    --bz-r-pill: 999px;

    --bz-s-1: 4px;  --bz-s-2: 8px;  --bz-s-3: 12px; --bz-s-4: 16px;
    --bz-s-5: 20px; --bz-s-6: 24px; --bz-s-7: 32px; --bz-s-8: 40px;

    --bz-font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;

    --bz-page-max: 1920px;   /* UHD-ready: content stops widening, never clips */

    --bz-ease: cubic-bezier(.22, .61, .36, 1);
    --bz-t:    .18s;
}

/* ---------------------------------------------------------------------------
   2. DARK - same system, inverted surfaces.

   Not a filter and not an inversion: every surface, border and ink is
   restated. Brand blue is LIGHTENED (#2563EB fails contrast on a dark ground;
   #60A5FA passes), and the status colours move to their 400-level tints for
   the same reason. Getting this wrong is how dark modes end up unreadable
   exactly where they matter - on a danger button.
--------------------------------------------------------------------------- */
[data-bz-theme="dark"] {
    --bz-primary:        #60A5FA;
    --bz-primary-600:    #3B82F6;
    --bz-primary-700:    #2563EB;
    --bz-secondary:      #3B82F6;
    --bz-accent:         #93C5FD;

    --bz-sidebar-from:   #0A1633;
    --bz-sidebar-to:     #050D22;

    --bz-bg:             #0B1220;
    --bz-bg-2:           #0F1829;
    --bz-surface:        #131C2E;
    --bz-surface-2:      #172236;

    --bz-text:           #E6EDF8;
    --bz-muted:          #94A3B8;
    --bz-heading:        #F1F6FD;

    --bz-success:        #4ADE80;
    --bz-success-ink:    #86EFAC;
    --bz-warning:        #FBBF24;
    --bz-warning-ink:    #FCD34D;
    --bz-danger:         #F87171;
    --bz-danger-ink:     #FCA5A5;
    --bz-info:           #60A5FA;

    --bz-border:         #24324A;
    --bz-border-2:       #33445F;
    --bz-ring:           rgba(96, 165, 250, .34);

    --bz-glass:          rgba(19, 28, 46, .82);
    --bz-glass-2:        rgba(19, 28, 46, .66);
    --bz-glass-brd:      rgba(148, 163, 184, .18);
    --bz-blur:           14px;

    --bz-shadow-sm:      0 1px 2px rgba(0, 0, 0, .40);
    --bz-shadow:         0 4px 14px rgba(0, 0, 0, .45);
    --bz-shadow-lg:      0 18px 44px rgba(0, 0, 0, .55);
    --bz-shadow-brand:   0 8px 22px rgba(37, 99, 235, .45);

    --bz-r-sm:  8px;
    --bz-r:     12px;
    --bz-r-lg:  16px;
    --bz-r-xl:  22px;
    --bz-r-pill: 999px;

    --bz-s-1: 4px;  --bz-s-2: 8px;  --bz-s-3: 12px; --bz-s-4: 16px;
    --bz-s-5: 20px; --bz-s-6: 24px; --bz-s-7: 32px; --bz-s-8: 40px;

    --bz-font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;

    --bz-page-max: 1920px;

    --bz-ease: cubic-bezier(.22, .61, .36, 1);
    --bz-t:    .18s;

    /* Tells the browser to paint dark form controls, scrollbars and
       autofill. Without it Chrome autofill stays bright yellow-white on a
       dark field - the single most common dark-mode complaint. */
    color-scheme: dark;
}

/* ---------------------------------------------------------------------------
   3. PAGE GROUND
--------------------------------------------------------------------------- */
[data-bz-theme="nextgen"] body,
[data-bz-theme="dark"] body {
    background-color: var(--bz-bg);
    color: var(--bz-text);
    font-family: var(--bz-font);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Soft brand wash behind everything. Fixed so it does not scroll away on a
   long grid; sized so it never tiles. */
[data-bz-theme="nextgen"] body {
    background-image:
        radial-gradient(1200px 620px at 82% -8%,  rgba(96, 165, 250, .20), transparent 60%),
        radial-gradient(980px  520px at -6% 12%,  rgba(37, 99, 235,  .13), transparent 62%);
    background-attachment: fixed;
    background-repeat: no-repeat;
}

[data-bz-theme="dark"] body {
    background-image:
        radial-gradient(1200px 620px at 82% -8%,  rgba(37, 99, 235, .20), transparent 60%),
        radial-gradient(980px  520px at -6% 12%,  rgba(96, 165, 250, .09), transparent 62%);
    background-attachment: fixed;
    background-repeat: no-repeat;
}

[data-bz-theme="nextgen"] h1, [data-bz-theme="nextgen"] h2,
[data-bz-theme="nextgen"] h3, [data-bz-theme="nextgen"] h4,
[data-bz-theme="dark"] h1, [data-bz-theme="dark"] h2,
[data-bz-theme="dark"] h3, [data-bz-theme="dark"] h4 {
    color: var(--bz-heading);
    font-family: var(--bz-font);
}

/* :not(.btn) - a link styled as a button keeps its own ink; see the note
   in theme-dark-guard.css. */
[data-bz-theme="nextgen"] a:not(.btn),
[data-bz-theme="dark"] a:not(.btn) { color: var(--bz-primary); }

[data-bz-theme="nextgen"] a:hover,
[data-bz-theme="dark"] a:hover { color: var(--bz-primary-600); }

/* ---------------------------------------------------------------------------
   4. ACCESSIBILITY

   One visible focus ring for everything, replacing the assorted per-control
   outlines. :focus-visible is not in Chrome 59, so :focus carries the ring and
   :focus-visible refines it where supported - a browser that ignores the
   second block still shows a ring, which is the safe direction to fail.
--------------------------------------------------------------------------- */
[data-bz-theme="nextgen"] :focus,
[data-bz-theme="dark"] :focus {
    outline: 2px solid var(--bz-primary);
    outline-offset: 2px;
}

[data-bz-theme="nextgen"] :focus:not(:focus-visible),
[data-bz-theme="dark"] :focus:not(:focus-visible) {
    outline: none;
}

[data-bz-theme="nextgen"] :focus-visible,
[data-bz-theme="dark"] :focus-visible {
    outline: 2px solid var(--bz-primary);
    outline-offset: 2px;
}

/* Honour the OS "reduce motion" setting across the whole theme. */
@media (prefers-reduced-motion: reduce) {
    [data-bz-theme="nextgen"] *,
    [data-bz-theme="dark"] * {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}

/* Screen-reader-only helper for the new wrappers. */
[data-bz-theme="nextgen"] .bz-sr,
[data-bz-theme="dark"] .bz-sr {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------------------
   5. PRINT - drop the glass, keep the data.
--------------------------------------------------------------------------- */
@media print {
    [data-bz-theme="nextgen"] body,
    [data-bz-theme="dark"] body {
        background: #fff !important;
        color: #000 !important;
    }
    [data-bz-theme="nextgen"] .sideNavigation,
    [data-bz-theme="dark"]   .sideNavigation,
    [data-bz-theme="nextgen"] .headerMain,
    [data-bz-theme="dark"]   .headerMain,
    [data-bz-theme="nextgen"] .bz-theme-switch,
    [data-bz-theme="dark"]   .bz-theme-switch { display: none !important; }

    /* -----------------------------------------------------------------------
       THE RULE ABOVE IS NOT ENOUGH ON ITS OWN.   [2026-09-12]
       -----------------------------------------------------------------------
       `body { color: #000 }` loses to every dark rule that names an element:
       those are both MORE SPECIFIC and !important, so specificity decides and
       body loses. Measured across the dark stylesheets, 1,869 colour and
       background declarations resolve through var(), which meant a page
       printed from Dark put LIGHT GREY TEXT ON WHITE PAPER.

       Flipping the TOKENS corrects all 1,869 without editing one selector -
       every rule stays exactly as written and simply resolves to paper values.
       Nothing here selects an element, so it cannot move a pixel on screen,
       and Standard matches none of it.

       What is deliberately NOT corrected: 37 colours written as literals
       rather than tokens. A token cannot reach those. Nearly all are header
       and nav chrome already hidden above, or transient overlays (datepicker,
       select2, autocomplete) that never reach paper. The remainder are white
       ink on buttons - and Standard has exactly the same white ink there
       (bootstrap ships `.btn-primary{color:#fff}`), so that is pre-existing
       print behaviour for every theme, not something Dark introduced. */
    [data-bz-theme="dark"] {
        --bz-bg:           #fff;
        --bz-bg-2:         #fff;
        --bz-surface:      #fff;
        --bz-surface-2:    #fff;
        --bz-glass:        #fff;
        --bz-glass-2:      #fff;

        --bz-text:         #000;
        --bz-heading:      #000;
        --bz-muted:        #333;

        --bz-border:       #999;
        --bz-border-2:     #777;
        --bz-glass-brd:    #999;

        /* Status inks keep their MEANING but move to the dark end of the ramp:
           #4ADE80 is chosen to sit on #131C2E and is unreadable on paper. */
        --bz-success-ink:  #14532D;
        --bz-warning-ink:  #7C2D12;
        --bz-danger-ink:   #7F1D1D;

        /* Glow and lift are screen affordances and only muddy a print. */
        --bz-shadow-sm:    none;
        --bz-shadow:       none;
        --bz-shadow-lg:    none;
        --bz-shadow-brand: none;
    }
}

/* ===========================================================================
   6. VIBRANCE LAYER  [2026-09-11]
   ---------------------------------------------------------------------------
   The flat token set above produced a Modern theme that read as "Standard with
   rounder corners". These tokens add the depth the design brief actually asks
   for: a saturated brand ramp, gradient fills for primary surfaces, and two
   texture washes.

   All of it is still TOKENS ONLY - nothing here selects an element, so this
   block cannot move a pixel on its own and Standard remains untouched.

   Gradients are declared as full `linear-gradient(...)` values rather than
   as stop colours, because a custom property holding a complete gradient can
   be dropped straight into `background-image` by any consumer. Chrome 59 is
   fine with that; it is plain variable substitution.
--------------------------------------------------------------------------- */
[data-bz-theme="nextgen"] {
    /* Brand ramp - deeper and more saturated than the flat #2563EB so that a
       gradient built from it has somewhere to travel. */
    --bz-brand-900:  #041640;
    --bz-brand-800:  #072265;
    --bz-brand-700:  #0B2F8E;
    --bz-brand-600:  #1340BE;
    --bz-brand-500:  #2563EB;
    --bz-brand-400:  #4F86F5;
    --bz-brand-300:  #8FB6FB;

    /* Sidebar: the deep blue column from the brief, not slate. */
    --bz-sidebar-grad: linear-gradient(180deg, #0B2F8E 0%, #072265 46%, #041640 100%);
    --bz-sidebar-ink:  #EAF1FF;
    --bz-sidebar-dim:  rgba(234, 241, 255, .68);
    --bz-sidebar-active-grad: linear-gradient(135deg, #2563EB 0%, #1340BE 100%);
    --bz-sidebar-hover-bg:    rgba(255, 255, 255, .09);

    /* Page ground: a tinted wash, not flat white. Two very wide radial stops
       plus the base colour - this is what stops large screens looking empty. */
    --bz-page-grad:
        radial-gradient(1200px 620px at 8% -6%,  rgba(79, 134, 245, .16) 0%, rgba(79, 134, 245, 0) 62%),
        radial-gradient(1000px 560px at 102% 4%, rgba(37, 99, 235, .13) 0%, rgba(37, 99, 235, 0) 60%),
        linear-gradient(180deg, #F2F7FF 0%, #E9F1FE 100%);

    /* Primary action fill. */
    --bz-btn-grad:        linear-gradient(135deg, #2F6BF6 0%, #1D4ED8 100%);
    --bz-btn-grad-hover:  linear-gradient(135deg, #1D4ED8 0%, #1340BE 100%);
    --bz-success-grad:    linear-gradient(135deg, #22C55E 0%, #15A349 100%);
    --bz-warning-grad:    linear-gradient(135deg, #FBA918 0%, #F97316 100%);
    --bz-danger-grad:     linear-gradient(135deg, #F4604F 0%, #DC2626 100%);

    /* Hero / page-title banner - the wide gradient plate in the brief. */
    --bz-hero-grad:
        radial-gradient(720px 300px at 88% 50%, rgba(255, 255, 255, .55) 0%, rgba(255, 255, 255, 0) 70%),
        linear-gradient(105deg, #E8F0FF 0%, #DCE9FF 38%, #CFE0FF 68%, #C3D8FF 100%);
    --bz-hero-ink: #0B2F8E;

    /* Elevation with a brand cast rather than neutral grey - this is most of
       what makes the surface read as "HD" instead of "flat card". */
    --bz-shadow-sm:   0 1px 2px rgba(11, 47, 142, .07), 0 1px 3px rgba(11, 47, 142, .06);
    --bz-shadow:      0 6px 18px rgba(11, 47, 142, .09), 0 2px 6px rgba(11, 47, 142, .05);
    --bz-shadow-lg:   0 22px 52px rgba(11, 47, 142, .15), 0 8px 18px rgba(11, 47, 142, .08);
    --bz-shadow-brand:0 10px 26px rgba(37, 99, 235, .32);

    --bz-surface-grad: linear-gradient(180deg, #FFFFFF 0%, #FBFDFF 100%);
    --bz-hairline:     rgba(11, 47, 142, .10);

    /* ---------------------------------------------------------------------
       BRAND FILL AND ITS INK - always use these two together
       ---------------------------------------------------------------------
       --bz-primary is a TEXT colour. In Dark it is deliberately lightened
       (#60A5FA) so it passes on a dark ground - which makes it the WRONG
       value to put behind a white label: white on #60A5FA is 2.54:1, a clear
       failure. Any filled brand surface (a selected grid row, an active tab,
       a hovered menu item) must use --bz-primary-fill with
       --bz-on-primary, never --bz-primary with a hardcoded #FFFFFF.
       Both themes resolve to an AA pair:
           Modern  #FFFFFF on #2563EB = 5.17:1
           Dark    #FFFFFF on #2563EB = 5.17:1
    --------------------------------------------------------------------- */
    --bz-primary-fill: #2563EB;
    --bz-on-primary:   #FFFFFF;
}

[data-bz-theme="dark"] {
    --bz-brand-900:  #0A1B3E;
    --bz-brand-800:  #10265A;
    --bz-brand-700:  #17357E;
    --bz-brand-600:  #2049A8;
    --bz-brand-500:  #3B82F6;
    --bz-brand-400:  #60A5FA;
    --bz-brand-300:  #93C5FD;

    --bz-sidebar-grad: linear-gradient(180deg, #101C36 0%, #0B1426 52%, #070E1D 100%);
    --bz-sidebar-ink:  #E6EDF8;
    --bz-sidebar-dim:  rgba(230, 237, 248, .62);
    --bz-sidebar-active-grad: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
    --bz-sidebar-hover-bg:    rgba(255, 255, 255, .07);

    --bz-page-grad:
        radial-gradient(1200px 620px at 8% -6%,  rgba(59, 130, 246, .13) 0%, rgba(59, 130, 246, 0) 62%),
        radial-gradient(1000px 560px at 102% 4%, rgba(96, 165, 250, .10) 0%, rgba(96, 165, 250, 0) 60%),
        linear-gradient(180deg, #0B1220 0%, #0D1524 100%);

    /* [2026-09-11] CONTRAST FIX. These were #3B82F6->#2563EB and
       #60A5FA->#3B82F6. Measured against the #FFFFFF label they carry:
           #3B82F6  3.68:1   AA-large only
           #60A5FA  2.54:1   FAIL - worse than the 3:1 non-text minimum
       In DARK the brand ramp is LIGHTENED so it can be read as TEXT on a dark
       ground; the same light blue used as a FILL behind white text inverts the
       problem. A dark theme therefore needs a separate, DARKER fill ramp, and
       hover darkens rather than lightens - which is also the better affordance
       here, since a lighter hover on a dark UI reads as glare.
       Now 5.17:1 / 6.70:1 and 6.70:1 / 8.72:1 - AA on every stop. */
    --bz-btn-grad:        linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
    --bz-btn-grad-hover:  linear-gradient(135deg, #1D4ED8 0%, #1E40AF 100%);
    --bz-success-grad:    linear-gradient(135deg, #22C55E 0%, #16A34A 100%);
    --bz-warning-grad:    linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    --bz-danger-grad:     linear-gradient(135deg, #EF4444 0%, #DC2626 100%);

    --bz-hero-grad:
        radial-gradient(720px 300px at 88% 50%, rgba(96, 165, 250, .16) 0%, rgba(96, 165, 250, 0) 70%),
        linear-gradient(105deg, #16213A 0%, #1A2947 42%, #1E3157 72%, #22386A 100%);
    --bz-hero-ink: #DCE9FF;

    --bz-surface-grad: linear-gradient(180deg, #16203300 0%, #16203300 100%), linear-gradient(180deg, #141E31 0%, #111A2B 100%);
    --bz-hairline:     rgba(148, 163, 184, .16);

    /* See the note in the Modern block. Dark keeps the SAME fill as Modern on
       purpose: it is dark enough to carry white at 5.17:1 and still reads as
       the brand. Using the lightened --bz-primary here is the bug this pair
       exists to prevent. */
    --bz-primary-fill: #2563EB;
    --bz-on-primary:   #FFFFFF;
}
