/* ============================================================================
   dashboard.css - KPI grids, chart containers, glass widgets.
   Load LAST of the six.

   Scope note: the Command Center and Report Center are NOT themed by this
   file. They render through their own layout
   (~/Areas/MYSHOP/Views/CommandCenter/_CommandCenter.cshtml), which does not
   carry the theme attribute, so nothing here can reach them - by design, and
   enforced by structure rather than by a selector anyone has to remember.

   This file is for the OTHER dashboards: FSM, module landing screens, and any
   new executive page built on the .dashboard-card vocabulary.
   ============================================================================ */

/*  [2026-09-11] backdrop-filter REMOVED - CONTAINING-BLOCK HAZARD.
    ---------------------------------------------------------------------------
    backdrop-filter creates a CONTAINING BLOCK for absolutely-positioned
    descendants. DevExpress computes a dropdown's position in DOCUMENT
    coordinates and applies them as position:absolute; left/top. When an
    ancestor becomes the containing block those coordinates are re-interpreted
    relative to THAT element, so the dropdown is displaced by exactly the
    ancestor's offset from the document origin.

    That is what broke the Branch dropdown on /Myshop/ShopList/Index: .backBox
    is the standard content panel - 242 views use it - and ShopList alone holds
    14 GridLookup controls inside one. The bug appeared in Modern and Dark and
    not in Standard purely because these rules are theme-scoped, which is the
    clearest possible signal that the theme caused it.

    Removing the filter is visually safe by the design's own account: the
    --bz-glass tokens in design-system.css are documented as "opaque enough to
    read against on its own" precisely so the effect can degrade. Over a dark
    page a blurred translucent panel and a flat translucent one are nearly
    indistinguishable, so this costs almost nothing.

    RULE: backdrop-filter may only be used on a floating overlay that can never
    contain a positioned widget. In practice that is the loader scrim, and
    nothing else.
*/


/* ---------------------------------------------------------------------------
   1. KPI GRID
   auto-fit + minmax gives a responsive dashboard with no breakpoints and no
   column classes: 4 across on a desktop, 2 on a tablet, 1 on a phone, decided
   by available width rather than by a guess about the device.
--------------------------------------------------------------------------- */
[data-bz-theme="nextgen"] .kpi-grid,
[data-bz-theme="dark"] .kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    grid-gap: var(--bz-s-4);
    margin-bottom: var(--bz-s-5);
}

@media (max-width: 575px) {
    [data-bz-theme="nextgen"] .kpi-grid,
    [data-bz-theme="dark"] .kpi-grid { grid-template-columns: 1fr; }
}

/* On a very wide screen let the cards grow but cap the count so a 4K display
   does not produce nine hairline columns. */
@media (min-width: 1900px) {
    [data-bz-theme="nextgen"] .kpi-grid,
    [data-bz-theme="dark"] .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
}

/* ---------------------------------------------------------------------------
   2. KPI CARD
--------------------------------------------------------------------------- */
[data-bz-theme="nextgen"] .kpi-card,
[data-bz-theme="dark"] .kpi-card {
    position: relative;
    overflow: hidden;
    padding: var(--bz-s-5);
    border-radius: var(--bz-r-lg);
    background: var(--bz-glass);
    border: 1px solid var(--bz-glass-brd);
    box-shadow: var(--bz-shadow);
    transition: transform var(--bz-t) var(--bz-ease), box-shadow var(--bz-t) var(--bz-ease);
}

[data-bz-theme="nextgen"] .kpi-card:hover,
[data-bz-theme="dark"] .kpi-card:hover {
    /* [2026-09-11] transform REMOVED. Like backdrop-filter, a non-none
       transform makes the element a CONTAINING BLOCK for absolutely-positioned
       descendants - but only WHILE HOVERED, which makes it far nastier to
       diagnose: reaching a combo inside the card means hovering the card, so
       the containing block appears at the exact moment the dropdown opens and
       vanishes again when the pointer leaves. The box-shadow below already
       carries the hover affordance on its own. */
    box-shadow: var(--bz-shadow-lg);
}

/* Corner wash. pointer-events:none so it can never swallow a click on a card
   that is itself a link - the classic decorative-overlay bug. */
[data-bz-theme="nextgen"] .kpi-card::after,
[data-bz-theme="dark"] .kpi-card::after {
    content: "";
    position: absolute;
    top: -40px; right: -40px;
    width: 130px; height: 130px;
    border-radius: 50%;
    background-image: radial-gradient(circle, rgba(37, 99, 235, .14) 0%, transparent 70%);
    pointer-events: none;
}

[data-bz-theme="nextgen"] .kpi-card .kpi-ico,
[data-bz-theme="dark"] .kpi-card .kpi-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px; height: 42px;
    border-radius: var(--bz-r);
    margin-bottom: var(--bz-s-3);
    font-size: 17px;
    color: #fff;
    background-image: linear-gradient(135deg, var(--bz-primary) 0%, var(--bz-primary-700) 100%);
    box-shadow: var(--bz-shadow-brand);
}

