/* =====================================================
   theme.css
   THEME TOKENS + BASE TYPOGRAPHY  (single source of truth)

   - :root design tokens (colors, radius, shadows)
   - fonts live in fonts.css (stacks + body.v2-font-* mapping)
   - body.v2-theme-*   -> Light / Dark / Smart (follows OS)
   Allowed theme/font names live in
   Services/AppearanceOptions.cs; the body classes are produced
   from that class by _Layout.cshtml.
   Loaded AFTER site.css and page styles, exactly where the old
   inline <style> block was, so the cascade is unchanged.
   ===================================================== */

/* =====================================================
           ROOT
           ===================================================== */

:root {
    --v2-primary: #2563eb;
    --v2-primary-dark: #1d4ed8;
    --v2-primary-text: #ffffff;
    --v2-primary-soft: rgba(37, 99, 235, 0.09);
    --v2-focus-ring: rgba(37, 99, 235, 0.12);
    --v2-primary-shadow: rgba(37, 99, 235, 0.20);
    --v2-danger-bg: rgba(220, 38, 38, 0.08);
    --v2-sidebar-bg: #ffffff;
    --v2-sidebar-text: #1f2937;
    --v2-sidebar-muted: #64748b;
    --v2-sidebar-border: #e5e7eb;
    --v2-sidebar-hover: #f1f5f9;
    --v2-sidebar-active: #2563eb;
    --v2-sidebar-active-2: #1d4ed8;
    --v2-sidebar-active-text: #ffffff;
    --v2-body-bg: #f8fafc;
    --v2-card-bg: #ffffff;
    --v2-card-border: #e5e7eb;
    --v2-table-bg: #ffffff;
    --v2-table-head-bg: #f1f5f9;
    --v2-table-border: #e5e7eb;
    --v2-table-row-hover: #f8fafc;
    --v2-text: #111827;
    --v2-muted: #64748b;
    --v2-danger: #dc2626;
    --v2-success: #16a34a;
    --v2-warning: #d97706;
    --v2-success-bg: rgba(22, 163, 74, 0.08);
    --v2-success-border: rgba(22, 163, 74, 0.24);
    --v2-success-text: #15803d;
    --v2-danger-border: rgba(220, 38, 38, 0.24);
    --v2-danger-text: #b91c1c;
    --v2-info: #0891b2;
    --v2-info-bg: rgba(8, 145, 178, 0.08);
    --v2-info-border: rgba(8, 145, 178, 0.24);
    --v2-info-text: #0e7490;
    --v2-warning-bg: rgba(217, 119, 6, 0.10);
    --v2-warning-border: rgba(217, 119, 6, 0.24);

    /* Centralized accounting semantic colors */
    --v2-credit: #dc2626;
    --v2-debit: #16a34a;
    --v2-positive: #16a34a;
    --v2-negative: #dc2626;
    --v2-neutral: #64748b;
    --v2-zero: #64748b;

    --v2-sidebar-width: 290px;
    --v2-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    --v2-radius: 12px;
    --v2-focus: #2563eb;
    --v2-input-bg: #ffffff;
    --v2-control-bg: #ffffff;
    --v2-credit-bg: rgba(220, 38, 38, 0.08);
    --v2-debit-bg: rgba(22, 163, 74, 0.08);
    --v2-balance-bg: rgba(100, 116, 139, 0.08);
}


/* =====================================================
           CENTRALIZED APPLICATION FONT SELECTION
           ===================================================== */

/* =====================================================
           GLOBAL FONT
           ===================================================== */

html,
body {
    font-family: var(--v2-font-family);
}

button,
input,
select,
textarea,
table {
    font-family: var(--v2-font-family);
}

/* =========================================================
   CENTRAL TABLE THEME
   Keeps every normal application table compatible with
   Light / Dark / Smart themes.
   ========================================================= */
.table {
    --bs-table-bg: var(--v2-table-bg);
    --bs-table-color: var(--v2-text);
    --bs-table-border-color: var(--v2-table-border);
    --bs-table-hover-bg: var(--v2-table-row-hover);
    --bs-table-hover-color: var(--v2-text);
    color: var(--v2-text);
    background-color: var(--v2-table-bg);
    border-color: var(--v2-table-border);
}

.table > :not(caption) > * > * {
    background-color: var(--v2-table-bg);
    color: var(--v2-text);
    border-color: var(--v2-table-border);
}

.table > thead,
.table > tfoot {
    color: var(--v2-text);
}

.table > thead > tr > th,
.table > thead > tr > td {
    background-color: var(--v2-table-head-bg);
    color: var(--v2-text);
    border-color: var(--v2-table-border);
}

.table.table-light,
.table-light {
    --bs-table-bg: var(--v2-table-head-bg);
    --bs-table-color: var(--v2-text);
    --bs-table-border-color: var(--v2-table-border);
}

