/* ============================================================================
   theme.css — design tokens + base styles for the Flask services
   (connect / dji / recovery). The same tokens as mng/assets/css/theme.css, so
   every RC Cams app is one palette; this copy also bridges them into Bootstrap
   5.3's CSS variables, because these services keep Bootstrap underneath.

   One file: connect/static/css/theme.css. dji/static/css/theme.css and
   recovery/static/css/theme.css are SYMLINKS to it (each origin serves its own
   copy, so the font needs no CORS). Served immutable for 30 days — bump ?v= on
   the <link> in shared/rccams_shared/templates/app/base_app.html on every edit.

   Theme choice: <html data-theme="auto|light|dark" data-bs-theme="light|dark">,
   from the rccams_theme cookie (domain .rccams.in) when the service allows the
   switch (app_theme_switch in its base.html), else dark. Colours exist ONLY
   here: a page uses var(--surface), rgb(var(--danger-rgb) / .15) …, never a hex.
   ============================================================================ */

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../fonts/inter-latin-wght.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
                   U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
                   U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---- Dark (default) -------------------------------------------------------- */
:root {
    color-scheme: dark;

    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Sans Malayalam', sans-serif;
    --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;

    /* "ink" is what translucent overlays are made of: white on dark, slate on light.
       rgb(var(--ink) / .06) is a hover wash in either theme. */
    --ink: 255 255 255;

    --bg: #0c1120;
    --bg-bar: #10172a;
    --surface: #141b2e;
    --surface-2: #1a2237;
    --surface-3: #232d46;
    --field: #182036;
    --border: #252f48;
    --border-strong: #35415e;

    --text: #e8ecf4;
    --text-2: #a9b2c7;
    --text-3: #7c869e;

    --accent: #22c3ee;
    --accent-rgb: 34 195 238;
    --accent-hover: #52d2f3;
    --accent-fg: #04222c;
    --accent-text: #56d2f3;

    --success: #3ccf8e;  --success-rgb: 60 207 142;
    --warning: #f2b544;  --warning-rgb: 242 181 68;
    --danger: #f45d63;   --danger-rgb: 244 93 99;
    --info: #6aa6f8;     --info-rgb: 106 166 248;
    --violet: #a68af6;   --violet-rgb: 166 138 246;
    --orange: #f59a4a;   --orange-rgb: 245 154 74;
    --whatsapp: #25d366;
    --on-fill: #0b1220;   /* text on a solid status fill (bright fills in dark, deep fills in light) */

    --shadow-1: 0 1px 2px rgb(0 0 0 / .35);
    --shadow-2: 0 4px 16px rgb(0 0 0 / .32);
    --shadow-pop: 0 14px 40px rgb(0 0 0 / .5);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-pill: 999px;

    --bar-h: 56px;
    --navbar-height: 56px;          /* the admin sidebar is sized beneath the bar (base_admin.html measures it) */
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 56px;
    --sidebar-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    /* Names the pages were written against — kept so nothing that still says
       var(--card-bg) breaks. New code uses the tokens above. */
    --primary-color: var(--accent);
    --primary-hover: var(--accent-hover);
    --secondary-color: var(--bg-bar);
    --dark-bg: var(--bg);
    --card-bg: var(--surface);
    --secondary-bg: var(--surface-2);
    --text-color: var(--text);
    --text-muted: var(--text-2);
    --border-color: var(--border);
    --input-bg: var(--field);
    --input-border: var(--border-strong);
    --success-color: var(--success);
    --warning-color: var(--warning);
    --danger-color: var(--danger);
}

/* ---- Light ------------------------------------------------------------------
   Written twice (explicit choice, and "auto" on a light device) because plain
   CSS cannot share a block between a selector and a media query. Keep the two
   copies identical. */
:root[data-theme="light"] {
    color-scheme: light;
    --ink: 15 23 42;
    --bg: #f3f5f9;  --bg-bar: #ffffff;  --surface: #ffffff;  --surface-2: #f4f6fa;  --surface-3: #e9edf4;
    --field: #ffffff;  --border: #e2e7ef;  --border-strong: #cdd5e2;
    --text: #131b2d;  --text-2: #4a556d;  --text-3: #79849b;
    --accent: #0a9ec7;  --accent-rgb: 10 158 199;  --accent-hover: #0888ab;  --accent-fg: #ffffff;  --accent-text: #0780a2;  --on-fill: #ffffff;
    --success: #12925a;  --success-rgb: 18 146 90;
    --warning: #b4730c;  --warning-rgb: 214 146 30;
    --danger: #d8353d;   --danger-rgb: 216 53 61;
    --info: #2d6ad3;     --info-rgb: 45 106 211;
    --violet: #6f4bd6;   --violet-rgb: 111 75 214;
    --orange: #cc6316;   --orange-rgb: 214 112 32;
    --shadow-1: 0 1px 2px rgb(15 23 42 / .06);
    --shadow-2: 0 4px 14px rgb(15 23 42 / .08);
    --shadow-pop: 0 12px 36px rgb(15 23 42 / .16);
}
@media (prefers-color-scheme: light) {
    :root[data-theme="auto"] {
        color-scheme: light;
        --ink: 15 23 42;
        --bg: #f3f5f9;  --bg-bar: #ffffff;  --surface: #ffffff;  --surface-2: #f4f6fa;  --surface-3: #e9edf4;
        --field: #ffffff;  --border: #e2e7ef;  --border-strong: #cdd5e2;
        --text: #131b2d;  --text-2: #4a556d;  --text-3: #79849b;
        --accent: #0a9ec7;  --accent-rgb: 10 158 199;  --accent-hover: #0888ab;  --accent-fg: #ffffff;  --accent-text: #0780a2;  --on-fill: #ffffff;
        --success: #12925a;  --success-rgb: 18 146 90;
        --warning: #b4730c;  --warning-rgb: 214 146 30;
        --danger: #d8353d;   --danger-rgb: 216 53 61;
        --info: #2d6ad3;     --info-rgb: 45 106 211;
        --violet: #6f4bd6;   --violet-rgb: 111 75 214;
        --orange: #cc6316;   --orange-rgb: 214 112 32;
        --shadow-1: 0 1px 2px rgb(15 23 42 / .06);
        --shadow-2: 0 4px 14px rgb(15 23 42 / .08);
        --shadow-pop: 0 12px 36px rgb(15 23 42 / .16);
    }
}

