/*
 * kd-theme.css — shared design-system foundation for the site-wide dark
 * redesign (2026-11-18, owner-approved, staging-ui branch only).
 *
 * SCOPE: variables + component classes only. Zero generic selectors
 * (body, .card, .btn, a, h1...) — every class below is new and prefixed
 * kd-ui- (verified via `grep -roE '\.kd-[a-zA-Z0-9_-]+'` across every
 * template: no existing class anywhere in the project starts with
 * "kd-ui-"). Loading this file has NO visual effect on any existing
 * page until that page's own markup is edited to use these classes.
 *
 * VARIABLE PREFIX: --kdt- (not --kd-), because home.html already
 * declares --kd-bg/--kd-card-bg/--kd-green/--kd-blue/--kd-red/--kd-amber/
 * --kd-text/--kd-text-muted/--kd-overlay-NN/--kd-on-card itself (scoped
 * to `html:has(.kd-dash), body:has(.kd-dash), .kd-dash` — main/templates/
 * home.html:129-154), so reusing the same --kd- names here would be a
 * real name collision. Owner-approved resolution: different prefix
 * (--kdt-), flagged here and in the delivery report.
 *
 * Real bug found live this round: this same comment block used to list
 * --kd-overlay- then immediately a star then immediately a slash then
 * --kd-on-card, with no separating space - that two-character sequence
 * silently closed this top doc-comment 18 lines early, corrupting
 * everything after it up through the whole :root block below, so every
 * single --kdt- variable resolved to nothing in a real browser (curl
 * can't catch this - it doesn't parse CSS at all). Confirmed via
 * Playwright: getComputedStyle(document.documentElement).getPropertyValue
 * applied to --kdt-blue returned an empty string, and :root was missing
 * entirely from document.styleSheets[...].cssRules. Fixed by never
 * placing those same two characters next to each other inside a comment
 * again, including in this very explanation.
 *
 * VALUES: sourced from the three owner-named reference surfaces —
 * bots/templates/instances.html (My Bots), main/templates/home.html
 * (Dashboard), templates/base.html (bottom nav / mobile sheet). Where
 * the two page-level implementations disagree on a --kd-* value, home.
 * html's own value wins (owner's explicit decision, this conversation).
 * Where only one page defines a given component at all (page title,
 * accordion row, empty state), that page's own value is used as-is —
 * there is no second value to reconcile against.
 *
 * Dark theme only — home.html's own light-mode override
 * (main/templates/home.html:965, `.kd-dash[data-theme="light"]`) is
 * untouched and not extended here; this file has no light variant.
 */

