/* ==========================================================================
   assets/theme-dark.css — dark appearance for the staff app.
   Active when <html data-theme="dark"> (set by nav.php from Settings → Display,
   or this device's own choice in the sidebar). Printed pages always use light colours.
   ========================================================================== */
html[data-theme="dark"]{
    color-scheme: dark;
    --bg:        #0e1014;
    --bg-2:      #161920;
    --card:      #1a1d25;
    --surface-2: #20242d;
    --text:      #e4e6eb;
    --heading:   #f5f6f8;
    --muted:     #a0a4ae;
    --muted-2:   #747985;
    --border:    #2c303a;
    --border-2:  #242832;

    --primary-dark:   #a5b4fc;
    --primary-darker: #c7d2fe;
    --primary-soft:   rgba(99,102,241,.18);
    --success:      #4ade80;  --success-soft: rgba(34,197,94,.16);
    --warning:      #fbbf24;  --warning-soft: rgba(245,158,11,.16);
    --danger:       #fb7185;  --danger-soft:  rgba(244,63,94,.16);
    --info-soft:    rgba(99,102,241,.18);
    --success-line: rgba(74,222,128,.3); --danger-line: rgba(251,113,133,.3); --warning-line: rgba(251,191,36,.3); --info-line: rgba(165,180,252,.3);
    --accent:       #a5b4fc;

    --shadow-xs: 0 1px 2px rgba(0,0,0,.4);
    --shadow:    0 1px 3px rgba(0,0,0,.45), 0 1px 2px rgba(0,0,0,.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,.45), 0 2px 4px rgba(0,0,0,.3);
    --shadow-lg: 0 12px 28px rgba(0,0,0,.55), 0 4px 8px rgba(0,0,0,.35);

    --light: #1a1d25; --dark: #e4e6eb; --gray: #a0a4ae; --gray-light: #161920;
    --slate-50:#1a1d25; --slate-100:#20242d; --slate-200:#2c303a; --slate-300:#3a3f4b; --slate-400:#747985;
    --slate-500:#a0a4ae; --slate-600:#c3c6cd; --slate-700:#d6d8dd; --slate-800:#e4e6eb; --slate-900:#f5f6f8;
    --ink: #e4e6eb;
    --row-hover: rgba(255,255,255,.035);
    --bar-bg: rgba(22,25,32,.94);
}
html[data-theme="dark"] body{
    background:var(--bg) !important;
    background-image:radial-gradient(1200px 600px at 100% -10%, rgba(99,102,241,.08), transparent 60%) !important;
    color:var(--text) !important;
}