[data-bz-theme="nextgen"] .kpi-card .kpi-ico.is-success,
[data-bz-theme="dark"] .kpi-card .kpi-ico.is-success {
    background-image: linear-gradient(135deg, #22C55E 0%, #15803D 100%);
    box-shadow: 0 8px 22px rgba(34, 197, 94, .30);
}
[data-bz-theme="nextgen"] .kpi-card .kpi-ico.is-warning,
[data-bz-theme="dark"] .kpi-card .kpi-ico.is-warning {
    background-image: linear-gradient(135deg, #F59E0B 0%, #B45309 100%);
    box-shadow: 0 8px 22px rgba(245, 158, 11, .30);
    color: #1F2937;
}
[data-bz-theme="nextgen"] .kpi-card .kpi-ico.is-danger,
[data-bz-theme="dark"] .kpi-card .kpi-ico.is-danger {
    background-image: linear-gradient(135deg, #EF4444 0%, #B91C1C 100%);
    box-shadow: 0 8px 22px rgba(239, 68, 68, .30);
}

[data-bz-theme="nextgen"] .kpi-card .kpi-label,
[data-bz-theme="dark"] .kpi-card .kpi-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--bz-muted);
}

[data-bz-theme="nextgen"] .kpi-card .kpi-value,
[data-bz-theme="dark"] .kpi-card .kpi-value {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -.6px;
    line-height: 1.12;
    color: var(--bz-heading);
    margin: 4px 0 2px;
    /* Tabular figures stop a live-updating number jittering as digits change. */
    font-variant-numeric: tabular-nums;
}

[data-bz-theme="nextgen"] .kpi-card .kpi-sub,
[data-bz-theme="dark"] .kpi-card .kpi-sub { font-size: 12.5px; color: var(--bz-muted); }

[data-bz-theme="nextgen"] .kpi-card .kpi-trend.is-up,
[data-bz-theme="dark"] .kpi-card .kpi-trend.is-up { color: var(--bz-success-ink); font-weight: 600; }

[data-bz-theme="nextgen"] .kpi-card .kpi-trend.is-down,
[data-bz-theme="dark"] .kpi-card .kpi-trend.is-down { color: var(--bz-danger-ink); font-weight: 600; }

/* ---------------------------------------------------------------------------
   3. CHART CONTAINER
   A chart canvas needs a parent with a REAL height. Chart.js and DevExpress
   both read the parent box; a percentage height against an auto-height parent
   resolves to zero and the chart silently never paints.
--------------------------------------------------------------------------- */
[data-bz-theme="nextgen"] .chart-card,
[data-bz-theme="dark"] .chart-card {
    background: var(--bz-glass);
    border: 1px solid var(--bz-glass-brd);
    border-radius: var(--bz-r-lg);
    box-shadow: var(--bz-shadow);
    padding: var(--bz-s-5);
    margin-bottom: var(--bz-s-5);
}

[data-bz-theme="nextgen"] .chart-card > .chart-head,
[data-bz-theme="dark"] .chart-card > .chart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--bz-s-4);
}

[data-bz-theme="nextgen"] .chart-card > .chart-head h3,
[data-bz-theme="dark"] .chart-card > .chart-head h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--bz-heading);
}

[data-bz-theme="nextgen"] .chart-body,
[data-bz-theme="dark"] .chart-body { position: relative; height: 320px; }

[data-bz-theme="nextgen"] .chart-body.is-tall,
[data-bz-theme="dark"] .chart-body.is-tall { height: 440px; }

@media (max-width: 767px) {
    [data-bz-theme="nextgen"] .chart-body,
    [data-bz-theme="dark"] .chart-body { height: 240px; }
}

/* ---------------------------------------------------------------------------
   4. DASHBOARD LAYOUT HELPERS
--------------------------------------------------------------------------- */
[data-bz-theme="nextgen"] .dash-grid-2,
[data-bz-theme="dark"] .dash-grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    grid-gap: var(--bz-s-5);
}

@media (max-width: 767px) {
    [data-bz-theme="nextgen"] .dash-grid-2,
    [data-bz-theme="dark"] .dash-grid-2 { grid-template-columns: 1fr; }
}

/* Empty state - shown instead of a blank panel when a widget has no data. */
[data-bz-theme="nextgen"] .dash-empty,
[data-bz-theme="dark"] .dash-empty {
    text-align: center;
    padding: var(--bz-s-8) var(--bz-s-5);
    color: var(--bz-muted);
    font-size: 13.5px;
}

/* Skeleton shimmer for loading widgets. The animation is disabled wholesale by
   the prefers-reduced-motion block in design-system.css. */
[data-bz-theme="nextgen"] .dash-skeleton,
[data-bz-theme="dark"] .dash-skeleton {
    border-radius: var(--bz-r-sm);
    background-image: linear-gradient(90deg,
        rgba(148, 163, 184, .10) 25%,
        rgba(148, 163, 184, .20) 37%,
        rgba(148, 163, 184, .10) 63%);
    background-size: 400% 100%;
    animation: bz-shimmer 1.4s ease-in-out infinite;
    min-height: 14px;
}

@keyframes bz-shimmer {
    0%   { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}
