/* ================================================================
   theme-dark-fixes.css — dark-mode gaps the theme layer never covered

   Section 1: a dark palette for the ops-* design tokens.
   Section 2 (end of file): Metronic utilities with no dark variant.

   dashboard-page.css and managedevice-page.css both declare the
   --ops-* token set on :root with LIGHT values only, and every page
   built on that design system (dashboard, devices, device drawer
   tabs, OS deploy, helpdesk/asset dashboards, AI assistant) reads
   them. Flipping data-theme therefore only repainted the Metronic
   header while the whole workspace stayed white.

   This file redefines the same tokens for every dark theme. The
   selector is qualified with `html` on purpose: several pages inject
   their own <link> to css/pages/*.css from inside the component (so
   it lands in <body>, after everything in <head>), and a bare
   [data-theme="dark"] ties with :root on specificity — the later
   light block would win.

   Tokens that no stylesheet ever defined (--ops-hover, --ops-text-3,
   --ops-primary-soft, …) are declared here too: they were only ever
   reached through their light var() fallbacks, which is exactly what
   painted white chips on the dark surfaces.
   ================================================================ */

/* ================================================================
   โทเค็นที่ถูกใช้แต่ไม่เคยมีใครนิยาม

   ตรวจทั้งระบบเมื่อ 2026-09-17: มี 13 ตัวที่ถูกอ้างผ่าน var() แต่ไม่มีที่ไหนประกาศค่าให้
   ทุกจุดจึงตกไปใช้ค่าสำรองในวงเล็บ ซึ่งผู้เขียนใส่เป็นสีโทนสว่างไว้เสมอ
   ผลคือบนธีมมืด "พื้นสว่าง + ตัวหนังสือที่รู้จักธีม" ปะทะกันจนอ่านไม่ออก — วัดเจอจริง 5 หน้า
   (หัวตาราง netdisc, chip ของ automation, แถบ dex, การ์ดของ refresh plan และ ai-usage)

   ค่าฝั่งสว่างตั้งให้ตรงกับค่าสำรองที่ใช้บ่อยที่สุดของแต่ละตัว ธีมสว่างจึงไม่ขยับ
   (--sc-text-muted ใช้ #78849a อยู่ 27 จุด · --sc-chip ใช้ #eef2f8 ทั้ง 7 จุด)
   ================================================================ */
:root {
    --sc-text-muted:  #78849a;
    --sc-chip:        #eef2f8;
    --sc-border-soft: #eef0f3;
    --sc-surface-3:   #eef2f7;
    --sc-danger:      #dc2626;
    --sc-primary-rgb: 99, 102, 241;
    --sc-focus-ring:  rgba(99, 102, 241, .2);
    --sc-mono:        ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --ops-subtle:     #f9fafb;
    --ops-border-2:   #cfd4e4;
    --ops-bad:        #dc2626;
    --ops-warn:       #b45309;
}

