/* ============================================================
   RUAV — Weekly Course Schedule (schedule.js)
   Uses the app tokens from style.css (--primary, --border, …)
   Logical properties everywhere so Hebrew (RTL) / English (LTR)
   mirror automatically — the hours column follows the language.
   ============================================================ */
.sch { --sch-time-w: 58px; --sch-col-min: 118px; font-family: var(--font); color: var(--text); }
.sch[lang="he"] { font-family: "Heebo", var(--font); }
.sch .lc { width: 16px; height: 16px; flex: 0 0 auto; }

/* toolbars */
.sch-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.sch-bar__end { margin-inline-start: auto; display: flex; gap: 6px; }
.sch-bar--week { justify-content: space-between; }
.sch-nav, .sch-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sch .btn { display: inline-flex; align-items: center; gap: 6px; }
.sch-ibtn { width: var(--btn-h, 40px); padding: 0 !important; justify-content: center; }
.sch-week { font-weight: 800; font-size: 1.02rem; margin-inline-start: 6px; color: var(--navy); }
.sch-jump { height: var(--btn-h, 40px); border: 1px solid var(--border); border-radius: 10px; padding: 0 8px; font: inherit; color: var(--text); background: var(--card); }
.sch-course { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.sch-course .select { min-width: 180px; }
.sch-course-name { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; color: var(--navy); }
.sch-course-name .lc { width: 20px; height: 20px; color: var(--primary); }

/* track tabs */
.sch-tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 3px; gap: 3px; }
.sch-tab { border: 0; background: transparent; padding: 7px 16px; border-radius: 9px; font: inherit; font-weight: 700; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.sch-tab.is-active { background: var(--card); color: var(--primary); box-shadow: var(--shadow-sm); }
.sch-count { font-size: .75rem; background: var(--soft); border: 1px solid var(--border); border-radius: 99px; padding: 0 7px; color: var(--muted); }
.sch-tab.is-active .sch-count { background: rgba(var(--primary-rgb), .1); color: var(--primary); border-color: transparent; }

/* status */
.sch-status { display: flex; align-items: center; gap: 10px; margin: -2px 0 10px; font-size: .85rem; flex-wrap: wrap; }
.sch-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-weight: 700; font-size: .8rem; border: 1px solid transparent; }
.sch-pill.is-ok { background: #e8f5e9; color: var(--ok); border-color: #c8e6c9; }
.sch-pill.is-warn { background: #fff4e0; color: var(--warn); border-color: #fde2b5; }
.sch-pill.is-muted { background: var(--soft); color: var(--muted); border-color: var(--border); }
.sch-muted { color: var(--muted); }

/* grid */
.sch-scroll { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); max-height: min(72vh, 760px); position: relative; }
.sch-grid { display: grid; grid-template-columns: var(--sch-time-w) repeat(7, minmax(var(--sch-col-min), 1fr)); min-width: calc(var(--sch-time-w) + 7 * var(--sch-col-min)); position: relative; }
.sch-corner, .sch-dayhead { position: sticky; top: 0; z-index: 3; background: var(--soft); border-bottom: 1px solid var(--border); }
.sch-corner { inset-inline-start: 0; z-index: 4; border-inline-end: 1px solid var(--border); }
.sch-dayhead { padding: 8px 6px; text-align: center; display: flex; flex-direction: column; gap: 1px; border-inline-start: 1px solid var(--border); }
.sch-dayhead b { font-size: .92rem; color: var(--navy); }
.sch-dayhead span { font-size: .78rem; color: var(--muted); }
.sch-dayhead.is-today { background: rgba(var(--primary-rgb), .08); }
.sch-dayhead.is-today b, .sch-dayhead.is-today span { color: var(--primary); }

.sch-times { position: sticky; inset-inline-start: 0; z-index: 2; background: var(--card); border-inline-end: 1px solid var(--border); }
.sch-time { position: absolute; inset-inline: 0; transform: translateY(-50%); text-align: center; font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.sch-time.is-hour { font-weight: 700; color: var(--text); font-size: .76rem; }
.sch-time:first-child { transform: translateY(2px); }

.sch-col { position: relative; border-inline-start: 1px solid var(--border);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--slot-h) - 1px), #edf1f6 calc(var(--slot-h) - 1px), #edf1f6 var(--slot-h)); }
.sch-col.is-today { background-color: rgba(var(--primary-rgb), .035); }
.sch-col.is-edit { cursor: copy; }
.sch-now { position: absolute; inset-inline: 0; height: 2px; background: var(--bad); z-index: 2; pointer-events: none; }
.sch-now::before { content: ""; position: absolute; inset-inline-start: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }

/* events */
.sch-ev { position: absolute; box-sizing: border-box; background: var(--ev-bg); color: var(--ev-fg); border: 1px solid color-mix(in srgb, var(--ev-bd) 35%, transparent);
  border-inline-start: 4px solid var(--ev-bd); border-radius: 8px; padding: 4px 6px; overflow: hidden; font-size: .78rem; line-height: 1.25;
  cursor: pointer; z-index: 1; transition: box-shadow .15s, transform .15s; outline: none; }
.sch-ev:hover, .sch-ev:focus-visible { box-shadow: 0 4px 14px rgba(15,42,68,.16); z-index: 5; }
.sch-ev:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.sch-ev.is-edit { cursor: grab; touch-action: none; user-select: none; }
.sch-ev.is-dragging { cursor: grabbing; opacity: .9; box-shadow: 0 10px 28px rgba(15,42,68,.28); z-index: 10; transition: none; }
.sch-ev__time { white-space: nowrap; font-weight: 700; font-size: .72rem; opacity: .85; font-variant-numeric: tabular-nums; }
.sch-ev__title { font-weight: 800; word-break: break-word; }
.sch-ev__meta { display: flex; align-items: center; gap: 3px; font-size: .72rem; opacity: .85; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sch-ev__meta .lc { width: 12px; height: 12px; }
.sch-ev.is-short { display: flex; gap: 6px; align-items: baseline; padding-block: 1px; }
.sch-ev.is-short .sch-ev__title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sch-ev__resize { position: absolute; inset-inline: 0; bottom: 0; height: 8px; cursor: ns-resize; }
.sch-ev__resize::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 22px; height: 3px; margin-left: -11px; border-radius: 3px; background: var(--ev-bd); opacity: 0; transition: opacity .15s; }
.sch-ev:hover .sch-ev__resize::after { opacity: .55; }
.sch-badge { display: inline-block; font-size: .66rem; font-weight: 800; padding: 0 6px; border-radius: 99px; background: rgba(15,42,68,.08); color: var(--navy); vertical-align: middle; }

/* agenda (list) */
.sch-agenda { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.sch-ag-day { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.sch-ag-day.is-today { border-color: rgba(var(--primary-rgb), .5); box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .08); }
.sch-ag-head { display: flex; align-items: center; gap: 8px; }
.sch-ag-head b { color: var(--navy); }
.sch-ag-head span { color: var(--muted); font-size: .85rem; }
.sch-ag-add { margin-inline-start: auto; border: 1px dashed var(--border-strong); background: transparent; border-radius: 8px; width: 28px; height: 28px; display: grid; place-items: center; color: var(--primary); cursor: pointer; }
.sch-ag-ev { display: flex; gap: 10px; align-items: flex-start; text-align: start; border: 0; border-inline-start: 4px solid var(--ev-bd); background: var(--ev-bg); color: var(--ev-fg); border-radius: 8px; padding: 7px 9px; font: inherit; cursor: pointer; width: 100%; }
.sch-ag-time { font-weight: 700; font-size: .8rem; white-space: nowrap; font-variant-numeric: tabular-nums; padding-top: 1px; }
.sch-ag-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sch-ag-main small { display: flex; gap: 8px; align-items: center; opacity: .85; flex-wrap: wrap; }
.sch-ag-main .lc { width: 12px; height: 12px; margin-inline-end: 2px; }
.sch-ag-empty { color: var(--muted); font-size: .85rem; padding: 4px 2px; }

.sch-empty-state { border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 28px 16px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; background: var(--soft); }
.sch-empty-state .lc { width: 28px; height: 28px; color: var(--primary); }

/* home screen block */
#courseWeekSchedule { margin: 6px 0 18px; }
#courseWeekSchedule .sch-scroll { max-height: 62vh; }

/* modal */
.sch-modal-ov { position: fixed; inset: 0; background: rgba(15,42,68,.45); z-index: 99990; display: flex; align-items: center; justify-content: center; padding: 16px; animation: schFade .15s ease; }
.sch-modal { background: var(--card); border-radius: 16px; box-shadow: 0 20px 60px rgba(15,42,68,.3); width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; font-family: var(--font); color: var(--text); text-align: start; }
.sch-modal[lang="he"] { font-family: "Heebo", var(--font); }
.sch-modal .lc { width: 16px; height: 16px; }
.sch-modal__head { display: flex; align-items: center; gap: 10px; }
.sch-modal__ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: rgba(var(--primary-rgb), .1); color: var(--primary); flex: 0 0 auto; }
.sch-modal__ic .lc { width: 18px; height: 18px; }
.sch-modal__title { font-weight: 800; font-size: 1.08rem; color: var(--navy); }
.sch-modal__sub { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.sch-x { margin-inline-start: auto; border: 0; background: transparent; font-size: 1.1rem; color: var(--muted); cursor: pointer; width: 32px; height: 32px; border-radius: 8px; flex: 0 0 auto; }
.sch-x:hover { background: var(--soft); }
.sch-f { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.sch-f > label { font-weight: 700; font-size: .88rem; }
.sch-f small { color: var(--muted); font-size: .78rem; }
.sch-f .search, .sch-f .textarea { width: 100%; box-sizing: border-box; }
.sch-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sch-row3 { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; }
.sch-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.sch-seg--col { flex-direction: column; }
.sch-seg label, .sch-checks label, .sch-days label { cursor: pointer; }
.sch-seg input, .sch-days input { position: absolute; opacity: 0; pointer-events: none; }
.sch-seg span { display: inline-block; padding: 7px 14px; border: 1px solid var(--border); border-radius: 10px; font-weight: 600; font-size: .9rem; background: var(--card); }
.sch-seg input:checked + span { border-color: var(--primary); background: rgba(var(--primary-rgb), .08); color: var(--primary); }
.sch-seg input:focus-visible + span, .sch-days input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 1px; }
.sch-days { display: flex; gap: 6px; flex-wrap: wrap; }
.sch-days span { display: grid; place-items: center; min-width: 40px; height: 34px; padding: 0 8px; border: 1px solid var(--border); border-radius: 9px; font-weight: 700; font-size: .85rem; }
.sch-days input:checked + span { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.sch-days label.is-own span { opacity: .35; text-decoration: line-through; cursor: default; }
.sch-checks { display: flex; flex-direction: column; gap: 6px; }
.sch-checks label { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; font-weight: 600; }
.sch-checks label:has(input:checked) { border-color: var(--primary); background: rgba(var(--primary-rgb), .05); }
.sch-checks em { margin-inline-start: auto; font-style: normal; color: var(--muted); font-size: .82rem; font-weight: 500; }
.sch-checks input { width: 17px; height: 17px; accent-color: var(--primary); }
.sch-colors { display: flex; gap: 8px; flex-wrap: wrap; }
.sch-sw input { position: absolute; opacity: 0; }
.sch-sw span { display: block; width: 26px; height: 26px; border-radius: 50%; background: var(--sw); cursor: pointer; box-shadow: 0 0 0 2px var(--card), 0 0 0 3px transparent; transition: box-shadow .12s; }
.sch-sw input:checked + span { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--sw); }
.sch-sw input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 3px; }
.sch-err { color: var(--bad); font-weight: 700; font-size: .85rem; min-height: 1em; }
.sch-err:empty { display: none; }
.sch-modal__actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding-top: 4px; }
.sch-modal__actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.sch-grow { flex: 1; }
.sch-det { display: flex; flex-direction: column; gap: 8px; }
.sch-det > div { display: flex; align-items: center; gap: 8px; }
.sch-det .lc { color: var(--primary); }
.sch-det__notes { margin: 4px 0 0; padding: 10px; background: var(--soft); border-radius: 10px; line-height: 1.5; }
@keyframes schFade { from { opacity: 0; } to { opacity: 1; } }

