/* Theme tokens — dark is default; light overrides via [data-theme="light"]. */

:root,
[data-theme="dark"] {
    color-scheme: dark;
    --bg: #020617;
    --bg-gradient-from: #0f172a;
    --panel: rgba(15, 23, 42, 0.88);
    --surface: #0f172a;
    --surface-muted: rgba(15, 23, 42, 0.55);
    --surface-inset: rgba(2, 6, 23, 0.55);
    --border: rgba(148, 163, 184, 0.2);
    --border-strong: rgba(148, 163, 184, 0.35);
    --text: #e2e8f0;
    --muted: #94a3b8;
    --accent: #38bdf8;
    --accent-strong: #0ea5e9;
    --accent-soft: rgba(56, 189, 248, 0.12);
    --accent-on: #020617;
    --success: #22c55e;
    --warning: #f59e0b;
    --header-bg: rgba(2, 6, 23, 0.92);
    --sidebar-bg: rgba(2, 6, 23, 0.82);
    --nav-link-bg: #0f172a;
    --input-bg: #0f172a;
    --menu-bg: rgba(2, 6, 23, 0.96);
    --dialog-bg: #0b1220;
    --overlay-bg: rgba(2, 6, 23, 0.55);
    --shadow-color: rgba(15, 23, 42, 0.45);
    --button-secondary-bg: #1e293b;
    --pill-bg: rgba(148, 163, 184, 0.14);
    --pill-border: rgba(148, 163, 184, 0.28);
    --count-bg: rgba(56, 189, 248, 0.14);
    --count-border: rgba(56, 189, 248, 0.45);
    --count-text: #bae6fd;
    --floating-bg: rgba(15, 23, 42, 0.92);
    --floating-bg-secondary: rgba(30, 41, 59, 0.92);
    --popup-bg: rgba(2, 6, 23, 0.92);
    --toast-bg: rgba(15, 23, 42, 0.94);
    --surface-strong: rgba(15, 23, 42, 0.72);
    --danger: #f87171;
    --system-title: "Integris";
}

[data-theme="light"] {
    color-scheme: light;
    --bg: #eef2f7;
    --bg-gradient-from: #e2e8f0;
    --panel: #ffffff;
    --surface: #ffffff;
    --surface-muted: #f1f5f9;
    --surface-inset: #e8eef5;
    --border: rgba(15, 23, 42, 0.14);
    --border-strong: rgba(15, 23, 42, 0.24);
    --text: #0f172a;
    --muted: #334155;
    --accent: #0369a1;
    --accent-strong: #075985;
    --accent-soft: rgba(3, 105, 161, 0.12);
    --accent-on: #ffffff;
    --success: #15803d;
    --warning: #b45309;
    --header-bg: #ffffff;
    --sidebar-bg: #f8fafc;
    --nav-link-bg: #ffffff;
    --input-bg: #ffffff;
    --menu-bg: #ffffff;
    --dialog-bg: #ffffff;
    --overlay-bg: rgba(15, 23, 42, 0.4);
    --shadow-color: rgba(15, 23, 42, 0.14);
    --button-secondary-bg: #e2e8f0;
    --pill-bg: rgba(51, 65, 85, 0.1);
    --pill-border: rgba(51, 65, 85, 0.22);
    --count-bg: rgba(3, 105, 161, 0.12);
    --count-border: rgba(3, 105, 161, 0.35);
    --count-text: #075985;
    --floating-bg: rgba(255, 255, 255, 0.97);
    --floating-bg-secondary: rgba(226, 232, 240, 0.97);
    --popup-bg: rgba(255, 255, 255, 0.98);
    --toast-bg: #ffffff;
    --surface-strong: #e2e8f0;
    --danger: #b91c1c;
}

[data-theme="light"] body {
    background: linear-gradient(180deg, var(--bg-gradient-from), var(--bg) 42%);
    color: var(--text);
}

[data-theme="light"] .panel,
[data-theme="light"] .admin-workspace .panel,
[data-theme="light"] .admin-table,
[data-theme="light"] .admin-table th,
[data-theme="light"] .admin-table td,
[data-theme="light"] .admin-form label,
[data-theme="light"] .admin-toolbar,
[data-theme="light"] .admin-toolbar h2,
[data-theme="light"] .admin-entity-card,
[data-theme="light"] .admin-entity-card strong,
[data-theme="light"] .nav-link-list a,
[data-theme="light"] .eyebrow,
[data-theme="light"] .app-title {
    color: var(--text);
}

[data-theme="light"] .muted,
[data-theme="light"] .admin-entity-card span,
[data-theme="light"] .admin-form label > span {
    color: var(--muted);
}

[data-theme="light"] .nav-link-list a:hover,
[data-theme="light"] .nav-link-list a.active {
    background: var(--accent-soft);
}

[data-theme="light"] .admin-entity-card {
    background: var(--surface);
}

[data-theme="light"] .admin-form input,
[data-theme="light"] .admin-form select,
[data-theme="light"] .admin-form textarea,
[data-theme="light"] .agenda-field input,
[data-theme="light"] .agenda-field select,
[data-theme="light"] .groups-list-search {
    background: var(--input-bg);
    border-color: var(--border-strong);
}

[data-theme="light"] .groups-list-panel,
[data-theme="light"] .agenda-section,
[data-theme="light"] .agenda-dialog {
    background: var(--surface);
}

[data-theme="light"] .groups-device-list li {
    background: var(--surface-muted);
}

[data-theme="light"] .device-type-tab {
    background: var(--surface);
    color: var(--text);
}

[data-theme="light"] .offline-alert-banner {
    background: rgba(185, 28, 28, 0.12);
    border-bottom-color: rgba(185, 28, 28, 0.35);
    color: #991b1b;
}

[data-theme="light"] .geo-device-marker__label {
    color: #0f172a;
    text-shadow: 0 0 2px #ffffff, 0 1px 2px rgba(255, 255, 255, 0.85);
}

[data-theme="light"] .map-tab,
[data-theme="light"] .map-control-button {
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
}

[data-theme="light"] .map-tab.active {
    color: var(--accent-on);
}

[data-theme="light"] .device-action-popup {
    background: rgba(255, 255, 255, 0.98);
    color: var(--text);
}

[data-theme="light"] .device-action-popup-close {
    color: var(--muted);
}

[data-theme="light"] .device-action-popup-close:hover {
    color: var(--text);
}

[data-theme="light"] .auth-card {
    background: var(--surface);
    border-color: var(--border);
}

[data-theme="light"] .auth-form input {
    background: var(--input-bg);
    border-color: var(--border-strong);
    color: var(--text);
}

.theme-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
}

.language-switcher + .theme-switcher,
.theme-switcher + .language-switcher {
    margin-top: 10px;
}

.app-header-actions .theme-switcher {
    margin-top: 0;
}

.theme-switcher-button {
    width: 42px;
    min-width: 42px;
    height: 42px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    color: var(--text);
}

.theme-switcher-button svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.theme-switcher-button:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.theme-switcher-button[aria-pressed="true"] {
    color: var(--warning);
}

[data-theme="light"] .theme-switcher-button[aria-pressed="false"] {
    color: var(--accent-strong);
}
