/* ==========================================================================
   RAKEEZ X — مكوّنات الشاشات
   ========================================================================== */

/* ---------- ترحيب ---------- */
.welcome { border-color: var(--brand); background: var(--brand-soft); display: block; text-align: center; }
.welcome__title { font-weight: 750; font-size: 17px; color: var(--brand); }
.welcome__text  { font-size: 14px; color: var(--text-2); margin-block: var(--sp-2) 0; line-height: 1.7; }

/* ---------- اختيار اللون ---------- */
.swatch { cursor: pointer; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch span {
  display: block; width: 34px; height: 34px;
  border-radius: var(--r-full);
  border: 3px solid transparent;
  box-shadow: 0 0 0 1px var(--border);
  transition: transform .12s var(--ease), border-color .12s var(--ease);
}
.swatch input:checked + span { border-color: var(--bg-elev); box-shadow: 0 0 0 2.5px var(--text); transform: scale(1.1); }
.swatch input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 3px; }

/* ---------- صف الفصل ---------- */
.class-dot { flex: none; width: 10px; height: 40px; border-radius: var(--r-full); }

/* ---------- شريط البحث ---------- */
.searchbar {
  display: flex; align-items: center; gap: var(--sp-2);
  padding-inline-start: var(--sp-3);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-3);
  color: var(--text-3);
}
.searchbar:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.searchbar svg { width: 18px; height: 18px; flex: none; }
.searchbar__input {
  flex: 1; min-width: 0;
  min-height: var(--tap);
  border: none; background: none; outline: none;
  color: var(--text);
}
.searchbar__input::-webkit-search-cancel-button { display: none; }

/* ---------- شريط التاريخ ---------- */
.datebar {
  display: flex; align-items: center; gap: var(--sp-2);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-1);
  margin-bottom: var(--sp-3);
}
.datebar__mid { flex: 1; text-align: center; }
.datebar__label { font-weight: 700; font-size: 15.5px; }
.datebar__note { font-size: 12px; color: var(--warn); font-weight: 600; }
.iconbtn.is-off { opacity: .3; pointer-events: none; }

