/* =========================================================
   Nexgen CACG – shared theme tokens (light + dark)
   Load this BEFORE page CSS (login.css, app.css, sreg.css …)
   ========================================================= */

/* ---------- LIGHT (default) ---------- */
:root {
    --primary: #0B3D91;
    --primary-dark: #072653;
    --secondary: #FF8A00;
    --secondary-dark: #C96A00;
    --accent: #1E6FFF;

    --bg: #F5F8FF;
    --card: #FFFFFF;
    --text: #0F172A;
    --muted: #64748B;

    --success: #22C55E;
    --success-dark: #15803D;
    --danger: #EF4444;
    --warning: #F59E0B;

    --radius: 18px;

    /* surfaces */
    --surface-1: #FFFFFF;
    --surface-2: #F7FAFF;
    --field-bg: #F5F8FF;
    --card-border: rgba(255, 255, 255, .9);
    --hilite: #FFFFFF;
    --border-soft: rgba(11, 61, 145, .08);
    --track: #E2E9F7;

    /* legacy "edge" tokens (hard-edge 3D, still used by some rules) */
    --edge: #DCE6F8;
    --edge-strong: #CBD7EE;
    --btn-light-a: #FFFFFF;
    --btn-light-b: #E9EFFB;

    /* text helpers */
    --heading: #0B3D91;
    --placeholder: #A3AEC0;
    --text-shadow: 0 2px 0 rgba(255, 255, 255, .9);

    /* ===== ELEVATION SHADOWS (layered: contact + ambient + tinted far shadow) ===== */
    --elev-0: 0 1px 2px rgba(15, 23, 42, .10);
    --elev-1:
        0 1px 2px rgba(15, 23, 42, .06),
        0 3px 6px rgba(15, 23, 42, .06),
        0 8px 16px -4px rgba(11, 61, 145, .12);
    --elev-2:
        0 2px 4px rgba(15, 23, 42, .05),
        0 8px 16px rgba(15, 23, 42, .07),
        0 24px 40px -12px rgba(11, 61, 145, .22);
    --elev-3:
        0 4px 6px rgba(15, 23, 42, .05),
        0 16px 28px rgba(15, 23, 42, .10),
        0 40px 64px -16px rgba(11, 61, 145, .30);

    /* lit top edge + shaded bottom edge (gives the "raised plastic" feel) */
    --bevel:
        inset 0 1px 0 rgba(255, 255, 255, .85),
        inset 0 -2px 0 rgba(11, 61, 145, .06);
    --bevel-dark:
        inset 0 1px 0 rgba(255, 255, 255, .35),
        inset 0 -2px 0 rgba(0, 0, 0, .18);

    /* coloured glows for primary actions */
    --glow-accent:
        0 2px 4px rgba(11, 61, 145, .25),
        0 10px 22px -4px rgba(30, 111, 255, .55);
    --glow-orange:
        0 2px 4px rgba(201, 106, 0, .25),
        0 10px 22px -4px rgba(255, 138, 0, .55);
    --glow-success:
        0 2px 4px rgba(21, 128, 61, .25),
        0 10px 22px -4px rgba(34, 197, 94, .5);
    --glow-danger:
        0 2px 4px rgba(185, 28, 28, .25),
        0 8px 18px -4px rgba(239, 68, 68, .5);

    --shadow-3d: var(--elev-1);
    --inset-3d:
        inset 0 2px 4px rgba(15, 23, 42, .07),
        inset 0 -1px 0 rgba(255, 255, 255, .9);
}

html[data-theme="light"] {
    color-scheme: light;
}

