/* ZEC Al Mizhar 4 — parent & student portal. Mobile first, RTL/LTR via logical properties. */
:root {
  --bg: #f4f8fb;
  --surface: #ffffff;
  --ink: #102a3d;
  --ink-2: #3d5568;
  --muted: #556274;
  --line: #d6e1e9;
  --teal: #006b68;
  --teal-2: #007a76;
  --teal-soft: #e3f2f1;
  --navy: #073a57;
  --gold: #d4a438;
  --gold-soft: #fbf3df;
  --red: #b42318;
  --red-soft: #fdecea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 42, 61, .06), 0 4px 16px rgba(16, 42, 61, .05);
  --font: 'IBM Plex Sans Arabic', Tahoma, 'Segoe UI', Arial, sans-serif;
  --bottom-nav: 64px;
}
* { box-sizing: border-box; }
/* The hidden attribute must win over component display rules (e.g. .notice { display: flex }). */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font);
  font-size: 17px; line-height: 1.65; padding-bottom: calc(var(--bottom-nav) + env(safe-area-inset-bottom));
}
img { max-width: 100%; height: auto; }
a { color: var(--teal); }
button { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.35; margin: 0; }
.h2, h2 { font-size: 1.15rem; font-weight: 700; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; inset-inline-start: 8px; top: 8px; background: var(--navy); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 50; transform: translateY(-150%); }
.skip:focus { transform: none; }
.muted { color: var(--muted); }
.ic { width: 20px; height: 20px; flex: none; }
.boot-splash, .maint { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; padding: 24px; }
.maint h1 { font-size: 1.5rem; color: var(--navy); }
.maint p { max-width: 480px; margin: 0; }