/* ---------- صف الحضور ---------- */
.att-row {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.att-row.is-unmarked { border-style: dashed; }
.att-row__name {
  flex: 1; min-width: 0;
  font-weight: 600; font-size: 14.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.segbtns { display: flex; gap: 3px; flex: none; }
.segbtn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  background: var(--bg-sunk);
  color: var(--text-3);
  font-weight: 750; font-size: 14px;
  border: 1.5px solid transparent;
  transition: background .12s var(--ease), color .12s var(--ease), transform .08s var(--ease);
}
.segbtn:active { transform: scale(.9); }
.segbtn.is-on[data-color="present"] { background: var(--present); color: #fff; }
.segbtn.is-on[data-color="late"]    { background: var(--late);    color: #fff; }
.segbtn.is-on[data-color="excused"] { background: var(--excused); color: #fff; }
.segbtn.is-on[data-color="absent"]  { background: var(--absent);  color: #fff; }
:root[data-theme="dark"] .segbtn.is-on { color: #0a0d10; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .segbtn.is-on { color: #0a0d10; }
}

@media (max-width: 400px) {
  .segbtn { width: 34px; height: 34px; font-size: 13px; }
  .att-row { padding-inline: var(--sp-2); }
}

/* ---------- مبدّل مقسّم ---------- */
.segmented {
  display: flex;
  background: var(--bg-sunk);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 3px;
}
.segmented__btn {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px;
  padding-inline: var(--sp-3);
  border-radius: calc(var(--r-md) - 3px);
  font-size: 14px; font-weight: 650;
  color: var(--text-2);
  white-space: nowrap;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.segmented__btn svg { width: 16px; height: 16px; }
.segmented__btn.is-on { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-1); }

/* ---------- مفتاح تبديل ---------- */
.switch { display: inline-flex; align-items: center; gap: var(--sp-2); cursor: pointer; font-size: 14px; font-weight: 600; }
.switch input { width: 20px; height: 20px; accent-color: var(--brand); }

/* ---------- شرائح ---------- */
.chips { display: flex; gap: var(--sp-2); padding-bottom: var(--sp-1); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: var(--sp-2) var(--sp-3);
  min-height: 38px;
  border-radius: var(--r-full);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  font-size: 14px; font-weight: 620;
  color: var(--text-2);
  white-space: nowrap; flex: none;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.chip.is-on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.chip__meta { font-size: 12px; opacity: .75; font-variant-numeric: tabular-nums; }

/* ---------- الرصد السريع ---------- */
.ql-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--sp-2);
}
@media (max-width: 380px) { .ql-grid { grid-template-columns: repeat(2, 1fr); } }

.qlcard {
  position: relative;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  overflow: hidden;
  transition: border-color .15s var(--ease), background .3s var(--ease);
}
.qlcard.is-pos { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.qlcard.is-neg { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }

.qlcard__hit {
  display: grid; gap: 2px;
  width: 100%;
  padding: var(--sp-3);
  padding-inline-end: var(--sp-8);
  min-height: 84px;
  text-align: start;
  align-content: start;
}
.qlcard__hit:active { background: var(--bg-sunk); }
.qlcard__roll { font-size: 11px; color: var(--text-3); font-weight: 700; }
.qlcard__name { font-size: 14px; font-weight: 650; line-height: 1.35; }
.qlcard__score { font-size: 20px; font-weight: 800; margin-top: 2px; }
.qlcard.is-pos .qlcard__score { color: var(--ok); }
.qlcard.is-neg .qlcard__score { color: var(--danger); }
.qlcard__today { font-size: 11px; color: var(--text-3); font-weight: 650; }

.qlcard__minus {
  position: absolute; inset-block-start: 0; inset-inline-end: 0;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  color: var(--text-3);
  border-radius: 0 0 0 var(--r-md);
}
.qlcard__minus:hover { background: var(--danger-soft); color: var(--danger); }
.qlcard__minus svg { width: 16px; height: 16px; }

@keyframes flashPlus  { 0% { background: var(--ok-soft); }     100% { background: var(--bg-elev); } }
@keyframes flashMinus { 0% { background: var(--danger-soft); } 100% { background: var(--bg-elev); } }
.qlcard.is-plus  { animation: flashPlus .55s var(--ease); }
.qlcard.is-minus { animation: flashMinus .55s var(--ease); }

.taglist { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.taglist .btn { min-height: 48px; font-size: 14px; }
@media (max-width: 420px) { .taglist { grid-template-columns: 1fr; } }

/* ---------- صف الدرجة ---------- */
.graderow {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.graderow__name {
  flex: 1; min-width: 0;
  font-weight: 600; font-size: 14.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.graderow__in { display: flex; align-items: center; gap: var(--sp-2); flex: none; }
.graderow__max { color: var(--text-3); font-size: 13px; }
.gradein {
  width: 74px;
  text-align: center;
  min-height: 40px;
  padding: var(--sp-2);
  font-weight: 700; font-size: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
}
.gradein:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.gradein::placeholder { color: var(--text-3); font-weight: 400; }

/* ---------- الجداول ---------- */
.tablewrap {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elev);
}
.gtable { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; }
.gtable th, .gtable td { padding: var(--sp-2) var(--sp-3); text-align: center; white-space: nowrap; }
.gtable thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg-sunk);
  font-size: 12.5px; font-weight: 700; color: var(--text-2);
  border-bottom: 1px solid var(--border);
  vertical-align: bottom;
}
.gtable tbody tr + tr th, .gtable tbody tr + tr td { border-top: 1px solid var(--border); }
.gtable__sticky {
  position: sticky; inset-inline-start: 0; z-index: 1;
  background: var(--bg-elev);
  text-align: start !important;
  font-weight: 650;
  min-width: 150px;
}
.gtable thead .gtable__sticky { background: var(--bg-sunk); z-index: 3; }
.gtable__sticky a { color: inherit; text-decoration: none; }
.gtable__sticky a:hover { color: var(--brand); text-decoration: underline; }
.gtable__roll { color: var(--text-3); font-size: 12px; margin-inline-end: var(--sp-2); font-variant-numeric: tabular-nums; }
.gtable__item { display: block; }
.gtable__max { display: block; font-size: 11px; color: var(--text-3); font-weight: 600; }
.gtable__total { background: var(--bg-sunk); }
.gtable td.is-auto { color: var(--text-3); background: var(--bg-sunk); }
/* 16px حدٌّ أدنى لكل حقل إدخال: سفاري iOS يكبّر الصفحة تلقائيًا عند التركيز
   على أي حقل أصغر منه، فتقفز الشاشة تحت إصبع المعلّم أثناء الرصد. */
.gradein--cell { width: 66px; min-height: 34px; font-size: 16px; border-color: transparent; background: transparent; }
.gradein--cell:hover { border-color: var(--border-strong); }

.att-col { font-size: 11px !important; }
.att-cell { font-weight: 700; }
.att-cell.is-present { color: var(--present); }
.att-cell.is-absent  { color: var(--absent); background: var(--absent-soft); }
.att-cell.is-late    { color: var(--late); }
.att-cell.is-excused { color: var(--excused); }

/* ---------- بطاقة اختيار ---------- */
.radiocard {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  background: var(--bg-elev);
  text-align: start; width: 100%;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.radiocard:hover { border-color: var(--brand); }
.radiocard input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.radiocard:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.radiocard__body { display: grid; gap: 2px; }
.radiocard__title { font-weight: 700; font-size: 14.5px; }
.radiocard__hint { font-size: 12.5px; color: var(--text-3); line-height: 1.5; }

/* ---------- القرعة ---------- */
.picker { max-width: 520px; margin-inline: auto; }
.picker__stage {
  display: grid; place-content: center; justify-items: center; gap: var(--sp-2);
  min-height: 210px;
  padding: var(--sp-6);
  border-radius: var(--r-xl);
  background: var(--brand-soft);
  border: 2px solid color-mix(in srgb, var(--brand) 35%, transparent);
  margin-bottom: var(--sp-4);
  text-align: center;
}
.picker__stage.is-spinning { opacity: .75; }
.picker__roll {
  font-size: 13px; font-weight: 800; color: var(--brand);
  background: var(--bg-elev);
  padding: 3px var(--sp-3); border-radius: var(--r-full);
}
.picker__name {
  font-size: clamp(26px, 7vw, 42px); font-weight: 800;
  color: var(--brand); line-height: 1.25; letter-spacing: -.5px;
}
.picker__stage.is-spinning .picker__name { filter: blur(1.5px); }
.picker__idle { font-size: 17px; color: var(--text-3); font-weight: 600; }

/* ---------- المجموعات ---------- */
.group__head {
  display: flex; align-items: center; gap: var(--sp-2);
  font-weight: 750; font-size: 15px;
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
}
.group__head .badge { margin-inline-start: auto; }
.group__member { display: flex; align-items: center; gap: var(--sp-2); font-size: 14px; }
.group__member .rollno { width: 28px; height: 28px; font-size: 12px; }

/* ---------- لوحة النتائج ---------- */
.board { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.board__row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.board__row.is-top { border-color: var(--brand); background: var(--brand-soft); }
.board__rank { flex: none; width: 32px; text-align: center; font-size: 19px; font-weight: 800; color: var(--text-3); }
.board__row.is-top .board__rank { font-size: 24px; }
.board__name { flex: 0 0 auto; min-width: 110px; max-width: 34%; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board__bar { flex: 1; height: 12px; background: var(--bg-sunk); border-radius: var(--r-full); overflow: hidden; }
.board__fill { display: block; height: 100%; background: var(--brand); border-radius: var(--r-full); transition: width .5s var(--ease); }
.board__pts { flex: none; min-width: 44px; text-align: end; font-weight: 800; font-size: 17px; color: var(--brand); }

@media (min-width: 900px) {
  .board__row { padding: var(--sp-4); }
  .board__name { font-size: 20px; min-width: 190px; }
  .board__pts { font-size: 24px; min-width: 60px; }
  .board__rank { font-size: 24px; width: 44px; }
  .board__bar { height: 16px; }
}

/* ---------- تقرير الطالب ---------- */
.itemrow { padding: var(--sp-3); }
.itemrow + .itemrow { border-top: 1px solid var(--border); }
.itemrow__head { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.itemrow__name { font-weight: 620; font-size: 14.5px; display: flex; align-items: center; gap: var(--sp-2); }
.itemrow__val { margin-inline-start: auto; font-weight: 700; font-size: 14px; }
.meter { height: 8px; background: var(--bg-sunk); border-radius: var(--r-full); overflow: hidden; }
.meter__fill { height: 100%; border-radius: var(--r-full); transition: width .4s var(--ease); }

.logrow { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); }
.logrow + .logrow { border-top: 1px solid var(--border); }
.logrow__delta {
  flex: none; width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  font-weight: 800; font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.logrow__delta.is-pos { background: var(--ok-soft); color: var(--ok); }
.logrow__delta.is-neg { background: var(--danger-soft); color: var(--danger); }
.logrow__main { flex: 1; display: flex; align-items: center; gap: var(--sp-2); font-size: 14px; min-width: 0; }
.logrow__date { margin-inline-start: auto; font-size: 12.5px; color: var(--text-3); flex: none; }

/* ---------- الصفحة الرئيسية ---------- */
.hero { margin-bottom: var(--sp-4); }
.hero__hello { font-size: 21px; font-weight: 750; letter-spacing: -.3px; }
.hero__date { font-size: 13.5px; color: var(--text-3); margin-top: 2px; }

/* منطقة محجوزة لميزة قادمة — بلا بيانات وهمية */
.soon {
  padding: var(--sp-4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--bg-sunk);
}
.soon__title { font-weight: 700; font-size: 14.5px; color: var(--text-2); }
.soon__text  { font-size: 12.5px; color: var(--text-3); margin-top: var(--sp-2); line-height: 1.6; }

/* ---------- رقم الحصة ---------- */
.period {
  flex: none;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 14px; font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.row__icon {
  flex: none; width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  background: var(--bg-sunk); color: var(--text-2);
}
.row__icon svg { width: 18px; height: 18px; }
.row__icon.is-off { color: var(--text-3); }

/* ---------- الجدول الأسبوعي ---------- */
.week {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-3);
}
.week__day {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-3);
}
.week__day.is-today { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.week__head {
  display: flex; align-items: center; gap: var(--sp-2);
  font-weight: 700; font-size: 14.5px;
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-3);
}
.week__head .badge { margin-inline-start: auto; }
.week__empty { text-align: center; color: var(--text-3); font-size: 13px; padding: var(--sp-3) 0; }

.slot {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2);
  background: var(--bg-sunk);
  border-radius: var(--r-sm);
}
.slot__main { flex: 1; min-width: 0; }
.slot__time { display: block; font-size: 12px; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.slot__name { display: block; font-weight: 650; font-size: 13.5px; }
.slot__sub  { display: block; font-size: 11.5px; color: var(--text-3); }

/* ---------- أوقات الحصص ---------- */
.timerow { display: flex; align-items: center; gap: var(--sp-2); }
.timerow__in { width: auto; flex: 1; min-width: 0; min-height: 38px; text-align: center; }

.timepreview {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: var(--sp-3);
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: var(--r-md);
  font-weight: 700; font-size: 15px;
}
.timepreview svg { width: 18px; height: 18px; }

.row.is-open { border-color: var(--brand); }
.row__icon.is-active { background: var(--brand-soft); color: var(--brand); }

/* ---------- المنهج ---------- */
.lesson { display: flex; align-items: center; gap: var(--sp-2); font-size: 14px; }
.lesson__dot {
  flex: none; width: 7px; height: 7px; border-radius: var(--r-full);
  background: var(--brand);
}
.lesson__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- لافتة فصل مغلق ---------- */
.banner-closed {
  border-color: var(--warn) !important;
  background: var(--warn-soft) !important;
  color: var(--warn);
  font-weight: 650; font-size: 14px;
  display: flex; align-items: center; gap: var(--sp-2);
}
.banner-closed svg { width: 18px; height: 18px; flex: none; }
.is-archived { opacity: .72; }

.radiocard--btn.is-on { border-color: var(--brand); background: var(--brand-soft); }

/* صف القائمة: العنوان والسطر الفرعي عنصران كتليان ليتكدّسا ويعمل القص */
.row__title, .row__sub, .tile__title, .tile__sub { display: block; }

/* ---------- ترويسة الطباعة ---------- */
.printhead { display: none; }
.printhead__title { font-size: 20px; font-weight: 800; }
.printhead__sub { font-size: 13px; color: var(--text-2); margin-top: 2px; }

/* ---------- الطباعة ---------- */
@media print {
  :root {
    --bg: #fff; --bg-elev: #fff; --bg-sunk: #f4f4f4;
    --border: #ccc; --border-strong: #999;
    --text: #000; --text-2: #333; --text-3: #666;
  }
  body { background: #fff; font-size: 11pt; }

  .topbar, .tabbar, .sidebar, .fab, .toast, .noprint,
  .segmented, .searchbar, .datebar, #modal-root { display: none !important; }

  .layout { display: block; }
  .main { padding: 0; }
  .page { max-width: none; padding: 0; }

  .printhead {
    display: block;
    border-bottom: 2px solid #000;
    padding-bottom: 8px;
    margin-bottom: 12px;
  }

  .card, .row, .tablewrap, .stat { box-shadow: none; border-color: #bbb; break-inside: avoid; }
  .section { margin-block: 10px; }
  .gtable { font-size: 9.5pt; }
  .gtable th, .gtable td { padding: 3px 5px; }
  .gtable thead th { background: #eee !important; position: static; }
  .gtable__sticky { position: static; }
  .grid--auto { grid-template-columns: repeat(3, 1fr); }
  .group { break-inside: avoid; }
  a { color: #000; text-decoration: none; }

  @page { margin: 14mm; }
}