/* ---------- DARK ---------- */
html[data-theme="dark"] {
    color-scheme: dark;

    --accent: #4C8DFF;

    --bg: #0A1020;
    --card: #101A30;
    --text: #E6ECFA;
    --muted: #93A1BA;

    --surface-1: #15213D;
    --surface-2: #0F1830;
    --field-bg: #0B1426;
    --card-border: rgba(255, 255, 255, .06);
    --hilite: rgba(255, 255, 255, .07);
    --border-soft: rgba(255, 255, 255, .08);
    --track: #1C2A47;

    --edge: #070D1B;
    --edge-strong: #070D1B;
    --btn-light-a: #1E2F52;
    --btn-light-b: #162441;

    --heading: #8DB4FF;
    --placeholder: #5E6E8A;
    --text-shadow: 0 2px 0 rgba(0, 0, 0, .4);

    --elev-0: 0 1px 2px rgba(0, 0, 0, .6);
    --elev-1:
        0 1px 2px rgba(0, 0, 0, .5),
        0 4px 8px rgba(0, 0, 0, .35),
        0 10px 20px -4px rgba(0, 0, 0, .45);
    --elev-2:
        0 2px 4px rgba(0, 0, 0, .5),
        0 10px 20px rgba(0, 0, 0, .4),
        0 28px 48px -12px rgba(0, 0, 0, .6);
    --elev-3:
        0 4px 6px rgba(0, 0, 0, .5),
        0 18px 32px rgba(0, 0, 0, .5),
        0 44px 72px -16px rgba(0, 0, 0, .7);

    --bevel:
        inset 0 1px 0 rgba(255, 255, 255, .07),
        inset 0 -2px 0 rgba(0, 0, 0, .35);
    --bevel-dark:
        inset 0 1px 0 rgba(255, 255, 255, .25),
        inset 0 -2px 0 rgba(0, 0, 0, .35);

    --glow-accent:
        0 2px 4px rgba(0, 0, 0, .4),
        0 10px 22px -4px rgba(76, 141, 255, .45);
    --glow-orange:
        0 2px 4px rgba(0, 0, 0, .4),
        0 10px 22px -4px rgba(255, 138, 0, .4);
    --glow-success:
        0 2px 4px rgba(0, 0, 0, .4),
        0 10px 22px -4px rgba(34, 197, 94, .38);
    --glow-danger:
        0 2px 4px rgba(0, 0, 0, .4),
        0 8px 18px -4px rgba(239, 68, 68, .4);

    --inset-3d:
        inset 0 2px 5px rgba(0, 0, 0, .55),
        inset 0 -1px 0 rgba(255, 255, 255, .04);

    /* Aliases for the older variable names used by dashboards / other pages */
    --primary-color: #8DB4FF;
    --secondary-color: #FF8A00;
    --accent-color: #EF4444;
    --success-color: #22C55E;
    --warning-color: #F59E0B;
    --dark-color: #E6ECFA;
    --light-bg: #0A1020;
    --text-primary: #E6ECFA;
    --text-gray: #93A1BA;
    --text-secondary: #93A1BA;
}

/* ---------- App-wide dark adjustments ---------- */
html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .bg-light {
    background-color: var(--surface-1) !important;
}

html[data-theme="dark"] .text-dark {
    color: var(--text) !important;
}

.footer-brand {
    color: var(--secondary);
}

/* ---------- Theme toggle button (3D) ---------- */
.theme-toggle {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.05rem;
    color: var(--heading);
    background: linear-gradient(180deg, var(--btn-light-a), var(--btn-light-b));
    box-shadow: var(--elev-1), var(--bevel);
    transition: transform .18s ease, box-shadow .18s ease;
}

.theme-toggle:hover {
    transform: translateY(-2px);
    box-shadow: var(--elev-2), var(--bevel);
}

.theme-toggle:active {
    transform: translateY(1px) scale(.97);
    box-shadow: var(--elev-0), var(--inset-3d);
}

.theme-toggle:focus-visible {
    outline: 3px solid rgba(255, 138, 0, .6);
    outline-offset: 3px;
}

.theme-toggle .icon-sun { display: none; color: var(--secondary); }
.theme-toggle .icon-moon { display: inline; }

html[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* floating version (login page) */
.theme-toggle-float {
    position: fixed;
    top: 1.2rem;
    right: 1.2rem;
    z-index: 1001;
}

/* smooth switch */
body,
.registration-card,
.login-card,
.form-control,
.form-select,
.navbar-custom,
.footer,
.card {
    transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}