/* منصة معهد الأمل العالي — واجهة عربية من اليمين لليسار، للجوال أولًا. بلا أدوات بناء. */
@font-face { font-family: "Plex Arabic"; src: url("../fonts/plex-arabic-400.woff2") format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41; }
@font-face { font-family: "Plex Arabic"; src: url("../fonts/plex-arabic-500.woff2") format("woff2"); font-weight: 500; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E; }
@font-face { font-family: "Plex Arabic"; src: url("../fonts/plex-arabic-600.woff2") format("woff2"); font-weight: 600; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E; }
@font-face { font-family: "Plex Arabic"; src: url("../fonts/plex-arabic-700.woff2") format("woff2"); font-weight: 700; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E; }
@font-face { font-family: "Plex Arabic"; src: url("../fonts/plex-latin-400.woff2") format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: "Plex Arabic"; src: url("../fonts/plex-latin-600.woff2") format("woff2"); font-weight: 600; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: "Plex Arabic"; src: url("../fonts/plex-latin-700.woff2") format("woff2"); font-weight: 700; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }

:root {
  --ink: #1b2a25; --ink-2: #4a5b55; --ink-3: #7b8a84;
  --paper: #f6f3ec; --card: #ffffff; --line: #e4ded1; --line-2: #efeadf;
  --brand: #1e5b47; --brand-2: #2c7a5f; --brand-soft: #e6f0ea;
  --gold: #a87b2f; --gold-soft: #f5ecda;
  --green: #2f7d4f; --green-soft: #e3f1e7;
  --yellow: #a86b00; --yellow-soft: #fbf0d6;
  --red: #a63a32; --red-soft: #f8e3e0;
  --blue: #2b5f8f; --blue-soft: #e2ecf6;
  --radius: 12px; --shadow: 0 1px 2px rgba(27,42,37,.06), 0 4px 14px rgba(27,42,37,.05);
  --font: "Plex Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.65; color: var(--ink); background: var(--paper); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.35; font-weight: 700; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }
td.num, th.num { display: table-cell; direction: rtl; }
code, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; direction: ltr; unicode-bidi: isolate; font-size: .9em; }
[hidden] { display: none !important; }

/* ---------- الهيكل ---------- */
.app { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; background: var(--brand); color: #fff; }
.topbar a { color: #fff; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1rem; white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: rgba(255,255,255,.14); display: grid; place-items: center; }
.topbar .spacer { flex: 1; }
.icon-btn { background: transparent; border: 0; color: inherit; padding: .4rem; border-radius: 8px; cursor: pointer; position: relative; display: inline-grid; place-items: center; }
.icon-btn:hover { background: rgba(255,255,255,.12); }
.badge-dot { position: absolute; top: 2px; inset-inline-end: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--gold); color: #fff; font-size: 11px; line-height: 17px; text-align: center; }
.who { font-size: .85rem; line-height: 1.25; text-align: start; display: none; }
.who small { color: rgba(255,255,255,.75); display: block; }

.sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 270px; transform: translateX(100%); transition: transform .2s ease; background: var(--card); border-inline-end: 1px solid var(--line); z-index: 40; overflow-y: auto; padding: 1rem .75rem 2rem; }
.sidebar.open { transform: none; box-shadow: var(--shadow); }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 35; }
.nav-group { margin-bottom: 1rem; }
.nav-title { font-size: .75rem; color: var(--ink-3); padding: 0 .6rem .3rem; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; border-radius: 9px; color: var(--ink); font-weight: 500; }
.nav a:hover { background: var(--line-2); text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .8; }

.main { padding: 1rem; max-width: 1280px; width: 100%; margin: 0 auto; min-width: 0; }
.app > * { min-width: 0; }
body { overflow-x: hidden; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; margin-bottom: 1rem; }
.page-head .grow { flex: 1; min-width: 200px; }
.page-head p { margin: 0; color: var(--ink-2); }
.crumbs { font-size: .82rem; color: var(--ink-3); margin-bottom: .2rem; }
.crumbs a { color: var(--ink-3); }

@media (min-width: 1000px) {
  .app { grid-template-columns: 260px 1fr; grid-template-rows: auto 1fr; }
  .topbar { grid-column: 1 / -1; }
  .sidebar { position: sticky; top: 50px; height: calc(100vh - 50px); transform: none; width: auto; z-index: 1; }
  .menu-toggle, .scrim { display: none !important; }
  .main { padding: 1.5rem 2rem; }
  .who { display: block; }
}