/* mobile */
@media (max-width: 700px) {
  .sch { --sch-time-w: 48px; --sch-col-min: 104px; }
  .sch-bar--week { flex-direction: column; align-items: stretch; }
  .sch-actions { justify-content: flex-start; }
  .sch-actions .btn { flex: 1 1 auto; justify-content: center; }
  .sch-week { width: 100%; margin: 4px 0 0; }
  .sch-jump { display: none; }
  .sch-row3 { grid-template-columns: 1fr 1fr; }
  .sch-row3 > .sch-f:first-child { grid-column: 1 / -1; }
  .sch-row2 { grid-template-columns: 1fr; }
  .sch-modal { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) { .sch-ev, .sch-modal-ov { transition: none; animation: none; } }

/* Users tab: track tag */
.acc-tag.track { background: #eef4fa; color: #0b4f7c; border: 1px solid #cfe0ef; }

/* Admin dashboard (fit-to-screen mode): toolbar stays, only the grid scrolls */
#adminDashboardView:has(#adminScheduleTab:not(.hidden)) #managerCourseScope { display: none !important; }
#adminDashboardView.dash-fit #adminScheduleTab:not(.hidden) { height: 100%; display: flex; flex-direction: column; }
#adminDashboardView.dash-fit #scheduleEditorRoot { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
#adminDashboardView.dash-fit #scheduleEditorRoot > .sch { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
#adminDashboardView.dash-fit #scheduleEditorRoot .sch-scroll,
#adminDashboardView.dash-fit #scheduleEditorRoot .sch-agenda { flex: 1 1 auto; min-height: 220px; max-height: none; overflow: auto; }
#adminDashboardView.dash-fit #scheduleEditorRoot .sch-agenda { align-content: start; }
.sch-ev.is-short .sch-ev__time { order: 2; }
