/* ═══════════════════════════════════════════════════════════════════════════
   Khadma theme
   Every visual decision in the dashboard and the shop, in three layers.
   Change a value here and it changes everywhere; components never hard-code
   their own.

   1. Foundations  brand colours, neutrals, corners, depth, type, spacing.
                   The brand colours themselves are set in Services/
                   KhadmaTheme.cs (MudBlazor publishes them as --mud-palette-*),
                   so MudBlazor's own parts and ours always agree.
   2. Meaning      what a colour is for: borders, muted text, status tones.
   3. Components   one small set per shared component (Components/Shared and
                   the MudBlazor parts), read only by components.css. To restyle
                   one kind of thing - every card, every chip - edit its block.

   The style guide page (/style-guide) shows all of it on one screen.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    /* ── 1. Foundations ──────────────────────────────────────────────────── */

    /* Brand and signal colours, from KhadmaTheme.cs. */
    --kh-primary: var(--mud-palette-primary);
    --kh-secondary: var(--mud-palette-secondary);
    --kh-success: var(--mud-palette-success);
    --kh-info: var(--mud-palette-info);
    --kh-warning: var(--mud-palette-warning);
    --kh-danger: var(--mud-palette-error);
    --kh-purple: #594ae2;

    /* Brand shades beyond the theme's primary. */
    --kh-primary-strong: #1f6458;
    --kh-primary-dark: #0e5c50;
    --kh-primary-deep: #0f2c28;
    --kh-primary-wash: #e0faf5;
    --kh-primary-light: #46b98d;
    --kh-accent-warm: #d08a2f;

    /* Neutrals. */
    --kh-bg: #f4f7f6;   /* the page behind the cards: a light neutral leaning green */
    --kh-surface: #ffffff;
    --kh-surface-soft: #f7fbfa;
    --kh-text: #13322e;
    --kh-text-soft: #4e6e69;
    --kh-shadow-ink: 9, 36, 34;

    /* Ink for text on a tinted background, one per meaning. */
    --kh-ink-success: #1f7355;
    --kh-ink-info: #2b6c93;
    --kh-ink-warning: #8a5a0e;
    --kh-ink-danger: #a3402f;
    --kh-ink-purple: #6d4a94;

    /* Corners: controls and small tiles, cards and panels, large blocks. */
    --kh-radius-sm: 8px;
    --kh-radius: 12px;
    --kh-radius-lg: 16px;
    --kh-radius-pill: 999px;

    /* Depth: resting cards, things lifted on hover, sheets and pop-ups. */
    --kh-shadow-sm: 0 1px 3px rgba(var(--kh-shadow-ink), .08), 0 4px 12px -6px rgba(var(--kh-shadow-ink), .12);
    --kh-shadow-md: 0 14px 28px -18px rgba(var(--kh-shadow-ink), .6);
    --kh-shadow-lg: 0 24px 48px -24px rgba(var(--kh-shadow-ink), .55);

    /* Type: one family, one scale, three weights for emphasis. */
    --kh-font: "Roboto", "Noto Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
    --kh-fs-2xs: .68rem;
    --kh-fs-xs: .74rem;
    --kh-fs-sm: .82rem;
    --kh-fs-md: .92rem;
    --kh-fs-base: 1rem;
    --kh-fs-lg: 1.15rem;
    --kh-fs-xl: 1.3rem;
    --kh-fs-2xl: 1.6rem;
    --kh-fs-3xl: 2rem;
    --kh-weight-medium: 600;
    --kh-weight-bold: 700;
    --kh-weight-heavy: 800;

    /* Spacing steps, for gaps and padding. */
    --kh-space-1: 4px;
    --kh-space-2: 8px;
    --kh-space-3: 12px;
    --kh-space-4: 16px;
    --kh-space-5: 20px;
    --kh-space-6: 24px;

    /* ── 2. Meaning ──────────────────────────────────────────────────────── */

    --kh-border: color-mix(in srgb, var(--kh-primary) 20%, transparent);
    --kh-divider: var(--mud-palette-divider);
    --kh-text-muted: var(--mud-palette-text-secondary);
    --kh-hover: color-mix(in srgb, var(--kh-primary) 6%, transparent);
    --kh-focus-ring: 0 0 0 2px var(--kh-primary);

    /* Status tones: background and text for each stage of anything that moves
       (orders, deliveries, tickets, ads). StatusBadge reads these. */
    --kh-tone-new-bg: color-mix(in srgb, var(--kh-warning) 18%, transparent);
    --kh-tone-new: var(--kh-ink-warning);
    --kh-tone-progress-bg: color-mix(in srgb, var(--kh-info) 16%, transparent);
    --kh-tone-progress: var(--kh-ink-info);
    --kh-tone-ready-bg: color-mix(in srgb, var(--kh-success) 18%, transparent);
    --kh-tone-ready: var(--kh-ink-success);
    --kh-tone-transit-bg: color-mix(in srgb, var(--kh-primary) 16%, transparent);
    --kh-tone-transit: var(--kh-primary);
    --kh-tone-done-bg: color-mix(in srgb, var(--kh-success) 16%, transparent);
    --kh-tone-done: var(--kh-ink-success);
    --kh-tone-bad-bg: color-mix(in srgb, var(--kh-danger) 14%, transparent);
    --kh-tone-bad: var(--kh-ink-danger);
    --kh-tone-neutral-bg: color-mix(in srgb, var(--kh-text-soft) 12%, transparent);
    --kh-tone-neutral: var(--kh-text-soft);

    /* ── 3. Components ───────────────────────────────────────────────────── */

    /* PageHeader */
    --kh-page-title-size: var(--kh-fs-2xl);
    --kh-page-title-weight: var(--kh-weight-heavy);
    --kh-page-sub-size: var(--kh-fs-md);
    --kh-page-head-gap: var(--kh-space-5);

    /* SectionCard, and every raised MudBlazor panel on a page */
    --kh-card-bg: var(--mud-palette-surface);
    --kh-card-border: 1px solid var(--kh-border);
    --kh-card-radius: var(--kh-radius);
    --kh-card-shadow: var(--kh-shadow-sm);
    --kh-card-padding: 18px;
    --kh-card-padding-compact: 10px;
    --kh-card-title-size: var(--kh-fs-lg);
    --kh-card-title-weight: var(--kh-weight-bold);

    /* StatCard */
    --kh-stat-padding: var(--kh-space-4);
    --kh-stat-radius: var(--kh-card-radius);
    --kh-stat-label-size: var(--kh-overline-size);
    --kh-stat-value-size: 1.7rem;
    --kh-stat-value-weight: var(--kh-weight-heavy);
    --kh-stat-accent-width: 4px;

    /* StatusBadge */
    --kh-badge-radius: var(--kh-radius-pill);
    --kh-badge-padding: 3px 10px;
    --kh-badge-size: var(--kh-fs-xs);
    --kh-badge-weight: var(--kh-weight-bold);

    /* FilterChip */
    --kh-chip-radius: var(--kh-radius-pill);
    --kh-chip-padding: 7px 16px;
    --kh-chip-padding-sm: 5px 13px;
    --kh-chip-size: .86rem;
    --kh-chip-size-sm: var(--kh-fs-sm);
    --kh-chip-weight: var(--kh-weight-medium);
    --kh-chip-bg: var(--mud-palette-surface);
    --kh-chip-border: var(--kh-divider);
    --kh-chip-text: var(--kh-text-muted);
    --kh-chip-on-bg: var(--kh-primary);
    --kh-chip-on-text: #fff;

    /* SegmentedControl */
    --kh-segment-radius: var(--kh-radius-pill);
    --kh-segment-border: var(--kh-divider);
    --kh-segment-padding: 6px 14px;
    --kh-segment-size: var(--kh-fs-sm);
    --kh-segment-weight: var(--kh-weight-medium);
    --kh-segment-text: var(--kh-text-muted);
    --kh-segment-on-bg: var(--kh-primary);
    --kh-segment-on-text: #fff;

    /* FilterBar: the bar above a list */
    --kh-filterbar-gap: var(--kh-space-2);
    --kh-filterbar-padding: 12px;
    --kh-filterbar-height: var(--kh-button-height);
    --kh-filterbar-search-width: 380px;
    --kh-filterbar-search-min: 240px;
    --kh-filterbar-filter-min: 140px;
    --kh-filterbar-label-color: var(--kh-text-soft);
    /* Addon: the tinted box at the start of a field that names it or gives its
       unit ("Vendor", "EGP"), split from the value by a hairline. */
    --kh-addon-bg: color-mix(in srgb, var(--kh-primary) 7%, var(--mud-palette-surface));
    --kh-addon-bg-focus: color-mix(in srgb, var(--kh-primary) 14%, var(--mud-palette-surface));
    --kh-addon-text: var(--kh-primary-strong);
    --kh-addon-divider: var(--kh-field-border);
    --kh-addon-padding: 0 12px;
    --kh-addon-weight: var(--kh-weight-bold);
    --kh-filterbar-label-size: var(--kh-fs-sm);

    /* PagerBar: the pager under every table */
    --kh-pager-padding: 10px 16px;
    --kh-pager-border: 1px solid var(--kh-divider);
    --kh-pager-btn-size: 34px;
    --kh-pager-btn-radius: var(--kh-radius-sm);
    --kh-pager-btn-text: var(--kh-text-soft);
    --kh-pager-btn-border: color-mix(in srgb, var(--kh-text) 10%, transparent);
    --kh-pager-btn-hover: color-mix(in srgb, var(--kh-primary) 8%, transparent);
    --kh-pager-on-bg: var(--kh-primary);
    --kh-pager-on-text: #fff;
    --kh-pager-size: var(--kh-fs-sm);

    /* EmptyState */
    --kh-empty-padding: 40px 16px;
    --kh-empty-padding-compact: 24px 12px;
    --kh-empty-icon-size: 2.6rem;

    /* Buttons. Every MudButton is one of four kinds, picked by its Variant
       and Color (see the style guide):
         primary    Variant.Filled                       the one main action
         secondary  Variant.Outlined                     other actions
         ghost      Variant.Text (Default or Primary)    cancel, back, small links
         danger     Color.Error, any Variant             delete, reject, sign out
       Size.Small / Medium / Large set the height. */
    --kh-button-radius: var(--kh-radius-sm);
    --kh-button-weight: var(--kh-weight-medium);
    --kh-button-gap: 8px;
    --kh-button-height-sm: 32px;
    --kh-button-height: 38px;
    --kh-button-height-lg: 46px;
    --kh-button-pad-sm: 12px;
    --kh-button-pad: 16px;
    --kh-button-pad-lg: 22px;
    --kh-button-size-sm: var(--kh-fs-sm);
    --kh-button-size: .9rem;
    --kh-button-size-lg: var(--kh-fs-base);
    --kh-button-focus-ring: 0 0 0 3px color-mix(in srgb, var(--kh-primary) 28%, transparent);
    --kh-button-disabled-opacity: .45;

    --kh-button-primary-bg: var(--kh-primary);
    --kh-button-primary-bg-hover: var(--kh-primary-strong);
    --kh-button-primary-text: #fff;
    --kh-button-primary-shadow: 0 1px 2px rgba(var(--kh-shadow-ink), .18), inset 0 1px 0 rgba(255, 255, 255, .14);

    --kh-button-secondary-bg: var(--mud-palette-surface);
    --kh-button-secondary-bg-hover: color-mix(in srgb, var(--kh-primary) 6%, var(--mud-palette-surface));
    --kh-button-secondary-border: var(--kh-field-border);
    --kh-button-secondary-border-hover: var(--kh-field-hover-border);
    --kh-button-secondary-text: var(--kh-text);
    --kh-button-secondary-icon: var(--kh-primary);
    --kh-button-secondary-shadow: 0 1px 2px rgba(var(--kh-shadow-ink), .06);

    --kh-button-ghost-text: var(--kh-text-soft);
    --kh-button-ghost-brand-text: var(--kh-primary-strong);
    --kh-button-ghost-bg-hover: color-mix(in srgb, var(--kh-text) 6%, transparent);
    --kh-button-ghost-brand-bg-hover: color-mix(in srgb, var(--kh-primary) 9%, transparent);

    --kh-button-danger: var(--kh-danger);
    --kh-button-danger-strong: var(--kh-ink-danger);
    --kh-button-danger-wash: color-mix(in srgb, var(--kh-danger) 9%, transparent);

    /* MudBlazor form fields */
    --kh-field-radius: var(--kh-radius);
    --kh-field-size: .95rem;
    --kh-field-hover-border: color-mix(in srgb, var(--kh-primary) 55%, transparent);
    --kh-field-focus-ring: 0 0 0 3px color-mix(in srgb, var(--kh-primary) 16%, transparent);
    --kh-field-bg: var(--mud-palette-surface);
    --kh-field-border: color-mix(in srgb, var(--kh-text) 15%, transparent);
    --kh-field-pad-y: 10px;
    /* The label sits above the box, never inside it; this is its room. */
    --kh-field-label-space: 22px;
    --kh-field-label-size: var(--kh-label-size);

    /* MudBlazor tabs */
    --kh-tab-size: var(--kh-fs-md);
    --kh-tab-weight: var(--kh-weight-medium);
    --kh-tab-text: var(--kh-text-soft);
    --kh-tab-active: var(--kh-primary);
    --kh-tab-icon-size: 1.15rem;

    /* Row actions (the small buttons at the end of a table row): quiet until
       hovered, then tinted with what they do. */
    --kh-row-action-size: 32px;
    --kh-row-action-bg: transparent;
    --kh-row-action-border: transparent;
    --kh-row-action-icon: var(--kh-text-soft);
    --kh-row-action-hover-bg: color-mix(in srgb, var(--kh-text) 7%, transparent);

    /* Dropdown lists: every select, autocomplete and menu */
    --kh-menu-bg: var(--mud-palette-surface);
    --kh-menu-radius: var(--kh-radius);
    --kh-menu-border: 1px solid color-mix(in srgb, var(--kh-text) 9%, transparent);
    --kh-menu-shadow: 0 16px 36px -14px rgba(var(--kh-shadow-ink), .35), 0 2px 8px rgba(var(--kh-shadow-ink), .07);
    --kh-menu-gap: 6px;
    --kh-menu-min-width: 200px;
    --kh-menu-padding: 6px;
    --kh-menu-item-radius: var(--kh-radius-sm);
    --kh-menu-item-padding: 7px 12px;
    --kh-menu-item-height: 34px;
    --kh-menu-item-size: .85rem;
    --kh-menu-item-hover: color-mix(in srgb, var(--kh-primary) 7%, transparent);
    --kh-menu-item-selected-bg: color-mix(in srgb, var(--kh-primary) 12%, transparent);
    --kh-menu-item-selected-text: var(--kh-primary-strong);
    --kh-menu-item-selected-weight: var(--kh-weight-medium);
    --kh-menu-check: var(--kh-primary);
    --kh-menu-scrollbar: color-mix(in srgb, var(--kh-text) 22%, transparent);

    /* MudBlazor tables */
    --kh-table-radius: var(--kh-radius);
    --kh-table-head-size: var(--kh-overline-size);
    --kh-table-head-weight: var(--kh-weight-bold);
    --kh-table-head-color: var(--kh-overline-color);
    /* Opaque, so a header that sticks while rows scroll under it hides them. */
    --kh-table-head-bg: color-mix(in srgb, var(--kh-primary) 4%, var(--mud-palette-surface));
    --kh-table-head-border: 1px solid var(--kh-divider);
    --kh-table-row-hover: var(--kh-hover);
    /* Cell padding on wide screens (rows become cards below 960px). */
    --kh-table-cell-pad-block: 10px;
    --kh-table-cell-pad-inline: 12px;
    --kh-table-edge-padding: 16px;


    /* Labels. Two voices, used everywhere: a field label names one input; an
       overline names a group (table heads, stat cards, menu sections). */
    --kh-label-size: var(--kh-fs-sm);
    --kh-label-weight: var(--kh-weight-medium);
    --kh-label-color: var(--kh-text-soft);
    --kh-overline-size: var(--kh-fs-2xs);
    --kh-overline-weight: var(--kh-weight-bold);
    --kh-overline-tracking: .07em;
    --kh-overline-case: uppercase;
    --kh-overline-color: color-mix(in srgb, var(--kh-text-soft) 85%, transparent);

    /* Icons. A plain icon takes the text colour; an icon in a tile (stat
       cards, section heads) sits on a soft wash of its accent. */
    --kh-icon-size: 1.25rem;
    --kh-icon-tile-size: 20px;
    --kh-icon-tile-padding: 8px;
    --kh-icon-tile-radius: var(--kh-radius-sm);
    --kh-icon-tile-tint: 13%;

    /* Tags: every MudChip, whatever Variant or Color a page gave it, is one
       soft pill tinted by its colour. */
    --kh-tag-radius: var(--kh-radius-pill);
    --kh-tag-size: var(--kh-fs-xs);
    --kh-tag-weight: var(--kh-weight-medium);
    --kh-tag-height: 26px;
    --kh-tag-tint: 13%;
    --kh-tag-edge: 24%;

    /* Sidebar (the staff menu): deep brand green, light text, the current
       page a solid green pill. */
    --kh-sidebar-bg: linear-gradient(180deg, #22594f 0%, #1b4a42 100%);
    --kh-sidebar-text: rgba(255, 255, 255, .78);
    --kh-sidebar-text-strong: #fff;
    --kh-sidebar-icon: rgba(255, 255, 255, .6);
    --kh-sidebar-caption: rgba(255, 255, 255, .5);
    --kh-sidebar-hover: rgba(255, 255, 255, .09);
    --kh-sidebar-active-bg: #349483;
    --kh-sidebar-active-text: #fff;
    --kh-sidebar-active-shadow: 0 6px 16px -6px rgba(0, 0, 0, .45);
    --kh-sidebar-divider: rgba(255, 255, 255, .08);
    --kh-sidebar-item-radius: var(--kh-radius-sm);

    /* The signed-in person in the top bar */
    --kh-avatar-size: 36px;
    --kh-avatar-bg: var(--kh-primary);
    --kh-avatar-text: #fff;

    /* Top bar of the staff dashboard: white with a hairline, like the shop's. */
    --kh-appbar-bg: var(--mud-palette-surface);
    --kh-appbar-text: var(--kh-text);
    --kh-appbar-border: 1px solid color-mix(in srgb, var(--kh-text) 8%, transparent);

    /* MudBlazor dialogs and alerts */
    --kh-dialog-radius: var(--kh-radius-lg);
    --kh-alert-radius: var(--kh-radius);
}
