/* ==========================================================================
   MAKonnect theme - the one place for colours, fonts, sizes and radii.
   Rule (CLAUDE.md "Theme values live in one place"): CSS, <style> blocks and inline
   styles use these variables, never a literal hex or font. A missing role is added here.
   JS that needs a literal (charts, canvas): MakTheme.get('accent') in site.js.

   Loaded after bootstrap.min.css and before site.css (__ImportCssLibraries, _LoginLayout).
   Bootstrap and Syncfusion read the accent through tools/theme/apply-vendor-theme.py, which
   rewrites their hard-coded blue (#0d6efd family) to var(--mk-accent*) - run it again after
   replacing either vendor file.
   Status tones (StatusTones / order_statuses_tone in the DB) are kept as literals in site.css:
   they must match the palette the server writes.

   Themes (css/themes/README.md): a theme is one file css/themes/{key}.css that only sets
   --mk-* values under :root[data-theme="{key}"]; the layout adds the attribute and links the
   file right after this one. Check a theme with tools/theme/check-theme.py before shipping it.
   ========================================================================== */
:root, [data-bs-theme=light] {
    /* Accent - the one blue: buttons, links, selection, focus */
    --mk-accent: #2563EB;
    --mk-accent-rgb: 37, 99, 235;
    --mk-accent-hover: #1D4ED8;
    --mk-accent-active: #1E40AF;
    --mk-accent-active-rgb: 30, 64, 175;
    --mk-accent-strong: #1E3A8A;     /* text on a light accent background */
    --mk-accent-soft: #E8EEFF;       /* selected chip / row tint */
    --mk-accent-subtle: #DBEAFE;     /* Bootstrap bg-subtle, alerts */
    --mk-accent-border: #BFDBFE;     /* Bootstrap border-subtle */
    --mk-accent-focus: #93C5FD;      /* input border on focus */
    --mk-accent-ring: rgba(var(--mk-accent-rgb), .15);

    /* Text */
    --mk-text: #1D2430;
    --mk-text-2: #475569;            /* secondary, descriptions */
    --mk-muted: #64748B;             /* sub-lines, dates */

    /* Lines and surfaces */
    --mk-border: #DEE2E6;
    --mk-line: #EEF0F3;
    --mk-bg: #F6F7F9;
    --mk-track: #E5E7EB;             /* progress ring / bar track */
    --mk-ring-off: #CBD5E1;
    --mk-border-strong: #CBD5E1;     /* input frame, dashed upload area, chip group */
    --mk-surface: #FFFFFF;           /* card, panel, dropdown, modal, input */
    --mk-bg-2: #EEF1F4;              /* app page ground; pressed / active neutral fill */
    --mk-on-accent: #FFFFFF;         /* text/icon on a filled accent, ink or red */

    /* Signals: text / icon / background */
    --mk-ok: #166534;    --mk-ok-icon: #16A34A;    --mk-ok-bg: #DCFCE7;
    --mk-create: #15803D; --mk-create-hover: #166534;   /* the green "Erstellen" button of a list page (white text, 5.0:1) */
    --mk-warn: #92400E;  --mk-warn-icon: #D97706;  --mk-warn-bg: #FEF3C7;  --mk-warn-line: #FDE68A;
    --mk-bad: #9F1239;   --mk-bad-icon: #E11D48;   --mk-bad-bg: #FFE4E6;  --mk-bad-line: #FECDD3;
    --mk-note-bg: #FFFAEB;           /* internal note strip (team mail) - not a warning */
    --mk-note-line: #EFE4C2;         /* ruled line of a notebook page (notes cell, notes modal) */
    --mk-note-margin: #F4B9B2;       /* the red margin line of that page */

    /* Documents tab of a record page (record-documents.css): the tab's old literal values, kept so it looks the same.
       Follow-up F3 (docs/order-details/21-record-kit-plani.md) folds them into the roles above. */
    --mk-docs-head-bg: #F8F9FA;      /* the chosen file in the upload dialog */
    --mk-docs-text: #333333;         /* file name, drop area title */
    --mk-docs-muted: #6C757D;        /* drop area icon and formats line */
    --mk-docs-drop-line: #CCCCCC;    /* dashed drop area frame */
    --mk-docs-drop-bg: #FAFAFA;
    --mk-docs-badge-shadow: 0 1px 2px rgba(0, 0, 0, .05);
    --mk-docs-badge-line: rgba(0, 0, 0, .06);
    --mk-docs-info: #17A2B8;  --mk-docs-info-rgb: 23, 162, 184;  --mk-docs-info-strong: #138496;    /* preview button */
    --mk-docs-danger: #DC3545; --mk-docs-danger-rgb: 220, 53, 69; --mk-docs-danger-strong: #C82333; /* delete button, remove link */
    /* file-type badges: icon / background */
    --mk-ft-pdf: #DC3545;   --mk-ft-pdf-bg: #FFEBEE;
    --mk-ft-word: #2196F3;  --mk-ft-word-bg: #E3F2FD;
    --mk-ft-excel: #4CAF50; --mk-ft-excel-bg: #E8F5E9;
    --mk-ft-image: #00BCD4; --mk-ft-image-bg: #E0F7FA;
    --mk-ft-other: #6C757D; --mk-ft-other-bg: #F5F5F5;
    /* server-built document rows (K10b): rendered report, inbound B2B mail, its attachment (the old order tab's colours) */
    --mk-ft-report: #2196F3; --mk-ft-report-bg: #E3F2FD;
    --mk-ft-mail: #5C6BC0;   --mk-ft-mail-bg: #E8EAF6;
    --mk-ft-attachment: #E91E63; --mk-ft-attachment-bg: #FCE4EC;
    /* makAI source marker in lists (the robot button on an order made from a B2B mail) */
    --mk-ai: #A855F7; --mk-ai-strong: #7C3AED; --mk-ai-rgb: 168, 85, 247;

    /* Neon skin of the record page (record-neon.css): glow and hairline colours only, never text */
    --mk-neon-1: #6C5CE7;   --mk-neon-1-rgb: 108, 92, 231;    /* indigo-violet: the app's dark blue turned purple (17.11.2026) */
    --mk-neon-2: #764BA2;   --mk-neon-2-rgb: 118, 75, 162;    /* purple */
    --mk-neon-3: #F093FB;   --mk-neon-3-rgb: 240, 147, 251;   /* pink, accents only */
    --mk-neon-4: #A78BFA;   --mk-neon-4-rgb: 167, 139, 250;   /* bright violet: the middle of the tab rail's beam (glow only, never text) */

    /* Ink - the sidebar/navbar dark, also chat header, sent bubble, active dark chip */
    --mk-ink: #11101D;
    --mk-ink-rgb: 17, 16, 29;
    --mk-ink-hover: #1D1B31;
    --mk-ink-2: #2A2840;
    --mk-on-ink-fill: rgba(255, 255, 255, .12);   /* hover fill on ink */
    --mk-on-ink-line: rgba(255, 255, 255, .18);   /* divider on ink */
    --mk-on-ink-dim: rgba(255, 255, 255, .7);     /* dim text on ink */

    /* Sidebar palette (site.css SIDEBAR block reads it as --sb-*) */
    --mk-sb-panel: #1C1B2E;
    --mk-sb-line: #2C2A45;
    --mk-sb-text: #D9D8E6;
    --mk-sb-sub: #A9A8BF;
    --mk-sb-muted: #8A88A6;
    --mk-sb-icon: #9EA6C9;
    --mk-brand: #FF8C00;             /* MAKonnect orange: sidebar and makAI only, never content */
    --mk-brand-soft: #FFB466;

    /* Depth */
    --mk-shadow-sm: 0 2px 8px rgba(var(--mk-ink-rgb), .06);    /* resting card */
    --mk-shadow-md: 0 4px 12px rgba(var(--mk-ink-rgb), .12);   /* hover card, tooltip, small menu */
    --mk-shadow-lg: 0 12px 32px rgba(var(--mk-ink-rgb), .16);  /* popover, dropdown, dialog, drawer */
    --mk-overlay: rgba(var(--mk-ink-rgb), .45);                /* modal / drawer backdrop */
    --mk-rec-page-bg: rgba(var(--mk-ink-rgb), .03);            /* ground of a record page (record.css .rec-page) */

    /* Fonts - the same system stack Bootstrap and Syncfusion shipped with */
    --mk-font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans",
                    "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    --mk-font-mono: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

    /* Font sizes - px on purpose (rem would shrink under the 14px phone root). Half steps round up.
       Icon/glyph sizes are not text and stay literal. */
    --mk-fs-2xs: 10px;               /* avatar initials, badge, uppercase micro label only */
    --mk-fs-xs: 11px;                /* list sub-line */
    --mk-fs-sm: 12px;                /* list cell */
    --mk-fs-md: 13px;                /* card text */
    --mk-fs-base: 14px;              /* forms, settings, body-size text */
    --mk-fs-lg: 15px;
    --mk-fs-xl: 16px;
    --mk-fs-h3: 18px;
    --mk-fs-h2: 22px;
    --mk-fs-display: 28px;           /* KPI figures */

    /* Radii */
    --mk-radius-sm: 4px;             /* cell label */
    --mk-radius-btn: 5px;            /* icon button */
    --mk-radius-card: 10px;
    --mk-radius-pill: 999px;         /* chip, search, create button */

    /* Bootstrap reads the theme */
    --bs-primary: var(--mk-accent);
    --bs-primary-rgb: var(--mk-accent-rgb);
    --bs-primary-text-emphasis: var(--mk-accent-strong);
    --bs-primary-bg-subtle: var(--mk-accent-subtle);
    --bs-primary-border-subtle: var(--mk-accent-border);
    --bs-link-color: var(--mk-accent);
    --bs-link-color-rgb: var(--mk-accent-rgb);
    --bs-link-hover-color: var(--mk-accent-active);
    --bs-link-hover-color-rgb: var(--mk-accent-active-rgb);
    --bs-focus-ring-color: rgba(var(--mk-accent-rgb), .25);
    --bs-body-color: var(--mk-text);
    --bs-body-color-rgb: 29, 36, 48;
    --bs-secondary-color: var(--mk-muted);
    --bs-font-sans-serif: var(--mk-font-sans);
    --bs-font-monospace: var(--mk-font-mono);
}

