/* מצב בהיר/כהה לכל המסכים (בעל המערכת, 03/10: "תוסיף רקע בהיר וכהה לכל המסכים כמו בדשבורד").
   המצב נקבע ב-web/theme.js על <html data-theme="light|dark">, לפני הציור הראשון.
   הצבעים הכהים לקוחים מערכת הכהה הקיימת של לוח הבקרה ומסך היעילות (web/efficiency.css):
   רקע #0A0E13, כרטיס #121820, קו #232C38, טקסט #EDF1F6. במצב בהיר הקובץ הזה כמעט לא חל
   (רק עיצוב המתג בכותרת), ולכן המראה הבהיר נשאר כמו שהיה.
   הקובץ המשלים web/theme-dark-auto.css מומר אוטומטית מצבעים קשיחים בקבצים הקיימים.
   תצוגה בלבד: לא נוגע בנתונים, במספרים או במבנה. */

/* ---------- טוקנים: הגרסה הכהה של משתני :root ב-styles.css ---------- */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0A0E13;
  --panel: #121820;
  --panel-bg: #121820;
  --border: #2C3644;
  --text: #EDF1F6;
  --muted: #A3AEBD;            /* 7.9:1 על כרטיס */
  --accent: #7DA0FF;           /* כטקסט/קו; כפתור ראשי נשאר בגרדיאנט המותג */
  --accent-weak: #172447;
  --ok: #5FD8B0;   --ok-weak: #0E2A23;
  --warn: #F6BF5C; --warn-weak: #2C2310;
  --danger: #FF8F94; --danger-weak: #351619;
  --purple: #C4B5FD; --purple-weak: #241A42;
  --teal: #5EEAD4; --teal-weak: #0F2B29;
  /* styles.css, בלוק "live efficiency dashboard" */
  --st-ok: #5FD8B0; --st-ok-weak: #0E2A23;
  --st-warn: #F6BF5C; --st-warn-weak: #2C2310;
  --st-crit: #FF8F94; --st-crit-weak: #351619;
  --st-na: #8F9BAB; --st-na-weak: #1A212B;
  --st-roster: #B3A4F5; --st-roster-weak: #211B3D;
  --m-login: #7DA0FF; --m-talk: #2DD4BF; --m-occ: #A5B4FC; --m-cph: #A3AEBD; --m-aht: #C4B5FD;
  --seq-0: #121d2e; --seq-1: #16273f; --seq-2: #1c3a63; --seq-3: #1f4f8e; --seq-4: #2668c0; --seq-5: #5598e7;
  --ink-axis: #3A4656; --ink-grid: #232C38; --ink-ref: #EDF1F6; --whisker: #8F9BAB;
  --sh-1: 0 1px 2px rgba(0,0,0,.4); --sh-2: 0 10px 30px -10px rgba(0,0,0,.6);
  --sh-focus: 0 0 0 2px #0A0E13, 0 0 0 4px #9DB8FF;
  --att-other: #4A5567;
  background: var(--bg);
}
html[data-theme="dark"] body { background: var(--bg); color: var(--text); }

/* כותרת עליונה ותפריט (נשארו לבנים במצב כהה) */
html[data-theme="dark"] header.app-header,
html[data-theme="dark"] nav.tabs { background: var(--panel); border-color: var(--border); }
html[data-theme="dark"] header.app-header h1 { color: var(--text); }
html[data-theme="dark"] nav.tabs button { color: var(--muted); }
html[data-theme="dark"] nav.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* שדות, כפתורים משניים, טבלאות - ברירות המחדל של הדפדפן לא תמיד מתאימות.
   :where() = בלי משקל: כל כלל ספציפי של מסך (למשל שדות במסך היעילות) ממשיך לגבור. */
