/*
 * Design tokens. Every page reads these, not color or shadow literals.
 *
 * The app is dark only: App.razor sets data-bs-theme="dark" on <html>. The colors are the FRAIT AI Blazor dark theme.
 *
 * Layout of this file:
 *   1. Colors     color and elevation tokens
 *   2. Bootstrap  Bootstrap 5.3 variables remapped onto the tokens
 *   3. Scales     spacing, radius, type, motion, z-index
 *   4. Base       body and heading rhythm
 *
 * Spacing sits on the 4px grid.
 */

/* ===== 1. Colors ===== */
:root,
[data-bs-theme="dark"] {
    color-scheme: dark;

    /* Surfaces, text and strokes follow Microsoft Teams dark mode (Fluent teamsDarkTheme grey ramp). The accent is the original
       FRAIT blue. Status colors are our own, kept vivid. */
    --surface-0: #1f1f1f;  /* page background, inputs */
    --surface-1: #292929;  /* cards, header */
    --surface-2: #333333;  /* card headers, hover rows */
    --surface-3: #3d3d3d;  /* raised or selected */
    --border: #3d3d3d;

    --text-1: #ebebeb;
    --text-2: #c8c8c8;
    --text-3: #a0a0a0;

    /* The accent marks titles, section headers, active states and focus. Primary is a deeper shade of it. */
    --primary: #4a8fac;
    --primary-hover: #6bb2ce;
    --on-primary: #ffffff;
    --accent: #6bb2ce;
    --accent-fill: #6bb2ce;  /* buttons */
    --info: #38bdf8;  /* chart marks and labels, not the brand accent */
    --info-text: #7dd3fc;

    /* Status. -soft is a badge or alert fill, -border its edge, -tint a stronger hover or active fill. */
    --success: #3fb950;
    --warn: #d29922;
    --danger: #f85149;
    --on-status: #001016;  /* text on a solid status fill */
    --success-soft: rgb(63 185 80 / 0.12);
    --success-border: rgb(63 185 80 / 0.3);
    --success-tint: color-mix(in srgb, var(--success) 20%, transparent);
    --warn-soft: rgb(210 153 34 / 0.12);
    --warn-border: rgb(210 153 34 / 0.3);
    --warn-tint: color-mix(in srgb, var(--warn) 20%, transparent);
    --danger-soft: rgb(248 81 73 / 0.12);
    --danger-border: rgb(248 81 73 / 0.3);
    --danger-tint: color-mix(in srgb, var(--danger) 20%, transparent);
    --accent-soft: rgb(107 178 206 / 0.12);
    --accent-border: color-mix(in srgb, var(--accent) 30%, transparent);
    --accent-tint: color-mix(in srgb, var(--accent) 20%, transparent);
    --info-soft: color-mix(in srgb, var(--info) 15%, transparent);

    /* Fills for elements that show their parent through: a faint lift (tint-1, tint-2) or a faint shade (tint-shade). */
    --tint-1: rgb(255 255 255 / 0.04);
    --tint-2: rgb(255 255 255 / 0.08);
    --tint-shade: rgb(0 0 0 / 0.25);
    --overlay: rgb(0 0 0 / 0.55);  /* behind a modal */

    /* Elevation. Dark separates layers by surface step alone, so cards, buttons and inputs carry no extra shadow or ring. */
    --shadow-sm: 0 0 2px rgb(0 0 0 / 0.24), 0 2px 4px rgb(0 0 0 / 0.28);
    --shadow-md: 0 0 2px rgb(0 0 0 / 0.24), 0 4px 8px rgb(0 0 0 / 0.28);
    --shadow-lg: 0 0 2px rgb(0 0 0 / 0.24), 0 8px 16px rgb(0 0 0 / 0.28);
    --elev-card: none;                 /* cards, panels, tables on a card */
    --elev-hero: var(--shadow-lg);     /* the one primary card on a page */
    --elev-btn: none;                  /* buttons at rest */
    --elev-btn-pressed: none;
    --elev-input: none;                /* text inputs at rest */
    --elev-pop: var(--shadow-lg);      /* dropdowns, popovers, flyouts, tooltips */
    --ring-focus: 0 0 0 0.2rem var(--accent-soft);  /* input focus glow */

    /* Components */
    --btn-bg: var(--surface-3);  /* button fill */
    --btn-edge-mix: white;       /* the color a hovered button border mixes toward */
    --card-title: var(--text-1);  /* card header title and icon */
    --card-icon: var(--text-2);
    --table-head-bg: var(--accent-soft);  /* column header row of a data table */
    --table-head-text: var(--text-2);
    --row-hover-bg: var(--accent-soft);
    --divider: var(--border);  /* lines between rows */
    --surface-nav: #1a1a1a;  /* sidebar: a step darker than the top bar */
    --nav-hover-bg: var(--surface-2);
    --nav-active-bg: var(--accent-soft);  /* current page link */
    --nav-active-text: var(--accent);
    --nav-group-text: var(--text-2);  /* sidebar group header */
    --nav-group-active-bg: transparent;  /* a closed sidebar group that holds the current page */
    --heat-0: var(--surface-2);  /* activity graph: a day with no entries; 1 to 4 step toward the accent */
    --heat-1: color-mix(in srgb, var(--accent) 30%, var(--surface-2));
    --heat-2: color-mix(in srgb, var(--accent) 55%, var(--surface-2));
    --heat-3: color-mix(in srgb, var(--accent) 78%, var(--surface-2));
    --heat-4: var(--accent);

}