html:is([data-theme="dark"],
        [data-theme="claude-dark"],
        [data-theme="indigo-dark"],
        [data-theme="royal-dark"],
        [data-theme="green-eco-dark"],
        [data-theme="colorful-dark"]) {
    /* Surfaces — aligned with the --sc-* dark ramp in app.css */
    --ops-bg:            #0f172a;
    --ops-surface:       #1e293b;
    --ops-surface-2:     #172033;
    --ops-surface-3:     #263449;
    --ops-hover:         #223046;

    /* Lines */
    --ops-border:        #334155;
    --ops-border-soft:   #263449;
    --ops-border-strong: #475569;

    /* Text */
    --ops-text:          #f1f5f9;
    --ops-text-1:        #f1f5f9;
    --ops-text-2:        #cbd5e1;
    --ops-text-3:        #94a3b8;
    --ops-text-muted:    #94a3b8;
    --ops-muted:         #94a3b8;
    --ops-muted-2:       #8b98ae;
    --ops-faint:         #64748b;

    /* Brand */
    --ops-primary:       #818cf8;
    --ops-primary-50:    rgba(129, 140, 248, .12);
    --ops-primary-100:   rgba(129, 140, 248, .22);
    --ops-primary-soft:  rgba(129, 140, 248, .14);
    --ops-accent:        #60a5fa;
    --ops-accent-soft:   rgba(96, 165, 250, .16);

    /* Status — light-mode values are dark inks meant for white chips,
       so both the ink and the chip flip here. */
    --ops-success:       #4ade80;
    --ops-success-soft:  rgba(34, 197, 94, .16);
    --ops-warning:       #fbbf24;
    --ops-warning-soft:  rgba(245, 158, 11, .16);
    --ops-warning-bd:    rgba(245, 158, 11, .35);
    --ops-danger:        #f87171;
    --ops-danger-soft:   rgba(248, 113, 113, .16);
    --ops-danger-50:     rgba(248, 113, 113, .12);

    /* คู่ฝั่งมืดของโทเค็นที่ไม่เคยมีใครนิยาม (ดูบล็อก :root ด้านบน) */
    --sc-text-muted:  #94a3b8;
    --sc-chip:        #263449;
    --sc-border-soft: #263449;
    --sc-surface-3:   #263449;
    --sc-danger:      #f87171;
    --sc-primary-rgb: 129, 140, 248;
    --sc-focus-ring:  rgba(129, 140, 248, .28);

    --ops-subtle:     #172033;
    --ops-border-2:   #3b4a63;
    --ops-bad:        #f87171;
    --ops-warn:       #fbbf24;

    /* Shadows — a light-mode drop shadow is invisible on #0f172a, the
       hairline ring is what actually separates the cards. */
    --ops-sh-1: 0 1px 2px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .05);
    --ops-sh-2: 0 6px 18px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 255, 255, .05);
}

/* ================================================================
   Metronic utility classes with no dark variant
   `bg-light-*` is a fixed pastel wash (#f1faff and friends) paired
   with `text-*` ink of the same hue — readable on white, a bright
   patch with washed-out text once the surface behind it went dark.
   Only the wash flips; the ink stays the accent it already is.
   ================================================================ */
html:is([data-theme="dark"],
        [data-theme="claude-dark"],
        [data-theme="indigo-dark"],
        [data-theme="royal-dark"],
        [data-theme="green-eco-dark"],
        [data-theme="colorful-dark"]) {
    --bs-light-primary: rgba(96, 165, 250, .16);
    --bs-light-success: rgba(34, 197, 94, .16);
    --bs-light-danger:  rgba(248, 113, 113, .16);
    --bs-light-warning: rgba(245, 158, 11, .16);
    --bs-light-info:    rgba(168, 85, 247, .16);
}
html:is([data-theme="dark"],
        [data-theme="claude-dark"],
        [data-theme="indigo-dark"],
        [data-theme="royal-dark"],
        [data-theme="green-eco-dark"],
        [data-theme="colorful-dark"]) :is(.bg-light-primary, .bg-light-blue) {
    background-color: rgba(96, 165, 250, .16) !important;
    color: #93c5fd;
}
html:is([data-theme="dark"],
        [data-theme="claude-dark"],
        [data-theme="indigo-dark"],
        [data-theme="royal-dark"],
        [data-theme="green-eco-dark"],
        [data-theme="colorful-dark"]) :is(.bg-light-success, .bg-light-green) {
    background-color: rgba(34, 197, 94, .16) !important;
    color: #86efac;
}
html:is([data-theme="dark"],
        [data-theme="claude-dark"],
        [data-theme="indigo-dark"],
        [data-theme="royal-dark"],
        [data-theme="green-eco-dark"],
        [data-theme="colorful-dark"]) :is(.bg-light-danger, .bg-light-red) {
    background-color: rgba(248, 113, 113, .16) !important;
    color: #fca5a5;
}
html:is([data-theme="dark"],
        [data-theme="claude-dark"],
        [data-theme="indigo-dark"],
        [data-theme="royal-dark"],
        [data-theme="green-eco-dark"],
        [data-theme="colorful-dark"]) :is(.bg-light-warning, .bg-light-brown) {
    background-color: rgba(245, 158, 11, .16) !important;
    color: #fcd34d;
}
html:is([data-theme="dark"],
        [data-theme="claude-dark"],
        [data-theme="indigo-dark"],
        [data-theme="royal-dark"],
        [data-theme="green-eco-dark"],
        [data-theme="colorful-dark"]) .bg-light-info {
    background-color: rgba(168, 85, 247, .16) !important;
    color: #d8b4fe;
}

