/*
 * ISP Platform — Central Theme
 * ============================================================
 * FALLBACK + compatibility layer.
 * Primary editable source: /config/theme.php
 *
 * Main controls:
 *   --theme-font-family
 *   --theme-primary
 *   --theme-primary-hover
 *   --theme-primary-soft
 *   --theme-accent
 *   --theme-page
 *   --theme-surface
 *   --theme-text
 *   --theme-muted
 *   --theme-border
 *   --theme-radius-card
 *   --theme-radius-control
 *
 * This file is loaded AFTER the legacy admin/user CSS so it can
 * safely act as the single override layer while pages are migrated
 * gradually to the shared component system.
 */

@font-face {
    font-family: 'Cairo';
    src: url('/assets/fonts/Cairo-Regular.ttf') format('truetype');
    font-style: normal;
    font-weight: 400 600;
    font-display: swap;
}

@font-face {
    font-family: 'Cairo';
    src: url('/assets/fonts/Cairo-Bold.ttf') format('truetype');
    font-style: normal;
    font-weight: 700 900;
    font-display: swap;
}

:root {
    /* ========================================================
       1. EDITABLE THEME TOKENS
       ======================================================== */

    --theme-font-family:
        'Cairo',
        Tahoma,
        Arial,
        sans-serif;

    --theme-primary: #168b82;
    --theme-primary-hover: #116d66;
    --theme-primary-soft: #e4f5f1;

    --theme-accent: #c78d25;
    --theme-accent-soft: #fff4dc;

    --theme-page: #f4f6f5;
    --theme-surface: #ffffff;
    --theme-surface-soft: #f9fbfa;

    --theme-text: #102126;
    --theme-text-strong: #183239;
    --theme-muted: #65777b;
    --theme-muted-2: #8b999c;

    --theme-border: #dfe7e5;
    --theme-border-strong: #cad7d4;

    --theme-success: #18794e;
    --theme-warning: #9a6700;
    --theme-danger: #b74545;
    --theme-info: #38738c;

    --theme-sidebar: #0b1d21;
    --theme-sidebar-2: #10292e;
    --theme-sidebar-text: #d7e2df;

    --theme-radius-card: 18px;
    --theme-radius-control: 12px;

    --theme-shadow-card:
        0 1px 2px rgba(0,0,0,.04),
        0 8px 24px rgba(0,0,0,.04);


    /* ========================================================
       2. SHARED TOKEN COMPATIBILITY
       ======================================================== */

    --font-ui: var(--theme-font-family);

    --bg-page: var(--theme-page);
    --bg-surface: var(--theme-surface);
    --bg-subtle: var(--theme-surface-soft);

    --text-main: var(--theme-text);
    --text-secondary: var(--theme-muted);
    --text-muted: var(--theme-muted-2);

    --border: var(--theme-border);
    --border-strong: var(--theme-border-strong);

    --success: var(--theme-success);
    --warning: var(--theme-warning);
    --danger: var(--theme-danger);
    --info: var(--theme-info);

    --shadow-card: var(--theme-shadow-card);


    /* ========================================================
       3. ADMIN LEGACY VARIABLE BRIDGE
       ======================================================== */

    --ink: var(--theme-text);
    --ink-2: var(--theme-text-strong);
    --muted: var(--theme-muted);
    --muted-2: var(--theme-muted-2);

    --paper: var(--theme-page);
    --surface: var(--theme-surface);
    --surface-soft: var(--theme-surface-soft);

    --line: var(--theme-border);
    --line-strong: var(--theme-border-strong);

    --teal: var(--theme-primary);
    --teal-2: var(--theme-primary-hover);
    --teal-soft: var(--theme-primary-soft);

    --gold: var(--theme-accent);
    --gold-soft: var(--theme-accent-soft);

    --red: var(--theme-danger);
    --blue: var(--theme-info);

    --sidebar: var(--theme-sidebar);
    --sidebar-2: var(--theme-sidebar-2);
    --sidebar-text: var(--theme-sidebar-text);

    --radius: var(--theme-radius-card);
    --radius-sm: var(--theme-radius-control);


    /* ========================================================
       4. SUBSCRIBER PORTAL VARIABLE BRIDGE
       ======================================================== */

    --portal-accent: var(--theme-primary);
    --portal-accent-hover: var(--theme-primary-hover);
    --portal-accent-soft: var(--theme-primary-soft);

    --portal-page: var(--theme-page);
    --portal-surface: var(--theme-surface);
    --portal-surface-soft: var(--theme-surface-soft);

    --portal-text: var(--theme-text);
    --portal-text-soft: var(--theme-muted);
    --portal-border: var(--theme-border);

    --portal-success: var(--theme-success);
    --portal-danger: var(--theme-danger);
}


/* ============================================================
   GLOBAL FONT SOURCE OF TRUTH
   ============================================================ */

html,
body,
button,
input,
select,
textarea {
    font-family: var(--theme-font-family) !important;
}


/* ============================================================
   ADMIN CORE OVERRIDES
   ============================================================ */

body {
    color: var(--theme-text);
}

.sidebar {
    color: var(--theme-sidebar-text);
    background:
        radial-gradient(
            circle at 25% 4%,
            color-mix(in srgb, var(--theme-primary) 20%, transparent),
            transparent 15rem
        ),
        linear-gradient(
            180deg,
            var(--theme-sidebar),
            var(--theme-sidebar-2)
        );
}

.sidebar-nav a.active {
    background:
        linear-gradient(
            90deg,
            color-mix(in srgb, var(--theme-primary) 20%, transparent),
            color-mix(in srgb, var(--theme-primary) 8%, transparent)
        );

    box-shadow:
        inset -3px 0 0 var(--theme-primary);
}

.sidebar-nav a.active .icon {
    color: var(--theme-primary-soft);
}

.topbar {
    border-bottom-color: var(--theme-border);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--theme-primary) !important;
    box-shadow:
        0 0 0 4px
        color-mix(in srgb, var(--theme-primary) 12%, transparent) !important;
}

.btn {
    border-radius: var(--theme-radius-control);
}

.card,
.invoice-item,
.invoice-bank {
    border-color: var(--theme-border);
}


/* ============================================================
   PORTAL CORE OVERRIDES
   ============================================================ */

body.user-page,
body.login-page {
    background: var(--theme-page);
    color: var(--theme-text);
}
