/* Global Bellator theme tokens + module light overrides */

:root,
html[data-theme="dark"] {
    color-scheme: dark;
    --bt-bg: #0b1220;
    --bt-bg-2: #111827;
    --bt-panel: #1e293b;
    --bt-panel-soft: rgba(30, 41, 59, 0.78);
    --bt-border: #334155;
    --bt-border-soft: rgba(148, 163, 184, 0.22);
    --bt-text: #f1f5f9;
    --bt-muted: #94a3b8;
    --bt-accent: #38bdf8;
    --bt-accent-2: #2563eb;
    --bt-ok: #16a34a;
    --bt-danger: #b91c1c;
    --bt-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    --bt-theme-meta: #0b1220;
}

html[data-theme="light"] {
    color-scheme: light;
    --bt-bg: #e8eef3;
    --bt-bg-2: #f4f7fa;
    --bt-panel: #ffffff;
    --bt-panel-soft: rgba(255, 255, 255, 0.94);
    --bt-border: #c5d0db;
    --bt-border-soft: rgba(30, 50, 70, 0.14);
    --bt-text: #1a2836;
    --bt-muted: #5d7083;
    --bt-accent: #0284c7;
    --bt-accent-2: #1d4ed8;
    --bt-ok: #15803d;
    --bt-danger: #b91c1c;
    --bt-shadow: 0 12px 32px rgba(20, 40, 60, 0.12);
    --bt-theme-meta: #e8eef3;
}

.theme-switch {
    --theme-switch-w: 52px;
    --theme-switch-h: 28px;
    --theme-switch-pad: 3px;
    --theme-switch-thumb: 22px;
    align-items: center;
    background: transparent;
    border: 0;
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    vertical-align: middle;
    width: auto;
}

.theme-switch-track {
    background: #1e293b;
    border: 1px solid var(--bt-border-soft);
    border-radius: 999px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35);
    display: block;
    height: var(--theme-switch-h);
    overflow: hidden;
    position: relative;
    transition: background 180ms ease, border-color 180ms ease;
    width: var(--theme-switch-w);
}

.theme-switch-icon {
    font-size: 12px;
    line-height: 1;
    opacity: 0.55;
    pointer-events: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    transition: opacity 180ms ease;
    z-index: 1;
}

.theme-switch-sun {
    left: 6px;
}

.theme-switch-moon {
    right: 6px;
}

.theme-switch-thumb {
    background: #f8fafc;
    border-radius: 999px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
    height: var(--theme-switch-thumb);
    left: var(--theme-switch-pad);
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    transition: left 180ms ease, background 180ms ease;
    width: var(--theme-switch-thumb);
    z-index: 2;
}

/* Dark = thumb on the right (moon) */
html[data-theme="dark"] .theme-switch-track {
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
}

html[data-theme="dark"] .theme-switch-thumb {
    background: #cbd5e1;
    left: calc(100% - var(--theme-switch-thumb) - var(--theme-switch-pad));
}

html[data-theme="dark"] .theme-switch-moon {
    opacity: 1;
}

html[data-theme="dark"] .theme-switch-sun {
    opacity: 0.35;
}