/* ---------- البطاقات والشبكات ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem; }
.card > h2:first-child, .card > h3:first-child, .card-head { margin-bottom: .75rem; }
.card-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; flex: 1; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 1rem 1rem 0; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: 1fr; } .grid.three { grid-template-columns: 1fr; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: 1rem; }
@media (min-width: 700px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.three { grid-template-columns: repeat(3, 1fr); } .stats { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1100px) { .grid.main-side { grid-template-columns: 2fr 1fr; } }

.stat { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; color: var(--ink); box-shadow: var(--shadow); }
a.stat:hover { border-color: var(--brand-2); text-decoration: none; }
.stat .label { font-size: .82rem; color: var(--ink-2); }
.stat .value { font-size: 1.7rem; font-weight: 700; line-height: 1.2; margin-top: .15rem; }
.stat .hint { font-size: .78rem; color: var(--ink-3); }
.stat.green .value { color: var(--green); } .stat.yellow .value { color: var(--yellow); } .stat.red .value { color: var(--red); }

/* شريط الفصل */
.term-strip { display: flex; gap: 3px; overflow-x: auto; padding-bottom: .4rem; }
.term-strip .wk { flex: 1 0 28px; min-width: 28px; height: 38px; border-radius: 6px; display: grid; place-items: center; font-size: .75rem; font-weight: 600; color: #fff; position: relative; }
.term-strip .wk.past { opacity: .55; }
.term-strip .wk.now { outline: 3px solid var(--gold); outline-offset: 1px; opacity: 1; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .8rem; color: var(--ink-2); margin-top: .4rem; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: .3rem; vertical-align: middle; }

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .6rem .75rem; text-align: start; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
th { font-size: .8rem; font-weight: 600; color: var(--ink-2); background: #faf8f3; white-space: nowrap; }
tbody tr:hover { background: #fcfbf8; }
td.n, th.n { text-align: center; white-space: nowrap; }
tr.total td { font-weight: 700; background: #faf8f3; }

/* ---------- العناصر ---------- */
.pill { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.pill.green { background: var(--green-soft); color: var(--green); } .pill.yellow { background: var(--yellow-soft); color: var(--yellow); }
.pill.red { background: var(--red-soft); color: var(--red); } .pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.gold { background: var(--gold-soft); color: var(--gold); } .pill.brand { background: var(--brand-soft); color: var(--brand); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot.green { background: var(--green); } .dot.yellow { background: #d99a00; } .dot.red { background: var(--red); } .dot.none { background: var(--line); }
.bar { height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--brand-2); border-radius: 99px; }
.bar.green > span { background: var(--green); } .bar.yellow > span { background: #d99a00; } .bar.red > span { background: var(--red); }
.progress-cell { display: flex; align-items: center; gap: .5rem; min-width: 110px; }
@media (min-width: 700px) { .progress-cell { min-width: 150px; } }
.progress-cell .bar { flex: 1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem 1rem; border-radius: 10px; border: 1px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; min-height: 42px; white-space: nowrap; }
.btn:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.secondary { background: var(--card); color: var(--brand); border-color: var(--line); }
.btn.secondary:hover { background: var(--brand-soft); }
.btn.danger { background: var(--red); border-color: var(--red); }
.btn.gold { background: var(--gold); border-color: var(--gold); }
.btn.small { padding: .3rem .7rem; min-height: 34px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

.alert { padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid; }
.alert.success { background: var(--green-soft); border-color: #bfdcc8; color: #1f5b37; }
.alert.error { background: var(--red-soft); border-color: #ecc1bb; color: #7d2a23; }
.alert.warn { background: var(--yellow-soft); border-color: #eed7a1; color: #6e4a00; }
.alert.info { background: var(--blue-soft); border-color: #c5d8ea; color: #1f4568; }
.alert ul { margin: .3rem 0 0; padding-inline-start: 1.2rem; }

/* ---------- النماذج ---------- */
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .3rem; }
.field { margin-bottom: .9rem; }
.field .help { font-size: .8rem; color: var(--ink-3); margin-top: .2rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=url], input[type=search], input[type=file], select, textarea {
  width: 100%; font: inherit; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); min-height: 42px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: -1px; border-color: var(--brand-2); }
textarea { min-height: 80px; }
.form-row { display: grid; gap: .75rem; grid-template-columns: 1fr; }
@media (min-width: 700px) { .form-row.two { grid-template-columns: 1fr 1fr; } .form-row.three { grid-template-columns: 1fr 1fr 1fr; } .form-row.four { grid-template-columns: repeat(4, 1fr); } }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.check input { width: 18px; height: 18px; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { margin: 0; min-width: 150px; flex: 1; }
.filters .btn { min-height: 42px; }

/* ---------- قوائم ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: .6rem; padding: .6rem 0; border-bottom: 1px solid var(--line-2); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; }
.list .sub { font-size: .82rem; color: var(--ink-3); }
.empty { text-align: center; color: var(--ink-3); padding: 1.5rem .5rem; }

/* حصص اليوم */
.session { display: flex; gap: .75rem; align-items: center; padding: .75rem; border: 1px solid var(--line); border-radius: 10px; margin-bottom: .6rem; background: #fff; }
.session .time { font-weight: 700; color: var(--brand); min-width: 92px; direction: ltr; text-align: center; font-variant-numeric: tabular-nums; }
.session .grow { flex: 1; min-width: 0; }
.session .actions { flex-wrap: nowrap; }
@media (max-width: 560px) { .session { flex-wrap: wrap; } .session .actions { width: 100%; } .session .actions .btn { flex: 1; } }

/* ---------- الحضور (للجوال) ---------- */
.att-list { list-style: none; margin: 0; padding: 0; }
.att-row { display: flex; align-items: center; gap: .5rem; padding: .55rem .25rem; border-bottom: 1px solid var(--line-2); }
.att-row .name { flex: 1; min-width: 0; font-weight: 600; }
.att-row .name small { display: block; font-weight: 400; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex: none; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { margin: 0; padding: .45rem .6rem; font-size: .82rem; font-weight: 600; cursor: pointer; color: var(--ink-2); border-inline-start: 1px solid var(--line); min-width: 44px; text-align: center; }
.seg label:first-of-type { border-inline-start: 0; }
.seg input:checked + label.present { background: var(--green); color: #fff; }
.seg input:checked + label.absent { background: var(--red); color: #fff; }
.seg input:checked + label.late { background: #d99a00; color: #fff; }
.seg input:checked + label.excused { background: var(--blue); color: #fff; }
.excuse-box { display: none; padding: .25rem 0 .6rem; gap: .5rem; }
.excuse-box.show { display: flex; flex-wrap: wrap; }
.excuse-box select, .excuse-box input { flex: 1; min-width: 140px; }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(to top, var(--paper) 70%, transparent); padding: .75rem 0 .5rem; display: flex; gap: .5rem; align-items: center; }
.sticky-actions .btn { flex: 1; }
.counter { font-size: .85rem; color: var(--ink-2); }

/* ---------- الدروس ---------- */
.lesson { display: flex; align-items: center; gap: .75rem; padding: .65rem .25rem; border-bottom: 1px solid var(--line-2); }
.lesson .tick { width: 30px; height: 30px; border-radius: 8px; border: 2px solid var(--line); display: grid; place-items: center; background: #fff; cursor: pointer; flex: none; color: #fff; }
.lesson.done .tick { background: var(--green); border-color: var(--green); }
.lesson.late:not(.done) .tick { border-color: var(--red); }
.lesson .grow { flex: 1; min-width: 0; }
.lesson.done .title { color: var(--ink-2); }
.week-sep { font-size: .8rem; font-weight: 700; color: var(--ink-3); padding: .8rem .25rem .2rem; border-bottom: 1px dashed var(--line); }
.week-sep.current { color: var(--gold); }

/* ---------- الدرجات ---------- */
.grade-table input { width: 72px; min-height: 36px; padding: .3rem .4rem; text-align: center; direction: ltr; }
.grade-table input.invalid { border-color: var(--red); background: var(--red-soft); }
.grade-table td.total { font-weight: 700; }
.save-state { font-size: .82rem; color: var(--ink-3); }
.save-state.saving { color: var(--yellow); } .save-state.saved { color: var(--green); } .save-state.error { color: var(--red); }
.workflow { display: flex; gap: .3rem; flex-wrap: wrap; margin: .25rem 0 1rem; }
.workflow .step { flex: 1; min-width: 100px; padding: .45rem .6rem; border-radius: 8px; background: var(--line-2); color: var(--ink-3); font-size: .8rem; font-weight: 600; text-align: center; }
.workflow .step.done { background: var(--brand-soft); color: var(--brand); }
.workflow .step.current { background: var(--brand); color: #fff; }

/* ---------- ملف الطالبة ---------- */
.profile-head { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.avatar { width: 64px; height: 64px; border-radius: 16px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: 1.6rem; font-weight: 700; flex: none; }
.signal { display: inline-flex; align-items: center; gap: .5rem; padding: .35rem .8rem; border-radius: 999px; font-weight: 700; }
.signal.green { background: var(--green-soft); color: var(--green); } .signal.yellow { background: var(--yellow-soft); color: var(--yellow); } .signal.red { background: var(--red-soft); color: var(--red); }
.dims { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.dim { border: 1px solid var(--line); border-radius: 10px; padding: .6rem; text-align: center; background: #fff; }
.dim .k { font-size: .78rem; color: var(--ink-3); } .dim .v { font-weight: 700; font-size: 1.05rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; font-size: .92rem; }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; font-weight: 500; }
.soon { border: 1px dashed var(--line); background: transparent; box-shadow: none; color: var(--ink-3); }
.soon h3 { color: var(--ink-2); }
.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs a { padding: .55rem .9rem; color: var(--ink-2); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--brand); border-color: var(--brand); text-decoration: none; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 36px; }
.spark span { flex: 1; background: var(--brand-2); border-radius: 2px 2px 0 0; min-width: 6px; opacity: .8; }

/* ---------- الجدول الأسبوعي ---------- */
.timetable { display: grid; gap: .5rem; grid-template-columns: 1fr; }
@media (min-width: 900px) { .timetable { grid-template-columns: repeat(6, 1fr); } }
.tt-day h3 { font-size: .9rem; padding: .4rem .6rem; background: var(--brand-soft); color: var(--brand); border-radius: 8px; margin-bottom: .4rem; }
.tt-slot { border: 1px solid var(--line); border-inline-start: 4px solid var(--brand-2); border-radius: 8px; padding: .45rem .6rem; margin-bottom: .4rem; background: #fff; font-size: .85rem; }
.tt-slot .t { font-weight: 700; direction: ltr; text-align: end; font-size: .78rem; color: var(--ink-3); }

/* ---------- تسجيل الدخول ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background:
  radial-gradient(circle at 15% 10%, rgba(30,91,71,.10), transparent 40%), radial-gradient(circle at 90% 90%, rgba(168,123,47,.12), transparent 40%), var(--paper); }
.auth-card { width: 100%; max-width: 440px; }
.auth-card .logo { width: 56px; height: 56px; border-radius: 14px; background: var(--brand); color: #fff; display: grid; place-items: center; margin: 0 auto .75rem; }
.auth-card h1 { text-align: center; }
.divider { display: flex; align-items: center; gap: .75rem; color: var(--ink-3); font-size: .82rem; margin: 1rem 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.demo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.demo-grid button { text-align: start; background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: .45rem .6rem; font: inherit; font-size: .84rem; cursor: pointer; line-height: 1.35; }
.demo-grid button:hover { border-color: var(--brand-2); background: var(--brand-soft); }
.demo-grid button small { display: block; color: var(--ink-3); font-size: .74rem; }
.demo-banner { background: var(--gold-soft); color: #6b4c14; font-size: .8rem; text-align: center; padding: .3rem 1rem; }

/* قوائم منسدلة صغيرة */
.dropdown { position: relative; }
.dropdown-panel { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); width: min(360px, 92vw); background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.12); z-index: 50; max-height: 70vh; overflow-y: auto; }
.dropdown-panel a { color: var(--ink); }
.dropdown-panel .item { display: block; padding: .7rem 1rem; border-bottom: 1px solid var(--line-2); font-size: .88rem; }
.dropdown-panel .item.unread { background: #fbf8f0; }
.dropdown-panel .item small { display: block; }

.pagination { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: 1rem; }
.pagination a, .pagination span { padding: .35rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: .85rem; }
.pagination .active span { background: var(--brand); color: #fff; border-color: var(--brand); }

@media print { .topbar, .sidebar, .actions, .btn, .filters { display: none !important; } .app { display: block; } .card { box-shadow: none; } }
.grade-table td:first-child, .grade-table th:first-child { white-space: nowrap; }
.grid > * { min-width: 0; }
