/* ==========================================================================
   Theme layer: switched by data-* attributes on <html> (see theme.js).
   ========================================================================== */

/* ---------- Colour scheme ---------- */
html[data-scheme="dark"] {
    --canvas: #0b1220;
    --surface: #121b2d;
    --surface-2: #17223a;
    --ink: #e8eef9;
    --ink-2: #b9c4d8;
    --muted: #8493ac;
    --line: #22304a;
    --input-border: #2b3b58;
    --row-hover: #16213a;
    --topbar-bg: rgba(14, 22, 38, .85);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, .4);
    --ok: #34d399; --bad: #f87171; --warn: #fbbf24; --info: #22d3ee; --neutral: #94a3b8;
    --brand-text: color-mix(in srgb, var(--brand) 55%, white);
    color-scheme: dark;
}
html[data-scheme="dark"] .mini { border-color: #22304a; }

/* ---------- Accent colour ---------- */
html[data-accent="blue"]    { --brand: #2563eb; --brand-600: #1d4ed8; }
html[data-accent="indigo"]  { --brand: #4f46e5; --brand-600: #4338ca; }
html[data-accent="violet"]  { --brand: #7c3aed; --brand-600: #6d28d9; }
html[data-accent="emerald"] { --brand: #059669; --brand-600: #047857; }
html[data-accent="teal"]    { --brand: #0d9488; --brand-600: #0f766e; }
html[data-accent="rose"]    { --brand: #e11d48; --brand-600: #be123c; }
html[data-accent="amber"]   { --brand: #d97706; --brand-600: #b45309; }
html[data-accent="slate"]   { --brand: #334155; --brand-600: #1e293b; }
html[data-scheme="dark"][data-accent="slate"] { --brand: #64748b; --brand-600: #94a3b8; }

/* ---------- Sidebar / top navigation palette ---------- */
html[data-side="light"] {
    --side-bg: var(--surface);
    --side-text: var(--ink-2);
    --side-text-strong: var(--ink);
    --side-title: var(--muted);
    --side-hover: var(--surface-2);
    --side-active: var(--brand-50);
    --side-active-icon: var(--brand);
    --side-line: var(--line);
}
html[data-side="light"] .sidebar { border-inline-end: 1px solid var(--line) !important; }
html[data-side="light"] .sidebar .nav-link.active { color: var(--brand-text); }
html[data-side="light"] .topnav .nav-link.active { color: var(--brand-text); }
html[data-side="accent"] {
    --side-bg: linear-gradient(180deg, var(--brand-600), color-mix(in srgb, var(--brand-600) 70%, black));
    --side-text: rgba(255, 255, 255, .78);
    --side-title: rgba(255, 255, 255, .5);
    --side-hover: rgba(255, 255, 255, .12);
    --side-active: rgba(255, 255, 255, .2);
    --side-active-icon: #fff;
}

/* ---------- Density ---------- */
html[data-density="compact"] { font-size: 13.5px; --pad-y: .45rem; --pad-x: .75rem; --content-pad: 1rem; }
html[data-density="compact"] .card-body { padding: .9rem 1rem; }
html[data-density="compact"] .card-header, html[data-density="compact"] .card-footer { padding: .6rem 1rem; }
html[data-density="compact"] .page-header { margin-bottom: .85rem; }
html[data-density="compact"] .page-header h1 { font-size: 1.25rem; }
html[data-density="compact"] .form-control, html[data-density="compact"] .form-select { padding: .35rem .65rem; }
html[data-density="compact"] .stat-card { padding: .7rem 1rem; }
html[data-density="compact"] .stat-card .value { font-size: 1.4rem; }
html[data-density="compact"] .stat-icon { width: 38px; height: 38px; font-size: 1.1rem; }
html[data-density="compact"] .sidebar .nav-link { padding: .38rem .7rem; }
html[data-density="compact"] .nav-group-title { padding-top: .7rem; }

/* ---------- Corner style ---------- */
html[data-radius="sharp"] { --radius: 4px; --radius-sm: 3px; }
html[data-radius="soft"]  { --radius: 14px; --radius-sm: 10px; }
html[data-radius="round"] { --radius: 22px; --radius-sm: 14px; }
html[data-radius="round"] .btn, html[data-radius="round"] .form-control, html[data-radius="round"] .form-select { border-radius: 999px; }
html[data-radius="round"] textarea.form-control { border-radius: 18px; }

/* ---------- Card style ---------- */
html[data-surface="flat"] { --card-shadow: none; }
html[data-surface="flat"] .btn-primary { box-shadow: none; }
html[data-surface="flat"] .btn-primary:hover { transform: none; }
html[data-surface="glow"] { --card-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 10%, transparent), 0 8px 28px rgba(0, 0, 0, .32); }
html[data-surface="glow"] .card, html[data-surface="glow"] .table-card, html[data-surface="glow"] .stat-card {
    background-image: linear-gradient(180deg, color-mix(in srgb, var(--brand) 6%, transparent), transparent 40%);
}

/* ---------- Layout: top navigation ---------- */
@media (min-width: 992px) {
    html[data-layout="top"] .sidebar { display: none !important; }
    html[data-layout="top"] .app-shell { display: block; }
    html[data-layout="top"] .topbar { background: var(--side-bg); border-bottom: 0; padding-block: .5rem 0; flex-wrap: wrap; row-gap: .25rem; }
    html[data-layout="top"] .topbar-brand, html[data-layout="top"] .topnav { display: flex; }
    /* the menu gets its own row under the brand, so 12 groups never collide with the right-hand tools */
    html[data-layout="top"] .topnav { order: 3; flex: 1 0 100%; margin: 0 -.25rem; padding: .35rem 0 .45rem; border-top: 1px solid var(--side-line); flex-wrap: wrap; row-gap: .1rem; }
    html[data-layout="top"] .topnav::-webkit-scrollbar { display: none; }
    html[data-layout="top"] .topbar .btn-light, html[data-layout="top"] .topbar .btn-icon {
        background: var(--side-hover); border-color: transparent; color: var(--side-text-strong);
    }
    html[data-layout="top"] .topbar .btn-light:hover, html[data-layout="top"] .topbar .btn-icon:hover { background: var(--side-active); }
    html[data-layout="top"] .company-chip { color: var(--side-text); border-color: var(--side-line); }
    html[data-layout="top"] .avatar { background: var(--side-active); color: var(--side-text-strong); }
    html[data-layout="top"] .content { max-width: 1480px; }
    html[data-layout="top"][data-side="light"] .topbar { border-bottom: 1px solid var(--line); background: var(--surface); }
    html[data-layout="top"] .topbar-brand .brand-mark { width: 34px; height: 34px; font-size: 1.1rem; }
    html[data-layout="top"] .topbar-brand .small { display: none; }
}
@media (min-width: 992px) and (max-width: 1399.98px) {
    html[data-layout="top"] .topnav .nav-link span.nav-text { display: none; }   /* icons only on narrower desktops */
    html[data-layout="top"] .topnav .nav-link { padding-inline: .6rem; }
}

/* ---------- Layout: icon rail (expands on hover) ---------- */
@media (min-width: 992px) {
    html[data-layout="rail"] .app-shell { display: block; }
    html[data-layout="rail"] .sidebar {
        position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 40; width: var(--rail-w); overflow: hidden;
        transition: width .2s ease, box-shadow .2s ease;
    }
    html[data-layout="rail"] .sidebar:hover { width: var(--sidebar-w); overflow-y: auto; box-shadow: 8px 0 32px rgba(0, 0, 0, .25); }
    html[data-layout="rail"] [dir="rtl"] .sidebar:hover { box-shadow: -8px 0 32px rgba(0, 0, 0, .25); }
    html[data-layout="rail"] .main { margin-inline-start: var(--rail-w); }
    html[data-layout="rail"] .sidebar:not(:hover) .sidebar-brand > div,
    html[data-layout="rail"] .sidebar:not(:hover) .nav-link span,
    html[data-layout="rail"] .sidebar:not(:hover) .nav-group-title { display: none; }
    html[data-layout="rail"] .sidebar:not(:hover) .sidebar-brand { justify-content: center; padding-inline: 0; }
    html[data-layout="rail"] .sidebar:not(:hover) .nav-link { justify-content: center; padding-inline: 0; }
    html[data-layout="rail"] .sidebar:not(:hover) .sidebar-nav { padding-inline: .5rem; }
    html[data-layout="rail"] .sidebar:not(:hover) .nav-link.active::before { inset-inline-start: -.5rem; }
    html[data-layout="rail"] .sidebar:not(:hover) .nav-link { border-top: 0; }
    html[data-layout="rail"] .nav-group-title { margin-top: .4rem; }
}

/* ---- Font size (user choice, independent of preset). Everything is rem-based, so the whole UI scales. */
html[data-font="sm"] { font-size: 14px; }
html[data-font="lg"] { font-size: 17.5px; }
html[data-font="xl"] { font-size: 19.5px; }