/* ===== 2. Bootstrap ===== */
/* Bootstrap 5.3 reads [data-bs-theme]; these override its per-theme values with the tokens above. */
:root, [data-bs-theme] {
    --bs-body-bg: var(--surface-0);
    --bs-body-color: var(--text-1);
    --bs-secondary-color: var(--text-2);
    --bs-tertiary-bg: var(--surface-2);
    --bs-emphasis-color: var(--text-1);
    --bs-border-color: var(--border);
    --bs-link-color: var(--text-1);
    --bs-link-hover-color: var(--text-1);
    --bs-code-color: var(--text-1);
    --bs-card-bg: var(--surface-1);
    --bs-card-cap-bg: var(--surface-2);
    --bs-card-border-color: var(--border);
    --bs-form-control-bg: var(--surface-0);
    --bs-dropdown-bg: var(--surface-1);
    --bs-dropdown-border-color: var(--border);
    --bs-dropdown-link-color: var(--text-1);
    --bs-dropdown-link-hover-bg: var(--surface-2);
    --bs-table-color: var(--text-1);
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--border);
}

:root {
    --bs-body-font-family: var(--font-sans);
    --bs-body-font-size: var(--text-sm);
    --bs-body-line-height: 1.5;
    --bs-border-radius: var(--radius-sm);
    --bs-border-radius-sm: var(--radius-sm);
    --bs-border-radius-lg: var(--radius-md);
    --bs-border-radius-xl: var(--radius-lg);
    --bs-border-radius-pill: var(--radius-pill);
    --bs-box-shadow-sm: var(--shadow-sm);
    --bs-box-shadow: var(--shadow-md);
    --bs-box-shadow-lg: var(--shadow-lg);
}

/* ===== 3. Scales ===== */
:root {
    /* Spacing, 4px base. Matches Bootstrap utilities: 1=4, 2=8, 3=16, 4=24, 5=48 (rem equivalents). */
    --space-0: 0;
    --space-1: 0.25rem;  /*  4 */
    --space-2: 0.5rem;   /*  8 */
    --space-3: 0.75rem;  /* 12 */
    --space-4: 1rem;     /* 16 */
    --space-5: 1.25rem;  /* 20 */
    --space-6: 1.5rem;   /* 24 */
    --space-8: 2rem;     /* 32 */
    --space-10: 2.5rem;  /* 40 */
    --space-12: 3rem;    /* 48 */
    --space-16: 4rem;    /* 64 */

    /* Radius */
    --radius-sm: 0.25rem; /*  4 */
    --radius-md: 0.5rem;  /*  8 */
    --radius-lg: 0.75rem; /* 12 */
    --radius-pill: 999px;

    /* Fixed pill widths, so status and percent pills line up in columns whatever their text. */
    --badge-status-width: 5rem;   /* 80: fits "Off Track" */
    --badge-percent-width: 3.5rem; /* 56: fits "100%" and "99.5%" */

    /* Type ramp: size / line-height, all line-heights on the 4px grid at 16px root. */
    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif; /* page titles: the Carrier Search font */
    --text-xs: 0.75rem;   /* 12 / 16 */
    --text-sm: 0.875rem;  /* 14 / 20 */
    --text-base: 1rem;    /* 16 / 24 */
    --text-lg: 1.125rem;  /* 18 / 28 */
    --text-xl: 1.25rem;   /* 20 / 28 */
    --text-2xl: 1.5rem;   /* 24 / 32 */
    --text-3xl: 2rem;     /* 32 / 40 */

    /* Top bar brand: the logo's width and the product name's size beside it. */
    --brand-logo-width: 88px;
    --text-brand: 1.125rem;  /* 18 */

    --leading-xs: 1rem;
    --leading-sm: 1.25rem;
    --leading-base: 1.5rem;
    --leading-lg: 1.75rem;
    --leading-2xl: 2rem;
    --leading-3xl: 2.5rem;
    --weight-regular: 400;
    --weight-medium: 500;
    --weight-semibold: 600;

    /* Motion */
    --duration-fast: 150ms;
    --duration-base: 250ms;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);

    /* Layering */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-overlay: 1040;
    --z-drawer: 1050;
    --z-toast: 1080;
}

/* ===== 4. Base ===== */
body {
    background-color: var(--surface-0);
    color: var(--text-1);
}

h1, .h1 { font-size: var(--text-2xl); line-height: var(--leading-2xl); }
h2, .h2 { font-size: var(--text-xl);  line-height: var(--leading-lg); }
h3, .h3 { font-size: var(--text-lg);  line-height: var(--leading-lg); }
h4, .h4 { font-size: var(--text-base); line-height: var(--leading-base); }
h5, .h5 { font-size: var(--text-sm);  line-height: var(--leading-sm); }
h6, .h6 { font-size: var(--text-xs);  line-height: var(--leading-xs); }
/* Margin 0: the pages were built with Tailwind's reset, which zeroed heading margins. Spacing comes from layout or mb-* classes. */
h1, h2, h3, h4, h5, h6 { font-weight: var(--weight-semibold); margin: 0; }

small, .small { font-size: var(--text-sm); }