:where(html[data-theme="dark"]) :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]), select, textarea) {
  background-color: #0E131A; color: var(--text); border-color: #364252;
}
:where(html[data-theme="dark"]) :where(input, textarea)::placeholder { color: #8390A2; opacity: 1; }
:where(html[data-theme="dark"]) :where(input, select, textarea):disabled { color: #8F9BAB; background-color: #171E27; }
:where(html[data-theme="dark"]) button.secondary { background: var(--panel); color: var(--text); border-color: #364252; }
:where(html[data-theme="dark"]) button.secondary:hover { background: var(--accent-weak); color: var(--accent); border-color: var(--accent); }
:where(html[data-theme="dark"]) :where(button:not([class])) { color: var(--text); }
:where(html[data-theme="dark"]) :where(th) { color: var(--muted); }
:where(html[data-theme="dark"]) :where(a) { color: var(--accent); }
:where(html[data-theme="dark"]) .panel { box-shadow: 0 1px 2px rgba(0,0,0,.4); }
:where(html[data-theme="dark"]) .tooltip-bubble { background: #1E2631; color: var(--text); border-color: #364252; }
:where(html[data-theme="dark"]) :where(dialog) { background: var(--panel); color: var(--text); border-color: var(--border); }
:where(html[data-theme="dark"]) :where(dialog)::backdrop { background: rgba(0, 0, 0, .6); }
:where(html[data-theme="dark"]) :where(hr) { border-color: var(--border); }
:where(html[data-theme="dark"]) :where(code, pre) { background: #0E131A; color: var(--text); }

/* גרפים (SVG/canvas שצובעים מטוקנים) - צירים וטקסט קריאים */
html[data-theme="dark"] .dash-ax { fill: var(--muted); }
html[data-theme="dark"] .dash-skel { background: linear-gradient(90deg, #171E27, #1E2631, #171E27); background-size: 200% 100%; }

/* "זמן אמת": ערכת הכהה שהייתה רק במצב קיר חלה עכשיו גם כשנבחר כהה */
html[data-theme="dark"] .rt2 {
  color-scheme: dark;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 10px 30px -10px rgba(0, 0, 0, .6);
  --c-bg: #0A0E13; --c-surface: #121820; --c-surface-2: #171E27; --c-sunken: #0E131A;
  --c-line: #232C38; --c-line-strong: #364252;
  --c-ink: #F4F7FB; --c-ink-2: #C9D2DE; --c-ink-3: #9AA6B6;
  --c-accent: #7DA0FF; --c-accent-tint: #172447; --c-accent-on: #08122E; --c-focus: #9DB8FF;
  --ok-solid: #2BB88E; --ok-on: #03140E; --ok-fg: #5FD8B0; --ok-tint: #0E2A23; --ok-line: #1F5E4B;
  --warn-mark: #F5B23A; --warn-solid: #F5B23A; --warn-on: #2A1A00; --warn-fg: #F6BF5C; --warn-tint: #2C2310; --warn-line: #6E5620;
  --crit-solid: #F0565C; --crit-on: #1D0204; --crit-fg: #FF8F94; --crit-tint: #351619; --crit-line: #7E2C32;
  --idle-solid: #8F9BAB; --idle-on: #0A0E13; --idle-fg: #B6C0CD; --idle-tint: #1A212B; --idle-line: #364252;
  --cat-call: #5B87FF; --cat-avail: #35508F; --cat-lunch: #9B85F0; --cat-train: #54479A; --cat-priv: #6C7889; --cat-admin: #8A7A55; --cat-other: #3A4453;
}
/* מסך העלויות (.cst) מגדיר צבעים משלו; כאן הגרסה הכהה שלהם */
html[data-theme="dark"] .cst {
  --c-surface: #121820; --c-surface-2: #171E27; --c-sunken: #0E131A; --c-line: #232C38; --c-line-strong: #364252;
  --c-ink: #EDF1F6; --c-ink-2: #B6C0CD; --c-ink-3: #97A3B3; --c-accent: #7DA0FF;
  --ok-solid: #2BB88E; --ok-tint: #0E2A23; --ok-line: #1F5E4B;
  --warn-fg: #F6BF5C; --warn-tint: #2C2310; --warn-line: #6E5620;
  --crit-fg: #FF8F94; --crit-tint: #351619; --crit-line: #7E2C32;
}

/* ---------- מתג אחד בכותרת: בהיר / כהה / לפי המכשיר ---------- */
.theme-switch {
  display: inline-flex; align-items: stretch; gap: 2px; padding: 2px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg);
}
.theme-switch__btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; min-width: 44px; padding: 0 10px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.theme-switch__btn:hover { color: var(--text); }
.theme-switch__btn[aria-pressed="true"] { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(16, 24, 40, .14); }
html[data-theme="dark"] .theme-switch__btn[aria-pressed="true"] { background: #232C38; box-shadow: none; }
.theme-switch__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-switch__ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.theme-switch__btn[data-theme-set="dark"] .theme-switch__ic { fill: currentColor; stroke: none; }
.theme-switch__btn[data-theme-set="light"] .theme-switch__ic circle { fill: currentColor; }
/* טלפון: אייקונים בלבד (השם המלא נשאר ב-title ובקורא המסך דרך aria-label של הקבוצה + טקסט מוסתר) */
@media (max-width: 560px) {
  .theme-switch__btn { padding: 0 8px; }
  .theme-switch__btn span {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
}

/* כפתורי הירח הישנים בתוך המסכים: הוחלפו במתג האחד בכותרת (theme.js מפנה אליו גם לחיצה) */
#efx-theme, #opsb-theme, #fcs-theme, #fsc-theme, #fst-theme, #fwi-theme, #fsn-theme, .nx-theme-toggle { display: none !important; }

/* פוקוס נראה גם על רקע כהה */
html[data-theme="dark"] :focus-visible { outline-color: #9DB8FF; }

/* ---------- צבעים שנכתבים ישירות על הרכיב (style=) בחלון פירוט המשמרת בלשונית הנוכחות ----------
   צבעים בלבד: אותו גוון, בהיר יותר על רקע כהה. לא נוגע בטקסט, במספרים או בסדר. */
html[data-theme="dark"] [style^="color:#2563eb"], html[data-theme="dark"] [style*=";color:#2563eb"] { color: #7DA0FF !important; }
html[data-theme="dark"] [style^="color:#d97706"], html[data-theme="dark"] [style*=";color:#d97706"] { color: #F6BF5C !important; }
html[data-theme="dark"] [style^="color:#7c3aed"], html[data-theme="dark"] [style*=";color:#7c3aed"] { color: #C4B5FD !important; }
html[data-theme="dark"] [style*="background:#eaf0fe"] { background-color: #172447 !important; }
html[data-theme="dark"] [style*="background:#fdf2e2"] { background-color: #2C2310 !important; }
html[data-theme="dark"] [style*="background:#f1e9fe"] { background-color: #241A42 !important; }

/* ---------- ניגודיות AA שהייתה חסרה גם קודם (בהיר בלבד, נמצאה בבדיקה האוטומטית 03/10) ---------- */
html[data-theme="light"] .sd-tile.warn .n { color: #b45309; }           /* היה #d97706 = 2.95:1, עכשיו 4.6:1 */
html[data-theme="light"] .src-tag.att,
html[data-theme="light"] .badge.ok,
html[data-theme="light"] .dir-chip.in { color: #166534; }               /* היה #16a34a על ירוק בהיר = 3.0:1, עכשיו 6.5:1 */

html[data-theme="light"] .sd-note,
html[data-theme="light"] .sd-badge.late,
html[data-theme="light"] .sd-badge.pending { color: #92400e; }        /* היה 2.88:1 */
html[data-theme="light"] .sd-badge.nologin,
html[data-theme="light"] #tab-availability .cal-no { color: #b91c1c; } /* היה 4.17:1 */
html[data-theme="light"] .src-tag.plan { color: #5b4bc4; }             /* היה 4.45:1 */
html[data-theme="light"] .pl-circ { color: #1c2230; }                  /* שלב עתידי: לבן על אפור בהיר היה 1.6:1 */
html[data-theme="light"] .pl-step.pl-done .pl-circ,
html[data-theme="light"] .pl-step.pl-active .pl-circ { color: #fff; }
html[data-theme="light"] #tab-availability { --rz-muted: #5c5b78; }    /* תאריכים בלוח: היה 4.48:1 */
#tab-availability .hist-tile:first-child .t { color: #fff; }
html[data-theme="light"] #tab-availability .cal-empty { color: #6b6a86; } /* "—" ביום ריק: היה 1.69:1 */           /* על הסגול: היה 4.12:1 (בשני המצבים) */
/* "חיזוי איוש"/"שיבוץ" בבהיר: תגי הנאון (טורקיז/כתום זוהר) לא קריאים על לבן */
#tab-forecast.nx-light .badge.ok, #tab-schedule.nx-light .badge.ok { background: #e3f5ed; color: #0b6b4f; }
#tab-forecast.nx-light .badge.warn, #tab-schedule.nx-light .badge.warn { background: #fdf1df; color: #92400e; }
#tab-forecast.nx-light .badge.neutral, #tab-schedule.nx-light .badge.neutral { background: #eef1f5; color: #4b5563; }

/* "המשמרות שלי": הסגול העמוק משמש כטקסט (תאריכים, שעות, מספרים) - בכהה גוון בהיר שלו */
html[data-theme="dark"] #tab-availability { --rz-purple-deep: #B3A4F5; }
/* מסלול תקופת השיבוץ: מספר לבן בעיגול - בכהה העיגול נשאר ירוק מלא */
html[data-theme="dark"] .pl-step.pl-done .pl-circ { background: #12805c; }
html[data-theme="dark"] .pl-circ { color: #fff; }

/* פס החלוקה בלשונית הנוכחות (LOGIN / LOGOUT PRIVET / LOGOUT): טקסט לבן על הפס, ולכן בכהה
   הפס נשאר בגוון המלא (לא הגרסה הבהירה של הטוקן). צבעים בלבד. */
html[data-theme="dark"] .att-seg-login  { background: #12805c; }
html[data-theme="dark"] .att-seg-privet { background: #9a5208; }
html[data-theme="dark"] .att-seg-logout { background: #566274; }
html[data-theme="dark"] .att-seg-other  { background: #4A5567; }

/* ---------- כפתור ראשי בנאון של "חיזוי איוש"/"שיבוץ" במצב כהה: לבן על #7c5cff היה 4.35:1 ---------- */
#tab-forecast:not(.nx-light) .panel button.primary,
#tab-schedule:not(.nx-light) .panel button.primary { background: linear-gradient(135deg, #6345e8, #4327b0); color: #fff; }