/* Light = thumb on the left (sun) */
html[data-theme="light"] .theme-switch-track {
    background: linear-gradient(180deg, #7dd3fc 0%, #bae6fd 100%);
    border-color: rgba(14, 116, 144, 0.28);
    box-shadow: inset 0 1px 2px rgba(14, 116, 144, 0.18);
}

html[data-theme="light"] .theme-switch-thumb {
    background: #fbbf24;
    box-shadow: 0 1px 4px rgba(180, 83, 9, 0.35);
    left: var(--theme-switch-pad);
}

html[data-theme="light"] .theme-switch-sun {
    opacity: 1;
}

html[data-theme="light"] .theme-switch-moon {
    opacity: 0.4;
}

.theme-switch:focus-visible .theme-switch-track {
    outline: 2px solid var(--bt-accent);
    outline-offset: 2px;
}

/* ----- Admin ----- */
html[data-theme="light"] {
    --admin-bg: #e8eef3;
    --admin-panel: #ffffff;
    --admin-card: #f8fafc;
    --admin-border: #c5d0db;
    --admin-text: #1a2836;
    --admin-muted: #5d7083;
    --admin-nav: #334155;
    --admin-topbar-bg: rgba(255, 255, 255, 0.94);
    --admin-accent: #1d4ed8;
    --admin-accent-soft: #2563eb;
}

html[data-theme="light"] .admin-sidebar {
    background: linear-gradient(180deg, #f8fafc 0%, #eef3f8 100%);
}

html[data-theme="light"] .admin-main,
html[data-theme="light"] .admin-topbar,
html[data-theme="light"] .admin-content {
    color: var(--admin-text);
}

html[data-theme="light"] .admin-nav-link:hover {
    background: rgba(37, 99, 235, 0.1);
    color: #0f172a;
}

html[data-theme="light"] .admin-nav-link.is-active {
    color: #fff;
}

/* ----- DELTA ----- */
html[data-theme="light"] {
    --delta-bg-0: #e8eef3;
    --delta-bg-1: #f4f7fa;
    --delta-panel: rgba(255, 255, 255, 0.94);
    --delta-border: rgba(30, 50, 70, 0.14);
    --delta-text: #1a2836;
    --delta-muted: #5d7083;
    --delta-accent: #1d4ed8;
    --delta-accent-soft: #0284c7;
}

html[data-theme="light"] .delta-page {
    background:
        radial-gradient(ellipse 80% 45% at 50% -8%, rgba(2, 132, 199, 0.08), transparent 55%),
        linear-gradient(165deg, #e8eef3 0%, #eef3f8 50%, #f4f7fa 100%);
    color: var(--delta-text);
}

/* ----- Briefing ----- */
html[data-theme="light"] .briefing-page,
html[data-theme="light"] .briefing-present-body {
    background: #e8eef3;
    color: #1a2836;
}

html[data-theme="light"] .briefing-page .muted {
    color: #5d7083;
}

html[data-theme="light"] .briefing-topbar-links a,
html[data-theme="light"] .briefing-hub-card {
    background: #ffffff;
    color: #1a2836;
    border: 1px solid #c5d0db;
}

html[data-theme="light"] .briefing-panel {
    background: #ffffff;
    border-color: #c5d0db;
    color: #1a2836;
}

html[data-theme="light"] .briefing-panel label,
html[data-theme="light"] .briefing-section-title,
html[data-theme="light"] .briefing-question {
    color: #1a2836;
}

html[data-theme="light"] .briefing-panel select,
html[data-theme="light"] .briefing-panel textarea,
html[data-theme="light"] .briefing-panel input[type="text"],
html[data-theme="light"] .briefing-panel input[type="number"] {
    background: #f4f7fa;
    border-color: #94a3b8;
    color: #0f172a;
}

html[data-theme="light"] .briefing-question {
    border-top-color: #c5d0db;
}

html[data-theme="light"] .briefing-question .required {
    color: #b91c1c;
}

html[data-theme="light"] .briefing-hub-sub {
    color: #5d7083;
}

/* ----- CRM / stock shared tokens when using kladovka-crm.css ----- */
html[data-theme="light"] {
    --bg: #e8eef3;
    --bg-elevated: #f4f7fa;
    --panel: #ffffff;
    --panel-2: #f1f5f9;
    --line: #c5d0db;
    --line-strong: #94a3b8;
    --text: #1a2836;
    --muted: #5d7083;
    --shadow: 0 12px 32px rgba(20, 40, 60, 0.12);
    --topbar-bg: rgba(255, 255, 255, 0.94);
    --section-bg: #ffffff;
    --section-shadow: 0 8px 24px rgba(20, 40, 60, 0.08);
    --section-header-bg: linear-gradient(180deg, #f8fafc, #ffffff);
    --th-bg: #eef3f8;
    --row-alt: #f8fafc;
    --link: #1d4ed8;
    --badge-bg: #e2e8f0;
    --badge-fg: #1e293b;
    --badge-soft-bg: #e0f2fe;
    --badge-soft-fg: #0c4a6e;
    --pill-bg: #f1f5f9;
    --blue-soft: rgba(37, 99, 235, 0.1);
    --accent: #0284c7;
}

html[data-theme="light"] body.crm-page {
    background:
        radial-gradient(1200px 500px at 10% -10%, rgba(2, 132, 199, 0.08), transparent 55%),
        radial-gradient(900px 400px at 90% 0%, rgba(37, 99, 235, 0.06), transparent 50%),
        var(--bg);
    color: var(--text);
}

/* ----- App shared cards ----- */
html[data-theme="light"] .stat-card {
    background: #ffffff;
    border-color: #c5d0db;
}

html[data-theme="light"] .stat-label {
    color: #5d7083;
}

html[data-theme="light"] .stat-value {
    color: #1a2836;
}

/* Login page inline dark body */
html[data-theme="light"] body.logo-mode {
    background: #e8eef3 !important;
    color: #1a2836 !important;
}

html[data-theme="light"] .briefing-present-chrome .theme-switch {
    margin-right: 8px;
}

html[data-theme="light"] .delta-topbar-links .theme-switch {
    align-self: center;
}

html[data-theme="light"] .admin-topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

html[data-theme="light"] .user-tools .theme-switch {
    margin-right: 4px;
}