:root {
    /* ---- Backgrounds / borders ----
       Fix (owner-specified, this round): the owner picked ONE exact
       reference - the live /bots/ (My Bots) page's own grey, read
       straight from the v1.9-ui9 tag (git show
       v1.9-ui9:bots/templates/instances.html), not from memory:
         - page background: #262d39 (that page's own unscoped
           html/body/main/.container rule)
         - card/panel background: #20262f, border: rgba(255,255,255,.08)
           (.kd-bot-frame - the card each bot group renders in, sitting
           ON TOP of that #262d39 page)
       This is a deliberate swap from the previous scheme (page=#0b1220,
       "card" token=#262d39): #262d39 is now the PAGE color, so the old
       --kdt-bg/--kdt-card-bg value (also #262d39) HAD to move too, or
       every .kd-ui-card/.kd-ui-row using it would have become visually
       identical to the page behind it - exactly what the owner said
       must never happen ("cards must stay distinguishable"). */
    --kdt-bg: #20262f;
    --kdt-card-bg: #20262f;
    --kdt-card-border: rgba(255, 255, 255, 0.08);

    /* Single source of truth (owner-specified) for html/body/header/
       every page container's background, site-wide - see
       templates/base.html's own <head> <style> for where this is
       actually applied globally (header.bg-dark + html,body), so no
       individual page template needs its own override anymore. */
    --kdt-page-bg: #262d39;

    /* ---- Text ----
       Source: home.html:137-139. instances.html hardcodes #fff / 3
       different greys (#9aa4b2/#b8c1d1/#94a3b8) instead of a single
       muted token - home.html's single pair wins per the owner's
       conflict-resolution rule. */
    --kdt-text: #F3F4F6;
    --kdt-text-muted: #9CA3AF;

    /* ---- Accent colors ----
       Source: home.html:134-136. instances.html's status-dot green
       (#22c55e) matches; its start-button green (#16a34a) and its two
       different reds (#ef4444/#e57373) do not - home.html's single
       --kd-green/--kd-red wins for this shared status/PnL vocabulary. */
    --kdt-blue: #3B82F6;
    --kdt-green: #22C55E;
    --kdt-red: #EF4444;
    --kdt-amber: #F5A623;

    /* ---- White-overlay tints (for subtle fills on dark cards) ----
       Source: home.html:147-153, verbatim - instances.html has no
       equivalent token set (uses literal rgba(255,255,255,X) inline). */
    --kdt-overlay-03: rgba(255, 255, 255, 0.03);
    --kdt-overlay-05: rgba(255, 255, 255, 0.05);
    --kdt-overlay-06: rgba(255, 255, 255, 0.06);
    --kdt-overlay-07: rgba(255, 255, 255, 0.07);
    --kdt-overlay-08: rgba(255, 255, 255, 0.08);
    --kdt-overlay-12: rgba(255, 255, 255, 0.12);
    --kdt-on-card: #ffffff;

    /* ---- Typography ----
       Family: explicit copy of Bootstrap's own --bs-font-sans-serif
       (static/css/styles.css:57) - same stack, just not depended on via
       var(), so this file has zero coupling to Bootstrap ever changing
       that variable. */
    --kdt-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";

    /* Page title: only instances.html defines this role at all
       (.top-sheet-title, instances.html:63-67) - used as-is. */
    --kdt-font-size-title: 32px;
    --kdt-font-weight-title: 900;

    /* Section title: both pages define this role and disagree
       (instances.html:120-121 = 16px/800, home.html:232-233 = 15px/800)
       - home.html's value wins. */
    --kdt-font-size-section: 15px;
    --kdt-font-weight-section: 800;

    /* Body text: both pages agree exactly (instances.html .kd-card-name
       = 14px/700, home.html .kd-bot-name = 14px/700). */
    --kdt-font-size-body: 14px;
    --kdt-font-weight-body: 700;

    /* Small text: instances.html .kd-card-pnl = 12px/700. */
    --kdt-font-size-small: 12px;
    --kdt-font-weight-small: 700;

    /* Tiny text (badges only): home.html .kd-bot-badge = 10.5px/800. */
    --kdt-font-size-tiny: 10.5px;
    --kdt-font-weight-tiny: 800;

    /* ---- Geometry ----
       Card radius: both pages agree (instances.html:197, home.html:221
       = 12px each). Button radius: owner's own explicit value this
       round (10px) - instances.html's own .kd-card-btn already matches
       (instances.html:333); home.html's buttons (8px) are superseded by
       this explicit owner decision, not by the general --kd-* rule. */
    --kdt-radius-card: 12px;
    --kdt-radius-button: 10px;
    --kdt-radius-input: 8px;
    --kdt-radius-pill: 999px;

    /* ---- Spacing ----
       Source: instances.html's own card-list/card-head/card-actions
       rhythm (instances.html:192,207,326). */
    --kdt-spacing-card-list-gap: 8px;
    --kdt-spacing-row-head-pad: 10px 12px;
    --kdt-spacing-row-body-pad: 0 12px 12px;
}

/* ===================== Page ===================== */

/* Source: .kd-dash (home.html:155-159). */
.kd-ui-page {
    max-width: 1360px;
    margin: 0 auto;
    padding: 0 12px 24px;
    font-family: var(--kdt-font-family);
}

.kd-ui-page-title {
    font-size: var(--kdt-font-size-title);
    font-weight: var(--kdt-font-weight-title);
    color: var(--kdt-text);
}

/* ===================== Card ===================== */

/* Source: .kd-card, agrees exactly between instances.html:196-200 and
   home.html:218-222. */
.kd-ui-card {
    background: var(--kdt-card-bg);
    border: 1px solid var(--kdt-card-border);
    border-radius: var(--kdt-radius-card);
}

