/* ============================================================
   מערכת בקליק — סגנון
   ------------------------------------------------------------
   Tailwind נטען מה-CDN ומספק את השלד. כאן יושבים רק
   הרכיבים החוזרים והתיקונים שנדרשים ל-RTL אמיתי.
   ============================================================ */

@font-face {
  font-family: 'Heebo-fallback';
  src: local('Segoe UI'), local('Arial');
  size-adjust: 100%;
}

:root {
  --brand-500: #2563eb;
  --brand-600: #1d4ed8;
  --brand-700: #1e40af;

  --bg:        #f8fafc;
  --surface:   #ffffff;
  --surface-2: #f1f5f9;
  --ink:       #0f172a;
  --ink-2:     #334155;
  --muted:     #64748b;
  --muted-2:   #94a3b8;
  --line:      #e2e8f0;
  --line-soft: #f1f5f9;
  --brand-tint: #eff6ff;

  --ad-h-mobile: 90px;
  --ad-h-desktop: 250px;
}

/* ------------------------------------------------------------
   מצב לילה — מבוסס-מחלקה על ה-body, לא prefers-color-scheme.
   ------------------------------------------------------------
   זו אותה החלטה שתועדה ב-machziot_site, ומאותה סיבה: ערבוב שתי
   המכניקות מייצר את התקלה של games_site — משתמש שהעדפת המערכת
   שלו כהה אך בחר מצב יום מקבל רכיבים משתי הערכות בו-זמנית.
   מתג מפורש = מצב אחד ודאי, שנשמר לכל משתמש בנפרד.

   הפלטה זהה ל-Apps/schedule/.../ui/theme/Theme.kt, כדי ששני
   הלקוחות ייראו אותו דבר על אותו מסמך.
   ------------------------------------------------------------ */
body.dark-mode {
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #93c5fd;

  --bg:        #0b1220;   /* background   ב-Theme.kt */
  --surface:   #111a2b;   /* surface      */
  --surface-2: #1e293b;   /* surfaceVariant */
  --ink:       #e2e8f0;   /* onSurface    */
  --ink-2:     #cbd5e1;
  --muted:     #94a3b8;   /* onSurfaceVariant */
  --muted-2:   #64748b;
  --line:      #334155;   /* outline      */
  --line-soft: #1e293b;
  --brand-tint: #172554;

  color-scheme: dark;
}

/* ------------------------------------------------------------
   מיפוי מחלקות Tailwind למצב לילה
   ------------------------------------------------------------
   הממשק בנוי ברובו על מחלקות שירות של Tailwind, שצבעיהן קבועים
   ואינם משתנים עם מחלקה על ה-body. במקום לפזר וריאנטי dark:
   על מאות אלמנטים במרקאפ, השכבה הזו ממפה בדיוק את המחלקות
   שנמצאות בשימוש בפועל (נספרו מהקוד, לא נוחשו).

   הספציפיות עובדת לטובתנו: ‎.dark-mode .text-slate-900 היא 0,2,0
   מול 0,1,0 של Tailwind, ולכן גוברת ללא תלות בסדר הטעינה —
   ו-Tailwind מה-CDN מזריק את הסגנון שלו אחרי הגיליון הזה.
   ------------------------------------------------------------ */

body.dark-mode .bg-white        { background-color: var(--surface) !important; }
/* דף הנחיתה נושא bg-white על ה-body עצמו — סלקטור צאצא לא היה
   תופס אותו, והתוצאה היא עמוד לבן עם כרטיסים כהים. */
