/* ============================================================
   IMPACTGIS — THEME STYLESHEET (theme.css)
   Light / Dark Mode Design Tokens & Standardized Toggle Button
   Preserves Exact index.html Visual Appearance
   Zero Inline Styles Architecture
   ============================================================ */

:root, [data-theme="dark"] {
    /* Brand & Surfaces */
    --bg-body: #060c18;
    --header-bg: linear-gradient(135deg, #050d1a 0%, #0a1628 50%, #0d203d 100%);
    --header-border: rgba(56, 189, 248, 0.16);
    --surface-card: #0c182c;
    --surface-card-hover: #12223d;
    --surface-panel: rgba(10, 22, 40, 0.94);
    --surface-panel-border: rgba(56, 189, 248, 0.28);
    --surface-table-head: #091322;
    --surface-table-row: #0c182c;
    --surface-table-alt: #081120;
    --surface-table-hover: #142848;

    /* Borders */
    --border-color: rgba(255, 255, 255, 0.14);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-focus: #38bdf8;

    /* Typography */
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-inverse: #060c18;

    /* Single Source of Truth Status Colors */
    --status-normal: #10b981;    /* Vibrant Emerald */
    --status-warning: #f59e0b;   /* Amber */
    --status-danger: #f97316;    /* Orange */
    --status-hfl: #ef4444;       /* Crimson Red */
    --status-barrage: #0284c7;   /* Deep Blue */
    --status-weir: #8b5cf6;      /* Purple */
    --status-dam: #06b6d4;       /* Cyan */

    /* Badges & Shadows */
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 14px 36px rgba(0, 0, 0, 0.65);

    /* Leaflet Popups */
    --popup-bg: rgba(10, 20, 36, 0.97);
    --popup-border: rgba(56, 189, 248, 0.7);
    --popup-shadow: 0 10px 32px rgba(0, 0, 0, 0.75);
    --popup-title: #38bdf8;
    --popup-subtitle: #94a3b8;
    --popup-text: #f8fafc;
    --popup-row-bg: rgba(255, 255, 255, 0.04);
}

[data-theme="light"] {
    --bg-body: #f8fafc;
    --header-bg: linear-gradient(135deg, #0a1628 0%, #0f2240 50%, #162e54 100%);
    --header-border: rgba(255, 255, 255, 0.2);
    --surface-card: #ffffff;
    --surface-card-hover: #f1f5f9;
    --surface-panel: rgba(255, 255, 255, 0.96);
    --surface-panel-border: rgba(14, 116, 144, 0.35);
    --surface-table-head: #e2e8f0;
    --surface-table-row: #ffffff;
    --surface-table-alt: #f8fafc;
    --surface-table-hover: #e0f2fe;

    --border-color: #cbd5e1;
    --border-subtle: #e2e8f0;
    --border-focus: #0284c7;

    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --text-inverse: #ffffff;

    --status-normal: #15803d;
    --status-warning: #b45309;
    --status-danger: #c2410c;
    --status-hfl: #b91c1c;
    --status-barrage: #0284c7;
    --status-weir: #7c3aed;
    --status-dam: #0891b2;

    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.16);

    --popup-bg: rgba(255, 255, 255, 0.98);
    --popup-border: rgba(2, 132, 199, 0.65);
    --popup-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
    --popup-title: #0284c7;
    --popup-subtitle: #64748b;
    --popup-text: #0f172a;
    --popup-row-bg: rgba(0, 0, 0, 0.03);
}

/* ------------------------------------------------------------
   Standardized Theme Toggle Button (Matches index.html exactly)
   ------------------------------------------------------------ */
.theme-toggle-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #cbd5e1;
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
}

.theme-toggle-btn.icon-only {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    border-radius: 8px;
    color: #e2e8f0;
}

.theme-toggle-btn.icon-only:hover {
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.4);
    background: rgba(56, 189, 248, 0.12);
    transform: translateY(-1px);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

.theme-toggle-btn.icon-only:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.35);
}

.theme-icon {
    display: block;
    stroke: currentColor;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.theme-toggle-btn.icon-only:hover .theme-icon {
    transform: rotate(15deg);
}

.theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.3);
}