/* New this round (2026-11-18, owner-specified): the featured/
   highlighted plan - a dark blue gradient instead of the flat card
   background, used on both plans pages (Account, Prices) wherever
   plan.is_featured is true (the real field both pages already read
   for the existing badge_text pill - payments/models.py:28-29 - reused
   here rather than a new hardcoded plan-name/id check, see the
   delivery report for why). Add alongside .kd-ui-card (same radius/
   border-width), not instead of it - only background/border color
   differ. */
.kd-ui-card-featured {
    background: linear-gradient(135deg, #1e3a6e 0%, #16284d 100%);
    border-color: rgba(96, 165, 250, .35);
}

/* Pairs with .kd-ui-card-featured - a lighter blue than --kdt-blue so
   the primary CTA still stands out against the darker gradient card
   behind it. */
.kd-ui-btn-featured {
    background: #60a5fa;
    color: #0b1220;
}

/* ===================== Section header ===================== */

/* Source: .kd-section-head/.kd-section-title (home.html:224-233). */
.kd-ui-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 22px 0 10px;
}
.kd-ui-section-title {
    font-size: var(--kdt-font-size-section);
    font-weight: var(--kdt-font-weight-section);
    color: var(--kdt-text);
}

/* ===================== Accordion row (expandable list item) =====================
   Source: .kd-card/.kd-card-head/.kd-card-body/.kd-chevron, the real
   working accordion in instances.html:196-285 - home.html has no
   accordion of its own to reconcile against. */

.kd-ui-row {
    background: var(--kdt-card-bg);
    border: 1px solid var(--kdt-card-border);
    border-radius: var(--kdt-radius-card);
}
.kd-ui-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: var(--kdt-spacing-row-head-pad);
    cursor: pointer;
}
.kd-ui-row-body {
    display: none;
    padding: var(--kdt-spacing-row-body-pad);
    border-top: 1px solid var(--kdt-card-border);
}
.kd-ui-row.open .kd-ui-row-body {
    display: block;
    padding-top: 10px;
}
.kd-ui-chevron {
    transition: transform .15s ease;
    color: var(--kdt-text-muted);
}
.kd-ui-row.open .kd-ui-chevron {
    transform: rotate(180deg);
}

/* ===================== Badges ===================== */

/* Source: .kd-bot-badge (home.html:582-594) for the pill shape/status
   colors; .kd-card-exchange-badge (instances.html:250-261) for the
   exchange variant - no competing definition for either in the other
   file, so each is used as-is. */
.kd-ui-badge {
    display: inline-block;
    font-size: var(--kdt-font-size-tiny);
    font-weight: var(--kdt-font-weight-tiny);
    padding: 2px 8px;
    border-radius: var(--kdt-radius-pill);
    text-transform: uppercase;
    letter-spacing: .3px;
}
.kd-ui-badge-running { color: var(--kdt-green); background: rgba(34, 197, 94, 0.14); }
.kd-ui-badge-paused { color: var(--kdt-amber); background: rgba(245, 166, 35, 0.14); }
.kd-ui-badge-error { color: var(--kdt-red); background: rgba(239, 68, 68, 0.14); }
.kd-ui-badge-exchange {
    font-size: 11px;
    letter-spacing: .02em;
    color: #93c5fd;
    background: rgba(37, 99, 235, .18);
    border: 1px solid rgba(37, 99, 235, .4);
    text-transform: none;
}

/* ===================== Buttons ===================== */

/* Source: .kd-card-btn (instances.html:329-348) for shape/disabled
   state; colors re-derived from the unified --kdt-* palette above
   rather than instances.html's own mixed literals, per the owner's
   "unify on one palette" intent for this new shared file. */