body.dark-mode.bg-white         { background-color: var(--bg) !important; }
body.dark-mode .bg-slate-50     { background-color: var(--bg) !important; }
body.dark-mode .bg-slate-100    { background-color: var(--surface-2) !important; }
body.dark-mode .bg-slate-900    { background-color: #020617 !important; }
body.dark-mode .bg-brand-50     { background-color: var(--brand-tint) !important; }

body.dark-mode .text-slate-900,
body.dark-mode .text-slate-800  { color: var(--ink) !important; }
body.dark-mode .text-slate-700,
body.dark-mode .text-slate-600  { color: var(--ink-2) !important; }
body.dark-mode .text-slate-500,
body.dark-mode .text-slate-400,
body.dark-mode .text-slate-300  { color: var(--muted) !important; }
body.dark-mode .text-brand-700  { color: var(--brand-700) !important; }

body.dark-mode .border-slate-200 { border-color: var(--line) !important; }
body.dark-mode .border-slate-100 { border-color: var(--line-soft) !important; }
body.dark-mode .divide-slate-100 > :not([hidden]) ~ :not([hidden]) {
  border-color: var(--line-soft) !important;
}

/* מצבי מצב (הצלחה/אזהרה/שגיאה): הרקעים הבהירים הופכים לרקעים
   כהים־רוויים, והטקסט מתבהר. בלי זה, כרטיס אזהרה בלילה הוא
   מלבן צהוב זוהר שמסנוור את כל המסך. */
body.dark-mode .bg-amber-50,
body.dark-mode .bg-amber-50\/40  { background-color: #2a1f07 !important; }
body.dark-mode .border-amber-200 { border-color: #78450f !important; }
body.dark-mode .text-amber-900,
body.dark-mode .text-amber-800,
body.dark-mode .text-amber-700,
body.dark-mode .text-amber-600   { color: #fcd34d !important; }

body.dark-mode .bg-rose-50       { background-color: #2c0b13 !important; }
body.dark-mode .border-rose-200,
body.dark-mode .border-rose-100  { border-color: #881337 !important; }
body.dark-mode .text-rose-900,
body.dark-mode .text-rose-800,
body.dark-mode .text-rose-700,
body.dark-mode .text-rose-600    { color: #fda4af !important; }

body.dark-mode .bg-emerald-50    { background-color: #052e21 !important; }
body.dark-mode .text-emerald-700,
body.dark-mode .text-emerald-600 { color: #6ee7b7 !important; }

body.dark-mode .border-brand-200 { border-color: var(--brand-600) !important; }
body.dark-mode .ring-brand-100   { --tw-ring-color: var(--brand-700) !important; }

/* הכותרת והמגירה שקופות-למחצה מעל הרקע */
body.dark-mode .bg-white\/90,
body.dark-mode .bg-white\/85     { background-color: rgb(17 26 43 / .92) !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Heebo', 'Rubik', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overscroll-behavior-y: none;
  transition: background-color .18s ease, color .18s ease;
}

/* ------------------------------------------------------------
   RTL — הדפדפן עושה את רוב העבודה דרך dir="rtl".
   מה שנשאר הוא מספרים, זמנים וכיווני אנימציה.
   ------------------------------------------------------------ */

[dir='rtl'] input[type='time'],
[dir='rtl'] input[type='number'],
[dir='rtl'] .ltr-nums {
  direction: ltr;
  text-align: right;
}

[dir='rtl'] .flip-x { transform: scaleX(-1); }

/* ------------------------------------------------------------
   רכיבים
   ------------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.04);
}

.input {
  width: 100%;
  height: 2.75rem;
  padding: 0 0.875rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--surface);
  font-size: 0.925rem;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.12);
}
select.input { padding-inline-end: 2rem; }

.label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 0.375rem;
}

.btn-primary,
.btn-ghost,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  height: 2.625rem;
  padding: 0 1.125rem;
  border-radius: 0.75rem;
  font-size: 0.9rem;
  font-weight: 700;
  transition: background-color .15s, opacity .15s, transform .1s;
  white-space: nowrap;
}
.btn-primary { background: var(--brand-600); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-700); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: var(--surface-2); color: var(--ink-2); }
.btn-ghost:hover { background: var(--line); }
.btn-danger { background: #e11d48; color: #fff; }
.btn-danger:hover { background: #be123c; }
.btn-primary:active, .btn-ghost:active, .btn-danger:active { transform: translateY(1px); }

.icon-btn {
  width: 2rem; height: 2rem;
  border-radius: 0.5rem;
  display: inline-grid; place-items: center;
  font-size: 0.9rem;
  transition: background-color .15s;
}
.icon-btn:hover { background: var(--surface-2); }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 0.5rem;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 0.75rem;
  font-weight: 700;
}

.chip-lg {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  border-radius: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.875rem;
}

.chip-toggle span {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  border-radius: 0.6rem;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all .12s;
  user-select: none;
}
.chip-toggle span:hover { border-color: var(--muted-2); }

/* מתג מצב הלילה — אותו רכיב כמו ב-machziot_site:
   גובה מגע 44px, פינות גלולה, וגבול שמתחלף בריחוף. */
.btn-toggle-dark {
  min-height: 2.25rem;
  padding: 0 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--ink-2);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  transition: border-color .18s, transform .18s;
  white-space: nowrap;
}
.btn-toggle-dark:hover { border-color: var(--brand-500); transform: translateY(-1px); }

@media (prefers-reduced-motion: reduce) {
  .btn-toggle-dark:hover { transform: none; }
}

.day-toggle {
  padding: 0.5rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  transition: all .12s;
}
.day-toggle.is-on {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: #fff;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.625rem 0.875rem;
  border-radius: 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-2);
  text-align: start;
  transition: background-color .12s, color .12s;
}
.nav-item:hover:not(:disabled) { background: var(--surface-2); }
.nav-item.is-active { background: var(--brand-tint); color: var(--brand-700); }

/* ------------------------------------------------------------
   בוררים — כפתורי בחירה קטנים (יעדים, ימים, שעות, מסננים)
   ------------------------------------------------------------ */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.7rem;
  border-radius: 0.6rem;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-2);
  transition: all .12s;
  white-space: nowrap;
}
.pill:hover { border-color: var(--muted-2); }
.pill.is-on {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: #fff;
}

.type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.75rem 0.5rem;
  border-radius: 0.75rem;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  transition: all .12s;
}
.type-card:hover { border-color: var(--muted-2); background: var(--bg); }
.type-card.is-on {
  border-color: var(--brand-600);
  background: var(--brand-tint);
  color: var(--brand-700);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

/* ------------------------------------------------------------
   לוח הג'וקרים — משבצת נלחצת
   ------------------------------------------------------------ */

.slot {
  position: relative;
  width: 100%;
  height: 2.75rem;
  border-radius: 0.6rem;
  border: 1px dashed var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
  gap: 2px;
  grid-auto-flow: column;
  transition: all .1s;
}
.slot:hover { border-color: var(--brand-500); background: var(--bg); }
.slot.is-set { border-style: solid; }

.slot-mark {
  display: inline-grid;
  place-items: center;
  width: 1.5rem; height: 1.5rem;
  border-radius: 0.4rem;
  font-size: 0.75rem;
  filter: saturate(1.4);
}
.slot-dot { width: 6px; height: 6px; border-radius: 999px; }
.slot-other {
  position: absolute;
  inset-block-start: 2px; inset-inline-end: 4px;
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--muted-2);
}

/* ------------------------------------------------------------
   תאי המערכת
   ------------------------------------------------------------ */

.lesson {
  border-inline-start: 3px solid var(--muted-2);
  background: var(--bg);
  border-radius: 0.4rem;
  padding: 0.3rem 0.45rem;
  margin-bottom: 0.25rem;
}
.lesson:last-child { margin-bottom: 0; }
.lesson-title { font-size: 0.8125rem; font-weight: 700; color: var(--ink); line-height: 1.25; }
.lesson-sub { font-size: 0.6875rem; color: var(--muted); line-height: 1.3; }
.lesson-tag {
  display: inline-block;
  margin-top: 2px;
  padding: 0 0.35rem;
  border-radius: 0.35rem;
  background: var(--brand-tint);
  color: var(--brand-700);
  font-size: 0.5625rem;
  font-weight: 700;
}

input[type='range'] { height: 1.25rem; cursor: pointer; }

/* ------------------------------------------------------------
   פרסומות — הגובה שמור מראש.
   יחידה שנטענת אחרי הציור ומזיזה את התוכן היא הדרך המהירה
   ביותר לגרום למנהל ללחוץ על הכפתור הלא נכון.
   ------------------------------------------------------------ */

.ad-slot {
  display: block;
  min-height: var(--ad-h-mobile);
  background: repeating-linear-gradient(45deg, var(--bg), var(--bg) 10px, var(--surface-2) 10px, var(--surface-2) 20px);
  border: 1px dashed var(--line);
  border-radius: 0.75rem;
  overflow: hidden;
  position: relative;
}
.ad-slot::after {
  content: 'שטח פרסום';
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 50%;
  transform: translate(50%, -50%);
  font-size: 0.6875rem;
  color: var(--muted-2);
  letter-spacing: 0.05em;
  pointer-events: none;
}
.ad-slot .adsbygoogle { position: relative; z-index: 1; display: block; }
.ad-slot--tall { min-height: var(--ad-h-desktop); }

/* מגירת ניווט במובייל */
body.drawer-open { overflow: hidden; }

@media (min-width: 640px) {
  .ad-slot { min-height: 120px; }
}

/* ------------------------------------------------------------
   הדפסה — המסמך שבית הספר באמת מחלק בחדר מורים.
   הכל שנשאר על הדף הוא הכותרת והגריד.
   ------------------------------------------------------------ */
@media print {
  .ad-slot, #drawer, #topbar, #demo-banner, #toast-root, .no-print { display: none !important; }
  body { background: var(--surface); }
  .card { border: none; box-shadow: none; }
  #view { min-height: 0 !important; }
  .print-block { break-inside: avoid; }
  table { width: 100% !important; min-width: 0 !important; font-size: 10pt; }
  .lesson { background: var(--surface); border-inline-start-width: 4px; }
  .lesson-title { font-size: 9pt; }
  .lesson-sub { font-size: 7.5pt; }
  @page { size: landscape; margin: 10mm; }
}