/* ══════════════════════════════════════════════════════════════════════════
   Operations Overview — ตระกูลสีของกราฟในธีมมืด
   ค่าชุดสว่างอยู่ใน dashboard-page.css · ลำดับขั้นกลับด้าน (1 = อ่อนสุด)
   เพื่อให้ขั้น 1-3 ยังเป็นขั้นที่วางตัวหนังสือสีพื้นหลังได้เหมือนธีมสว่าง
   ══════════════════════════════════════════════════════════════════════════ */
html:is([data-theme="dark"],
        [data-theme="claude-dark"],
        [data-theme="indigo-dark"],
        [data-theme="royal-dark"],
        [data-theme="green-eco-dark"],
        [data-theme="colorful-dark"]) :is(.ops-page, .pm-page, .cm-page, .th-page, .dct, .dth) {
    --ops-c-blue-1: #bfd6fe; --ops-c-blue-2: #60a5fa; --ops-c-blue-3: #3b82f6;
    --ops-c-blue-m: #2f66c8; --ops-c-blue-4: #2c4f96; --ops-c-blue-5: #1b3055;
    --ops-c-teal-1: #a5efe4; --ops-c-teal-2: #2dd4bf; --ops-c-teal-3: #14b8a6;
    --ops-c-teal-m: #109387; --ops-c-teal-4: #0e6f68; --ops-c-teal-5: #0a4741;
    --ops-c-viol-1: #d6c9fe; --ops-c-viol-2: #a78bfa; --ops-c-viol-3: #8b5cf6;
    --ops-c-viol-m: #6f4ccb; --ops-c-viol-4: #553d9e; --ops-c-viol-5: #33265e;
    --ops-c-rose-1: #fecdd3; --ops-c-rose-2: #fb7185; --ops-c-rose-3: #f43f5e;
    --ops-c-rose-m: #c0314f; --ops-c-rose-4: #8d2440; --ops-c-rose-5: #521428;
    --ops-c-amb-1:  #fde3b4; --ops-c-amb-2:  #fbbf24; --ops-c-amb-3:  #e09a12;
    --ops-c-amb-m:  #ad7712; --ops-c-amb-4:  #7a5511; --ops-c-amb-5:  #4a330a;
    --ops-c-grn-1:  #bbf7d0; --ops-c-grn-2:  #4ade80; --ops-c-grn-3:  #22c55e;
    --ops-c-grn-m:  #1c974e; --ops-c-grn-4:  #1a6c3f; --ops-c-grn-5:  #0f4227;
    --ops-c-sl-1:   #cbd5e1; --ops-c-sl-2:   #94a3b8; --ops-c-sl-3:   #64748b;
    --ops-c-sl-m:   #4b5768; --ops-c-sl-4:   #3c4757; --ops-c-sl-5:   #252e3c;
}

html:is([data-theme="dark"],
        [data-theme="claude-dark"],
        [data-theme="indigo-dark"],
        [data-theme="royal-dark"],
        [data-theme="green-eco-dark"],
        [data-theme="colorful-dark"]) :is(.ops-page, .pm-page, .cm-page, .th-page, .dct, .dth) {
    --ops-c-on-strong: #0b1220;
}