/* header */
.admin-banner { background: var(--gold); color: #3b2a00; font-weight: 600; padding: 8px 16px; display: flex; gap: 8px; align-items: center; justify-content: center; font-size: .95rem; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); border-top: 3px solid var(--gold); }
.topbar-in { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 8px 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; flex: 1; }
.brand img { border-radius: 50%; border: 1px solid var(--line); background: #fff; object-fit: contain; }
.brand span { display: flex; flex-direction: column; min-width: 0; }
.brand strong { font-size: .98rem; line-height: 1.3; }
.brand small { font-size: .72rem; color: var(--muted); line-height: 1.3; }
@media (max-width: 400px) { .brand small { display: none; } .brand strong { font-size: .92rem; } }
.topnav { display: none; }
.lang-btn { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; font-size: .9rem; cursor: pointer; min-height: 40px; }
.menu-btn { border: 0; background: none; padding: 8px; cursor: pointer; min-width: 44px; min-height: 44px; display: grid; place-items: center; }
.drawer { position: fixed; inset: 0; background: rgba(7, 26, 40, .45); z-index: 40; }
.drawer-panel { position: absolute; inset-block: 0; inset-inline-end: 0; width: min(320px, 86vw); background: #fff; padding: 16px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.drawer-panel a { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 10px; text-decoration: none; color: var(--ink); font-weight: 500; }
.drawer-panel a[aria-current="page"] { background: var(--teal-soft); color: var(--teal); }
.drawer-panel hr { border: 0; border-top: 1px solid var(--line); width: 100%; }
.drawer-close { align-self: flex-end; border: 0; background: none; min-width: 44px; min-height: 44px; cursor: pointer; }

main { max-width: 1180px; margin: 0 auto; padding: 14px 16px 28px; display: flex; flex-direction: column; gap: 14px; }
main:focus { outline: none; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card.empty { text-align: center; color: var(--ink-2); padding: 28px 16px; }
.card.error { border-color: #f3c2bd; }
.loading { text-align: center; color: var(--muted); padding: 32px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.more { font-size: .92rem; font-weight: 600; text-decoration: none; }
.big { font-size: 1.08rem; font-weight: 600; margin: 4px 0; }
.note { font-size: .85rem; color: var(--muted); margin: 10px 0 0; }

/* picker */
.card-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: .92rem; }
.ic-badge { width: 44px; height: 44px; padding: 10px; border-radius: 12px; background: var(--navy); color: #fff; flex: none; }
.seg { display: inline-flex; background: #edf3f7; border-radius: 12px; padding: 4px; gap: 4px; width: 100%; }
.seg button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 10px 12px; font-weight: 600; cursor: pointer; min-height: 44px; color: var(--ink-2); }
.seg button[aria-checked="true"], .seg button[aria-selected="true"] { background: #fff; color: var(--teal); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.seg.small { width: auto; }
.seg.small button { padding: 6px 12px; min-height: 38px; font-size: .9rem; }
.field { margin-top: 14px; }
.lbl { display: block; font-size: .9rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { border: 1px solid var(--line); background: #fff; border-radius: 10px; min-width: 48px; min-height: 44px; padding: 6px 12px; font-weight: 600; cursor: pointer; }
.chips button[aria-checked="true"], .chips button[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); color: #fff; }
.row-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: 8px; justify-content: center; border-radius: 10px; padding: 10px 16px; min-height: 44px; font-weight: 600; text-decoration: none; cursor: pointer; border: 1px solid transparent; font-size: .95rem; }
.btn.primary { background: var(--teal); color: #fff; }
.btn.primary:hover { background: #005a57; }
.btn.ghost { background: #fff; color: var(--teal); border-color: var(--line); }
.link-btn { background: none; border: 0; color: var(--teal); font-weight: 600; cursor: pointer; padding: 6px 4px; min-height: 36px; }
.link-btn.danger { color: var(--red); }
.picker.compact { padding: 10px 12px; }
.kids { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.kid { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 6px 14px; min-width: 76px; cursor: pointer; }
.kid b { font-size: 1.05rem; }
.kid[aria-pressed="true"] { border-color: var(--teal); background: var(--teal-soft); box-shadow: inset 0 0 0 1px var(--teal); }
.kid-sec { font-size: .72rem; font-weight: 700; padding: 0 8px; border-radius: 999px; }
.kid-sec.boys { background: #e0eef8; color: var(--navy); }
.kid-sec.girls { background: #f8e6ef; color: #8a2556; }
.kid.add { color: var(--teal); justify-content: center; border-style: dashed; font-size: .8rem; }
.kid-tools { display: flex; gap: 12px; margin-top: 4px; }

/* hero + tiles */
.hero { background: linear-gradient(135deg, var(--navy) 0%, #0b4d6e 55%, var(--teal) 100%); color: #fff; border-radius: 18px; padding: 22px 18px; position: relative; overflow: hidden; }
.hero::after { content: ''; position: absolute; inset-inline-end: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%; border: 28px solid rgba(255,255,255,.07); }
.hero h1 { font-size: 1.45rem; margin: 2px 0 6px; }
.hero p { margin: 0; opacity: .92; }
.eyebrow { color: var(--gold) !important; font-weight: 700; font-size: .85rem; opacity: 1 !important; }
.hero-date { display: inline-block; margin-top: 12px !important; background: rgba(255,255,255,.14); padding: 4px 12px; border-radius: 999px; font-size: .9rem; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); min-height: 104px; }
.tile:hover { border-color: var(--teal); }
.ic-tile { width: 34px; height: 34px; padding: 6px; border-radius: 10px; background: var(--teal-soft); color: var(--teal); margin-bottom: 6px; }
.tile b { font-size: 1rem; }
.tile small { color: var(--muted); font-size: .82rem; line-height: 1.4; }

/* timetable */
.lessons { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.lessons li { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fbfdfe; }
.lessons li.free { opacity: .6; }
.lessons b { display: block; font-size: 1.02rem; }
.lessons small { color: var(--muted); font-size: .9rem; }
.pnum { width: 34px; height: 34px; border-radius: 10px; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.daytabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin: 6px 0 12px; }
.daytabs button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 2px; min-height: 48px; cursor: pointer; font-weight: 600; white-space: nowrap; font-size: .88rem; position: relative; }
.daytabs button[aria-selected="true"] { background: var(--teal); color: #fff; border-color: var(--teal); }
.daytabs i { font-style: normal; font-size: .7rem; display: block; line-height: 1; color: var(--gold); }
.daytabs button[aria-selected="true"] i { color: #ffe7a8; }
.notice { background: var(--gold-soft); border: 1px solid #efd9a2; border-radius: 10px; padding: 8px 12px; margin: 8px 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .95rem; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table.week { border-collapse: collapse; width: 100%; min-width: 640px; font-size: .9rem; }
table.week th, table.week td { border-bottom: 1px solid var(--line); border-inline-start: 1px solid var(--line); padding: 8px; text-align: center; vertical-align: top; }
table.week thead th { background: var(--navy); color: #fff; position: sticky; top: 0; }
table.week tbody th { background: #edf3f7; width: 44px; }
table.week td b { display: block; }
table.week td small { color: var(--muted); font-size: .78rem; }
table.week .is-today { background: var(--teal-soft); }
table.week thead .is-today { background: var(--teal); }

/* weekly plan */
.tabs3 { margin-bottom: 12px; }
.plan-grid { display: grid; gap: 12px; margin-top: 8px; }
.subject-card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.subject-card header { background: linear-gradient(90deg, var(--gold-soft), #fff); border-bottom: 1px solid #efe1bb; padding: 10px 14px; display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.subject-card h3 { font-size: 1.05rem; }
.subject-card h3 small { display: block; font-size: .8rem; color: var(--muted); font-weight: 500; }
.teacher { font-size: .88rem; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }
.subject-card > p { padding: 10px 14px; margin: 0; }
.pf { padding: 10px 14px; border-top: 1px dashed var(--line); }
.pf:first-of-type { border-top: 0; }
.pf span { font-size: .8rem; font-weight: 700; color: var(--teal); }
.pf.task span { color: #9a6a00; }
.pf.rem span { color: var(--navy); }
.pf p { margin: 2px 0 0; white-space: pre-line; }
.archive { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.arch-btn { width: 100%; text-align: start; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 12px; min-height: 48px; cursor: pointer; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.arch-btn[aria-expanded="true"] { border-color: var(--teal); background: var(--teal-soft); }
.arch-body { padding: 8px 2px; }

/* pdf */
.file-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.pdf-box { display: flex; flex-direction: column; gap: 10px; }
.pdf-figure { margin: 0; }
.pdf-page { direction: ltr; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; display: block; }
.pdf-figure figcaption { text-align: center; font-size: .8rem; color: var(--muted); }
.pdf-status { padding: 24px; text-align: center; color: var(--muted); background: #f7fafc; border-radius: 10px; }
.pdf-status.error { color: var(--red); background: var(--red-soft); }

/* posts */
.post-list { display: flex; flex-direction: column; gap: 12px; }
.post { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fff; }
.post.important { border-inline-start: 4px solid var(--red); }
.post header { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .82rem; color: var(--muted); margin-bottom: 4px; }
.post h3 { font-size: 1.08rem; margin-bottom: 6px; }
.post-list.compact .post { padding: 10px 12px; }
.post-list.compact .post-body { -webkit-line-clamp: 2; }
.post-body { white-space: pre-line; color: var(--ink-2); }
.post-body.clamp, .post-list.compact .post-body { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.tag { font-size: .75rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: #edf3f7; color: var(--ink-2); }
.tag.cat-important { background: var(--red-soft); color: var(--red); }
.tag.cat-academic { background: var(--teal-soft); color: var(--teal); }
.tag.cat-event { background: var(--gold-soft); color: #7a5600; }
.tag.pin { background: var(--navy); color: #fff; }
.gallery { display: grid; gap: 6px; margin: 8px 0; }
.gallery.multi { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.gallery img { width: 100%; border-radius: 10px; object-fit: cover; max-height: 420px; background: #edf3f7; }
.gallery.multi img { aspect-ratio: 4 / 3; }
.video { position: relative; aspect-ratio: 16 / 9; margin: 8px 0; border-radius: 10px; overflow: hidden; background: #000; }
.video iframe, .video video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video.file video { object-fit: contain; background: #000; }
.chips.filter { margin-bottom: 12px; }
.act-strip { display: grid; grid-auto-flow: column; grid-auto-columns: 70%; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.act-thumb { text-decoration: none; color: var(--ink); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; background: #fff; }
.act-thumb img, .act-thumb .ph { aspect-ratio: 16 / 10; width: 100%; object-fit: cover; }
.act-thumb .ph { display: grid; place-items: center; background: var(--teal-soft); color: var(--teal); }
.act-thumb b { padding: 8px 10px 0; font-size: .95rem; }
.act-thumb small { padding: 0 10px 8px; color: var(--muted); }

/* resources */
.res-list { display: grid; gap: 10px; }
.res { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-decoration: none; color: var(--ink); background: #fff; min-height: 64px; }
.res:hover { border-color: var(--teal); }
.res-ic { width: 42px; height: 42px; border-radius: 10px; background: var(--teal-soft); color: var(--teal); display: grid; place-items: center; flex: none; }
.res span:nth-child(2) { flex: 1; display: flex; flex-direction: column; }
.res small { color: var(--muted); }
.res-go { color: var(--muted); }
[dir="rtl"] .res-go { transform: scaleX(-1); }

/* bottom nav (mobile) */
.bottomnav { position: fixed; inset-inline: 0; bottom: 0; z-index: 25; background: #fff; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); padding-bottom: env(safe-area-inset-bottom); height: calc(var(--bottom-nav) + env(safe-area-inset-bottom)); }
.bottomnav a, .bottomnav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: .7rem; font-weight: 600; border: 0; background: none; cursor: pointer; padding: 4px 2px; text-align: center; line-height: 1.2; }
.bottomnav .ic { width: 24px; height: 24px; }
.bottomnav [aria-current="page"] { color: var(--teal); }
.bottomnav [aria-current="page"] .ic { background: var(--teal-soft); border-radius: 999px; width: 48px; padding: 0 12px; }

.foot { max-width: 1180px; margin: 0 auto; padding: 16px; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .9rem; border-top: 1px solid var(--line); }
.foot strong { color: var(--ink); }
.foot img { border-radius: 50%; }
.foot-admin { margin-inline-start: auto; font-size: .85rem; color: var(--muted); }

@media (min-width: 640px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .plan-grid { grid-template-columns: 1fr 1fr; }
  .act-strip { grid-auto-columns: calc(33.33% - 7px); }
  .seg { width: auto; }
  .hero { padding: 28px; }
  .hero h1 { font-size: 1.8rem; }
}
@media (min-width: 960px) {
  body { padding-bottom: 0; }
  .bottomnav, .menu-btn { display: none; }
  .topnav { display: flex; gap: 2px; flex-wrap: wrap; }
  .topnav a { text-decoration: none; color: var(--ink-2); padding: 8px 10px; border-radius: 8px; font-weight: 600; font-size: .92rem; white-space: nowrap; }
  .topnav a[aria-current="page"] { background: var(--teal-soft); color: var(--teal); }
  .brand { flex: 0 1 auto; }
  .topbar-in { justify-content: space-between; }
  main { display: grid; grid-template-columns: 340px 1fr; align-items: start; gap: 18px; }
  .picker-wrap { position: sticky; top: 84px; }
  .main-col, #view { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
  .res-list { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
@media print {
  .topbar, .bottomnav, .picker-wrap, .foot, .drawer { display: none !important; }
  body { padding: 0; background: #fff; }
  .card { box-shadow: none; }
}

/* Long words and pasted links in user content must wrap instead of widening the page on small phones. */
.post h3, .post-body, .pf p, .subject-card h3, .teacher, .res b, .res small, .lessons b, .lessons small, .act-thumb b, .notice, .card p { overflow-wrap: anywhere; }

/* sharing, deep links, subject shortcuts, offline note */
.btn.wa { background: #1f9d55; color: #fff; }
.btn.wa:hover { background: #17834a; }
.btn.sm { min-height: 38px; padding: 6px 12px; font-size: .88rem; }
.share-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.post.highlight { box-shadow: 0 0 0 3px var(--gold); }
.subj-chips { margin: 6px 0 10px; }
.subj-chips button { min-height: 36px; font-size: .85rem; }
.subject-card { scroll-margin-top: 80px; }
.post { scroll-margin-top: 80px; }
.notice.offline { margin: 0; }
