/* Shared styles for the teacher page (index.html) and the admin page (admin.html). Phone first. */
:root {
  color-scheme: light;
  --bg: #f1f5f5;
  --surface: #ffffff;
  --ink: #12343b;
  --muted: #566d72;
  --line: #d6e2e4;
  --primary: #0f5c68;
  --primary-press: #0b4952;
  --tint: #e8f1f2;
  --green: #41af70;
  --ok: #1d7047;
  --ok-tint: #e7f4ec;
  --err: #b42318;
  --err-tint: #fdeceb;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 18px;
  --shadow: 0 1px 2px rgb(15 92 104 / .06), 0 6px 18px rgb(15 92 104 / .06);
  --font: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --font-head: 'Noto Kufi Arabic', 'IBM Plex Sans Arabic', sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid rgb(15 92 104 / .35); outline-offset: 2px; }

/* header */
.hdr { background: var(--surface); border-bottom: 1px solid var(--line); position: relative; }
.hdr::before { content: ''; position: absolute; inset: 0 0 auto; height: 4px; background: var(--primary); }
.hdr::after { content: ''; position: absolute; top: 4px; left: 0; right: 0; height: 2px; background: var(--green); }
.hdr-in { max-width: 640px; margin: 0 auto; padding: 18px 18px 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.hdr-txt { min-width: 0; }
.hdr-school { font-family: var(--font-head); font-weight: 700; font-size: 15px; line-height: 1.6; color: var(--primary); }
.hdr-sub { font-size: 13px; color: var(--muted); }
.hdr-logo { width: 74px; height: auto; flex: none; }
body.admin .hdr-in, body.admin .wrap { max-width: 760px; }

.wrap { max-width: 640px; margin: 0 auto; padding: 22px 16px calc(40px + env(safe-area-inset-bottom)); }
.title { font-family: var(--font-head); font-weight: 700; font-size: 22px; line-height: 1.5; margin: 4px 0 4px; }
.lead { margin: 0 0 18px; color: var(--muted); font-size: 15px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card h2 { font-family: var(--font-head); font-size: 16.5px; font-weight: 700; margin: 0 0 12px; line-height: 1.5; }

/* form fields */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
label, .lbl { font-weight: 600; font-size: 15px; }
.in, select.in, textarea.in {
  width: 100%; min-height: 50px; padding: 11px 14px; border: 1.5px solid #bfd0d3; border-radius: var(--r);
  background: #fff; font-size: 16px; line-height: 1.5;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea.in { resize: vertical; min-height: 84px; }
.in::placeholder { color: #7d9095; }
.in:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgb(15 92 104 / .15); }
.in.bad { border-color: var(--err); }
.in[dir="ltr"] { text-align: left; }
select.in {
  appearance: none; -webkit-appearance: none; padding-left: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230f5c68' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6l6 -6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 12px center; background-size: 20px;
}
.help { margin: 0; font-size: 13.5px; color: var(--muted); }
.err { margin: 0; font-size: 14px; color: var(--err); font-weight: 600; min-height: 0; }
.err:empty { display: none; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px; border-radius: var(--r); border: 1.5px solid var(--line);
  background: #fff; color: var(--ink); font-weight: 600; font-size: 15.5px; cursor: pointer; text-decoration: none;
  transition: background-color .15s ease, border-color .15s ease, transform .1s ease;
  -webkit-tap-highlight-color: transparent; white-space: nowrap;
}
.btn:hover { border-color: #b4c9cc; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; cursor: default; transform: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-press); border-color: var(--primary-press); }
.btn.block { width: 100%; }
.btn.sm { min-height: 44px; padding: 8px 14px; font-size: 14.5px; }
.btn.danger { color: var(--err); border-color: #efc9c5; }
.btn.danger:hover { background: var(--err-tint); }
.btn svg { width: 19px; height: 19px; flex: none; }
.linkbtn { background: none; border: 0; padding: 8px 4px; color: var(--primary); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 7px; text-decoration-thickness: 1px; min-height: 44px; }

/* notes */
.note { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--r); font-size: 15px; }
.note svg { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.note.ok { background: var(--ok-tint); color: var(--ok); }
.note.warn { background: var(--err-tint); color: var(--err); }
.note strong { font-weight: 700; }

/* teacher page: success */
.done { text-align: center; padding: 34px 20px 26px; }
.done-ic { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; background: var(--ok-tint); color: var(--ok); display: grid; place-items: center; }
.done-ic svg { width: 34px; height: 34px; }
.done h2 { font-size: 20px; margin-bottom: 4px; }
.done p { margin: 0 0 4px; color: var(--muted); }
.done .who { color: var(--ink); font-weight: 700; font-size: 17px; }

/* loading skeleton */
.sk { height: 50px; border-radius: var(--r); background: linear-gradient(90deg, #e9f0f1 25%, #f4f8f8 50%, #e9f0f1 75%); background-size: 200% 100%; animation: sk 1.4s ease-in-out infinite; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* admin: summary */
.stat { display: grid; gap: 14px; }
.stat-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.stat-num { font-family: var(--font-head); font-weight: 700; font-size: 34px; line-height: 1.2; color: var(--primary); }
.stat-num small { font-size: 20px; color: var(--muted); font-weight: 600; }
.stat-l { color: var(--muted); font-size: 14.5px; }
.bar { height: 8px; border-radius: 8px; background: var(--tint); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--green); border-radius: 8px; transition: width .4s ease; }
.actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.actions .btn { white-space: normal; line-height: 1.35; text-align: center; padding-inline: 12px; }
.actions .btn.primary { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 15px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); flex: none; }
.pdf-ready { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: var(--r); background: var(--ok-tint); color: var(--ok); font-weight: 600; font-size: 14.5px; }

/* admin: list */
.sec-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.sec-h h2 { margin: 0; }
.seg { display: inline-flex; background: var(--tint); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: none; padding: 8px 12px; min-height: 40px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button[aria-selected="true"] { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgb(15 92 104 / .15); }

.list { list-style: none; margin: 0; padding: 0; }
.row { border-top: 1px solid #e3ecee; }
.row:first-child { border-top: 0; }
.row-main { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 4px; min-height: 58px; background: none; border: 0; text-align: right; cursor: pointer; }
.row-n { flex: none; width: 30px; height: 30px; border-radius: 8px; border: 1.5px solid #9fbcc1; color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.row-name { flex: 1; min-width: 0; font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { flex: none; font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 20px; }
.chip.ok { background: var(--ok-tint); color: var(--ok); }
.chip.no { background: #f1f3f3; color: #66787c; }
.row-chev { width: 20px; height: 20px; color: #7d9095; flex: none; transition: transform .2s ease; }
.row.open .row-chev { transform: rotate(180deg); }
.row-edit { padding: 4px 4px 16px; display: grid; gap: 12px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.row-url { font-size: 13px; color: var(--muted); direction: ltr; text-align: left; word-break: break-all; margin: -4px 0 0; }
.add { display: flex; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.add .in { flex: 1; }
.empty-list { padding: 18px 4px; color: var(--muted); text-align: center; }

.sig { display: grid; gap: 8px; padding: 14px; border: 1px solid #e3ecee; border-radius: var(--r); }
.sig + .sig { margin-top: 10px; }
.sig-h { font-size: 13px; font-weight: 700; color: var(--primary); }
.saved { font-size: 13.5px; color: var(--ok); font-weight: 600; min-height: 22px; margin-top: 10px; }

.foot { text-align: center; margin-top: 18px; }

/* dialog, toast, busy overlay */
.dlg { border: 0; border-radius: var(--r-lg); padding: 24px 20px 20px; width: min(92vw, 380px); box-shadow: 0 20px 60px rgb(18 52 59 / .25); }
.dlg::backdrop { background: rgb(18 52 59 / .45); }
.dlg h2 { font-family: var(--font-head); margin: 0 0 6px; font-size: 18px; }
.dlg p { margin: 0 0 14px; color: var(--muted); font-size: 14.5px; }
.dlg .err { margin-top: 8px; }
.dlg .btn { margin-top: 14px; }
.dlg-row { display: flex; gap: 10px; justify-content: flex-start; }
.dlg-row .btn { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 15px; font-weight: 500;
  max-width: calc(100vw - 32px); box-shadow: 0 10px 30px rgb(18 52 59 / .3); z-index: 30;
  animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.busy { position: fixed; inset: 0; z-index: 20; background: rgb(241 245 245 / .97); display: grid; place-items: center; }
.busy-box { text-align: center; padding: 20px; }
.spin { width: 40px; height: 40px; margin: 0 auto 14px; border-radius: 50%; border: 3.5px solid var(--tint); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.busy-t { font-weight: 600; font-size: 16px; }
.busy-s { color: var(--muted); font-size: 14px; margin-top: 4px; }

@media (min-width: 640px) {
  .wrap { padding-top: 32px; }
  .card { padding: 24px; }
  .actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .actions .btn.primary { grid-column: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.sig-title { margin-top: 22px; }