/* Form controls, tables, modals that set their own light colours */
html[data-theme="dark"] input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea{
    background-color:var(--surface-2) !important; color:var(--text) !important; border-color:var(--border) !important;
}
html[data-theme="dark"] input::placeholder, html[data-theme="dark"] textarea::placeholder{ color:var(--muted-2) !important; }
html[data-theme="dark"] input:disabled, html[data-theme="dark"] select:disabled{ opacity:.6; }
html[data-theme="dark"] table{ color:var(--text); }
html[data-theme="dark"] thead, html[data-theme="dark"] thead tr{ background:var(--surface-2) !important; }
html[data-theme="dark"] th{ background:var(--surface-2) !important; color:var(--muted) !important; border-color:var(--border) !important; }
html[data-theme="dark"] td{ border-color:var(--border) !important; }
html[data-theme="dark"] hr{ border-color:var(--border); }
html[data-theme="dark"] code, html[data-theme="dark"] pre{ background:var(--surface-2); color:var(--text); }
html[data-theme="dark"] a:not([class]){ color:#a5b4fc; }

/* Inline styles written with light colours */
html[data-theme="dark"] [style*="background:#fff"]:not(.keep-light),
html[data-theme="dark"] [style*="background: #fff"]:not(.keep-light),
html[data-theme="dark"] [style*="background:white"]:not(.keep-light),
html[data-theme="dark"] [style*="background: white"]:not(.keep-light),
html[data-theme="dark"] [style*="background:#f8fafc"], html[data-theme="dark"] [style*="background: #f8fafc"],
html[data-theme="dark"] [style*="background:#f9fafb"], html[data-theme="dark"] [style*="background:#f1f5f9"],
html[data-theme="dark"] [style*="background:#f3f4f6"], html[data-theme="dark"] [style*="background:#fafafa"]{
    background:var(--card) !important;
}
html[data-theme="dark"] [style*="color:#111"], html[data-theme="dark"] [style*="color:#0f172a"],
html[data-theme="dark"] [style*="color:#1e293b"], html[data-theme="dark"] [style*="color:#1f2937"],
html[data-theme="dark"] [style*="color:#334155"], html[data-theme="dark"] [style*="color:#374151"],
html[data-theme="dark"] [style*="color: #111"], html[data-theme="dark"] [style*="color:#333"]{ color:var(--text) !important; }
html[data-theme="dark"] [style*="color:#6b7280"], html[data-theme="dark"] [style*="color:#64748b"],
html[data-theme="dark"] [style*="color:#94a3b8"]{ color:var(--muted) !important; }
html[data-theme="dark"] [style*="border:1px solid #e5e7eb"], html[data-theme="dark"] [style*="border:1px solid #e2e8f0"],
html[data-theme="dark"] [style*="border:1px dashed #cbd5e1"], html[data-theme="dark"] [style*="border: 1px solid #e5e7eb"]{ border-color:var(--border) !important; }

/* Scrollbars */
html[data-theme="dark"] ::-webkit-scrollbar-thumb{ background:#3a3f4b; }

/* Documents shown on screen (quotation, delivery slip, invoice preview) stay paper-white */
html[data-theme="dark"] .keep-light, html[data-theme="dark"] .keep-light *{ color-scheme: light; }
html[data-theme="dark"] .keep-light{
    --bg:#ffffff; --bg-2:#f4f4f2; --card:#ffffff; --surface-2:#fafafa; --text:#1b1b1f; --heading:#111114;
    --muted:#6b6b76; --muted-2:#9a9aa3; --border:#e7e7e3; --border-2:#efeeea;
    --primary-soft:#eef2ff; --success-soft:#dcfce7; --warning-soft:#fef3c7; --danger-soft:#ffe4e6;
    --success:#15803d; --warning:#b45309; --danger:#be123c; --primary-dark:#4338ca;
    background:#fff; color:#1b1b1f;
}
html[data-theme="dark"] .keep-light input, html[data-theme="dark"] .keep-light select, html[data-theme="dark"] .keep-light textarea{
    background-color:#fff !important; color:#1b1b1f !important; border-color:#e5e7eb !important;
}

/* Theme switch in the sidebar */
.theme-switch{display:flex;gap:4px;background:var(--bg-2);border:1px solid var(--border);border-radius:10px;padding:3px;margin:0 0 10px}
.theme-switch button{flex:1;min-width:0;border:0;background:transparent;color:var(--muted);border-radius:7px;padding:6px 2px;font:600 .7rem/1 inherit;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:4px;white-space:nowrap}
.theme-switch button i{font-size:.72rem}
.theme-switch button.on{background:var(--card);color:var(--heading);box-shadow:var(--shadow-xs)}
body.sidebar-collapsed .theme-switch{flex-direction:column}
body.sidebar-collapsed .theme-switch span{display:none}

@media print{
    html[data-theme="dark"]{ color-scheme: light;
        --bg:#fff; --bg-2:#f4f4f2; --card:#fff; --surface-2:#fafafa; --text:#1b1b1f; --heading:#111114; --muted:#6b6b76;
        --border:#e7e7e3; --border-2:#efeeea; --primary-soft:#eef2ff; --success-soft:#dcfce7; --warning-soft:#fef3c7; --danger-soft:#ffe4e6; }
    html[data-theme="dark"] body{ background:#fff !important; color:#1b1b1f !important; }
}

/* Pop-up messages (fixed position) must not be see-through on dark backgrounds */
html[data-theme="dark"] .alert[style*="position:fixed"],
html[data-theme="dark"] .alert[style*="position: fixed"]{
    background:var(--card) !important; color:var(--text) !important; border:1px solid var(--border) !important;
    box-shadow:var(--shadow-lg) !important;
}
html[data-theme="dark"] .alert-success[style*="position:fixed"]{ border-left:4px solid var(--success) !important; }
html[data-theme="dark"] .alert-warn[style*="position:fixed"]{ border-left:4px solid var(--warning) !important; }
html[data-theme="dark"] .alert-error[style*="position:fixed"]{ border-left:4px solid var(--danger) !important; }