/* --------------------------------------------------------------------------
   Derived tones - only while a theme is active (<html data-theme>).
   The standard look keeps the exact hand-picked values above; with a theme, the accent family
   follows --mk-accent so a theme file only has to set the base. A theme may still set any of
   these itself: its file is linked after this one with the same specificity, so it wins.
   The srgb mix percentages reproduce the standard blue as far as a mix can;
   tools/theme/check-theme.py --deviation prints formula vs hand-picked value (CIE76 dE).
   soft, subtle, strong are within ~2; border ~4 and focus ~7 come out slightly greyer;
   hover and active are matched on lightness and come out less saturated (the Tailwind darks
   gain saturation, which a mix with black cannot) - they are momentary states.
   -rgb triplets cannot be derived in CSS: a theme sets --mk-accent-rgb (and --mk-ink-rgb when
   it changes --mk-ink) itself. Link hover (--bs-link-hover-color-rgb) uses the accent rgb in a
   theme unless the theme sets --mk-accent-active-rgb (check-theme.py suggests the value).
   -------------------------------------------------------------------------- */
:root[data-theme] {
    --mk-accent-hover: color-mix(in srgb, var(--mk-accent) 85%, #000);
    --mk-accent-active: color-mix(in srgb, var(--mk-accent) 72%, #000);
    --mk-accent-active-rgb: var(--mk-accent-rgb);
    --mk-accent-strong: color-mix(in srgb, var(--mk-accent) 59%, #000);
    --mk-accent-soft: color-mix(in srgb, var(--mk-accent) 12%, #fff);
    --mk-accent-subtle: color-mix(in srgb, var(--mk-accent) 15%, #fff);
    --mk-accent-border: color-mix(in srgb, var(--mk-accent) 25%, #fff);
    --mk-accent-focus: color-mix(in srgb, var(--mk-accent) 40%, #fff);
}

/* SVG data URIs in bootstrap.min.css cannot read variables (T4). With a theme:
   - accordion chevron: the same SVG used as a mask, coloured by background-color;
   - form-switch focus knob (a light blue circle): the neutral unfocused knob instead - a mask
     would clip the whole switch; the focus ring (box-shadow) still shows the theme accent. */
:root[data-theme] .accordion-button::after {
    background-image: none;
    background-color: var(--mk-text);
    -webkit-mask: var(--bs-accordion-btn-icon) center / contain no-repeat;
    mask: var(--bs-accordion-btn-icon) center / contain no-repeat;
}
:root[data-theme] .accordion-button:not(.collapsed)::after {
    background-image: none;
    background-color: var(--mk-accent-strong);
    -webkit-mask-image: var(--bs-accordion-btn-active-icon);
    mask-image: var(--bs-accordion-btn-active-icon);
}
:root[data-theme] .form-switch .form-check-input:focus:not(:checked) {
    --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%280, 0, 0, 0.25%29'/%3e%3c/svg%3e");
}