.kd-ui-btn {
    display: inline-block;
    text-align: center;
    padding: 9px 10px;
    border-radius: var(--kdt-radius-button);
    border: none;
    font-weight: var(--kdt-font-weight-small);
    font-size: 12.5px;
    cursor: pointer;
    text-decoration: none;
    font-family: var(--kdt-font-family);
}
.kd-ui-btn:disabled { opacity: .5; cursor: not-allowed; }
.kd-ui-btn-primary { background: var(--kdt-blue); color: #fff; }
.kd-ui-btn-secondary { background: var(--kdt-overlay-08); color: var(--kdt-text); }
.kd-ui-btn-danger { background: rgba(239, 68, 68, .12); color: #fca5a5; }

/* ===================== Tabs ===================== */

/* Source: #botsTabBtn/#instancesTabBtn (templates/base.html:1220-1223),
   the only existing tab control across the 3 reference surfaces - those
   are inline style= attributes, not a class, so there is nothing to
   conflict with; colors re-derived from --kdt-blue per the same
   unification intent as buttons above. */
.kd-ui-tabs {
    display: flex;
    gap: 8px;
}
.kd-ui-tab {
    flex: 1;
    text-align: center;
    padding: 8px 12px;
    border-radius: var(--kdt-radius-button);
    border: none;
    font-weight: var(--kdt-font-weight-body);
    font-size: 13px;
    cursor: pointer;
    background: var(--kdt-overlay-08);
    color: var(--kdt-text-muted);
}
.kd-ui-tab.active { background: var(--kdt-blue); color: #fff; }

/* ===================== Inputs / selects ===================== */

/* Source: .kd-account-input/.kd-account-select (home.html:899-903) -
   the only input/select styling across the 3 reference surfaces. */
.kd-ui-input, .kd-ui-select {
    width: 100%;
    background: var(--kdt-overlay-05);
    border: 1px solid var(--kdt-card-border);
    border-radius: var(--kdt-radius-input);
    padding: 9px 11px;
    color: var(--kdt-text);
    font-size: 13.5px;
    font-family: var(--kdt-font-family);
}
.kd-ui-select { width: auto; padding: 6px 8px; font-size: 12.5px; }

/* ===================== Empty state ===================== */

/* Source: .kd-empty-state (instances.html:363-366), text color
   consolidated onto --kdt-text-muted rather than instances.html's own
   one-off #cbd5e1, to avoid introducing a third grey into this shared
   file's text vocabulary (only --kdt-text/--kdt-text-muted exist). */
.kd-ui-empty {
    padding: 20px;
    text-align: center;
    color: var(--kdt-text-muted);
    font-size: 13px;
}

/* ===================== Alerts ===================== */

/* Source: .kd-error-box (instances.html:313-321); success variant
   mirrors it with the green palette - instances.html/home.html have no
   existing success-alert box to reconcile against. */
.kd-ui-alert {
    padding: 8px 10px;
    border-radius: var(--kdt-radius-input);
    font-size: 12px;
}
.kd-ui-alert-error {
    background: rgba(239, 68, 68, .1);
    border: 1px solid rgba(239, 68, 68, .3);
    color: #fca5a5;
}
.kd-ui-alert-success {
    background: rgba(34, 197, 94, .1);
    border: 1px solid rgba(34, 197, 94, .3);
    color: var(--kdt-green);
}
/* New this round (2026-11-18, needed for /subscriptions/'s "no active
   subscription" notice) - mirrors the other two alert variants with
   the amber palette. */
.kd-ui-alert-warning {
    background: rgba(245, 166, 35, .1);
    border: 1px solid rgba(245, 166, 35, .3);
    color: var(--kdt-amber);
}

/* New this round (2026-11-18, needed for /subscriptions/'s "Inactive"
   status - the badge inventory above only had running/paused/error/
   exchange, none of which read as a plain neutral "off" state). */
.kd-ui-badge-neutral {
    color: var(--kdt-text-muted);
    background: var(--kdt-overlay-08);
}

/* ===================== Cross-document view transitions ===================== */
/* Owner-requested (this round, Part 1): keeps the header/bottom nav
   visually stable and fades content between full-page navigations
   instead of a hard cut - a real browser feature (Chrome/Edge 126+),
   completely harmless/no-op everywhere else (older Safari/Firefox just
   never read this at-rule, same as any unsupported CSS feature - zero
   JS, zero fallback code needed). Kept short/subtle on purpose - this
   is about removing the "jump", not adding a flashy effect. */
@view-transition {
    navigation: auto;
}
@media (prefers-reduced-motion: no-preference) {
    ::view-transition-old(root),
    ::view-transition-new(root) {
        animation-duration: 0.15s;
    }
}