/* ---- Bootstrap 5.3 bridge ----------------------------------------------------
   Bootstrap reads its own custom properties for body, links, borders, the
   status colours and (5.3+) the *-text-emphasis / *-bg-subtle pairs that
   alerts, list-group items and .text-bg-* use. Pointing them at the tokens
   makes Bootstrap's own light/dark mode (data-bs-theme on <html>) paint with
   our palette, which is what lets most of the old !important repaints go.
   `:root[data-bs-theme]` outranks Bootstrap's [data-bs-theme=dark] block. */
:root, :root[data-bs-theme] {
    --bs-body-font-family: var(--font);
    --bs-body-font-size: 0.9rem;
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
    --bs-emphasis-color: var(--text);
    --bs-secondary-color: var(--text-2);
    --bs-tertiary-color: var(--text-3);
    --bs-secondary-bg: var(--surface-2);
    --bs-tertiary-bg: var(--surface-3);
    --bs-heading-color: var(--text);
    --bs-link-color: var(--accent-text);
    --bs-link-hover-color: var(--accent-hover);
    --bs-link-color-rgb: var(--accent-rgb);
    --bs-link-hover-color-rgb: var(--accent-rgb);
    --bs-code-color: var(--accent-text);
    --bs-border-color: var(--border);
    --bs-border-color-translucent: var(--border);
    --bs-border-radius: 8px;
    --bs-border-radius-sm: 6px;
    --bs-border-radius-lg: 12px;
    --bs-box-shadow: var(--shadow-2);
    --bs-box-shadow-sm: var(--shadow-1);
    --bs-box-shadow-lg: var(--shadow-pop);

    --bs-primary: var(--accent);   --bs-primary-rgb: var(--accent-rgb);
    --bs-success: var(--success);  --bs-success-rgb: var(--success-rgb);
    --bs-danger: var(--danger);    --bs-danger-rgb: var(--danger-rgb);
    --bs-warning: var(--warning);  --bs-warning-rgb: var(--warning-rgb);
    --bs-info: var(--info);        --bs-info-rgb: var(--info-rgb);

    --bs-primary-text-emphasis: var(--accent-text);
    --bs-success-text-emphasis: var(--success);
    --bs-danger-text-emphasis: var(--danger);
    --bs-warning-text-emphasis: var(--warning);
    --bs-info-text-emphasis: var(--info);
    --bs-primary-bg-subtle: rgb(var(--accent-rgb) / .14);
    --bs-success-bg-subtle: rgb(var(--success-rgb) / .14);
    --bs-danger-bg-subtle: rgb(var(--danger-rgb) / .14);
    --bs-warning-bg-subtle: rgb(var(--warning-rgb) / .14);
    --bs-info-bg-subtle: rgb(var(--info-rgb) / .14);
    --bs-primary-border-subtle: rgb(var(--accent-rgb) / .4);
    --bs-success-border-subtle: rgb(var(--success-rgb) / .4);
    --bs-danger-border-subtle: rgb(var(--danger-rgb) / .4);
    --bs-warning-border-subtle: rgb(var(--warning-rgb) / .4);
    --bs-info-border-subtle: rgb(var(--info-rgb) / .4);
    --bs-secondary-bg-subtle: var(--surface-2);
    --bs-secondary-text-emphasis: var(--text-2);
    --bs-light-bg-subtle: var(--surface-2);
    --bs-dark-bg-subtle: var(--surface-3);
}

/* ---- Base ------------------------------------------------------------------ */
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font);
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv11';   /* Inter's single-storey a reads better at small sizes */
}

h1, h2, h3, h4, h5, h6 { color: var(--text); line-height: 1.25; letter-spacing: -0.011em; font-weight: 650; }

a { color: var(--accent-text); }
a:hover { color: var(--accent-hover); }

small, .small { color: var(--text-2); }
.text-muted { color: var(--text-2) !important; }   /* Bootstrap's utility is !important too */
.text-faint { color: var(--text-3); }
.num, .tabular { font-variant-numeric: tabular-nums; }
code, kbd, pre, .mono { font-family: var(--font-mono); }
code { background: rgb(var(--accent-rgb) / .1); color: var(--accent-text); padding: 1px 6px; border-radius: 4px; font-size: .92em; }
kbd { border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 11px; color: var(--text-2); background: none; }

hr { border: 0; border-top: 1px solid var(--border); opacity: 1; }

::selection { background: rgb(var(--accent-rgb) / .3); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Scrollbars ------------------------------------------------------------ */
* { scrollbar-color: rgb(var(--ink) / .2) transparent; scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgb(var(--ink) / .18); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgb(var(--ink) / .3); background-clip: content-box; }

/* ---- Icons (Lucide sprite inlined by app/base_app.html; app/_macros.html icon()) --- */
.i {
    width: 1.15em; height: 1.15em;
    flex: none;
    vertical-align: -0.2em;
    fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.i-sm { width: 14px; height: 14px; }
.i-lg { width: 20px; height: 20px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