.table.table-light > :not(caption) > * > *,
.table-light > :not(caption) > * > * {
    background-color: var(--v2-table-head-bg);
    color: var(--v2-text);
    border-color: var(--v2-table-border);
}

.table > tbody > tr:hover > * {
    background-color: var(--v2-table-row-hover);
    color: var(--v2-text);
}


html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}


body {
    background: var(--v2-body-bg);
    color: var(--v2-text);
    overflow-x: hidden;
}


a {
    color: inherit;
}


/* =====================================================
           LIGHT THEME
           ===================================================== */

body.v2-theme-light {
    --v2-sidebar-bg: #ffffff;
    --v2-sidebar-text: #1f2937;
    --v2-sidebar-muted: #64748b;
    --v2-sidebar-border: #e5e7eb;
    --v2-sidebar-hover: #f1f5f9;
    --v2-body-bg: #f8fafc;
    --v2-card-bg: #ffffff;
    --v2-card-border: #e5e7eb;
    --v2-table-bg: #ffffff;
    --v2-table-head-bg: #f1f5f9;
    --v2-table-border: #e5e7eb;
    --v2-table-row-hover: #f8fafc;
    --v2-text: #111827;
    --v2-muted: #64748b;
    --v2-input-bg: #ffffff;
    --v2-control-bg: #ffffff;
    --v2-focus: #2563eb;
}


/* =====================================================
           DARK THEME
           ===================================================== */

body.v2-theme-dark {
    --v2-sidebar-bg: #111827;
    --v2-sidebar-text: #f8fafc;
    --v2-sidebar-muted: #94a3b8;
    --v2-sidebar-border: #374151;
    --v2-sidebar-hover: #1f2937;
    --v2-body-bg: #0f172a;
    --v2-card-bg: #111827;
    --v2-card-border: #374151;
    --v2-table-bg: #111827;
    --v2-table-head-bg: #1f2937;
    --v2-table-border: #374151;
    --v2-table-row-hover: #1f2937;
    --v2-text: #f8fafc;
    --v2-muted: #94a3b8;
    --v2-input-bg: #111827;
    --v2-control-bg: #111827;
    --v2-focus: #60a5fa;
    --v2-credit: #f87171;
    --v2-debit: #4ade80;
    --v2-positive: #4ade80;
    --v2-negative: #f87171;
    --v2-neutral: #94a3b8;
    --v2-zero: #94a3b8;
}


/* =====================================================
           SMART THEME
           ===================================================== */

body.v2-theme-smart {
    --v2-sidebar-bg: #ffffff;
    --v2-sidebar-text: #1f2937;
    --v2-sidebar-muted: #64748b;
    --v2-sidebar-border: #e5e7eb;
    --v2-sidebar-hover: #f1f5f9;
    --v2-body-bg: #f8fafc;
    --v2-card-bg: #ffffff;
    --v2-card-border: #e5e7eb;
    --v2-table-bg: #ffffff;
    --v2-table-head-bg: #f1f5f9;
    --v2-table-border: #e5e7eb;
    --v2-table-row-hover: #f8fafc;
    --v2-text: #111827;
    --v2-muted: #64748b;
    --v2-input-bg: #ffffff;
    --v2-control-bg: #ffffff;
    --v2-focus: #2563eb;
}


@media (prefers-color-scheme: dark) {

    body.v2-theme-smart {
        --v2-sidebar-bg: #111827;
        --v2-sidebar-text: #f8fafc;
        --v2-sidebar-muted: #94a3b8;
        --v2-sidebar-border: #374151;
        --v2-sidebar-hover: #1f2937;
        --v2-body-bg: #0f172a;
        --v2-card-bg: #111827;
        --v2-card-border: #374151;
        --v2-table-bg: #111827;
        --v2-table-head-bg: #1f2937;
        --v2-table-border: #374151;
        --v2-table-row-hover: #1f2937;
        --v2-text: #f8fafc;
        --v2-muted: #94a3b8;
        --v2-input-bg: #111827;
        --v2-control-bg: #111827;
        --v2-focus: #60a5fa;
        --v2-focus-ring: rgba(96, 165, 250, 0.18);
        --v2-credit: #f87171;
        --v2-debit: #4ade80;
        --v2-positive: #4ade80;
        --v2-negative: #f87171;
        --v2-neutral: #94a3b8;
        --v2-zero: #94a3b8;
        --v2-credit-bg: rgba(248, 113, 113, 0.12);
        --v2-debit-bg: rgba(74, 222, 128, 0.12);
        --v2-balance-bg: rgba(148, 163, 184, 0.12);
    }
}


/* =====================================================
           SINGLE ACCOUNTING COLOR CONTRACT
           Every page must use these classes/variables.
           Credit = رفت, Debit = آمد.
           Balance is determined by its sign.
           ===================================================== */
