/* Quizy */
:root {
  --bg: #f4f2ec;
  --card: #ffffff;
  --ink: #1b2130;
  --ink-2: #2a3245;
  --muted: #6a7182;
  --line: #e5e1d6;
  --field: #d7d2c4;
  --accent: #0f6b5c;
  --accent-2: #0a5247;
  --accent-soft: #e2f1ec;
  --warn: #b45309;
  --warn-soft: #fef4d6;
  --danger: #b42318;
  --danger-soft: #fde8e6;
  --ok: #067647;
  --ok-soft: #dff7e7;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 20px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "IBM Plex Sans Arabic", "Segoe UI", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.75;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
[hidden] { display: none !important; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; }
.narrow { max-width: 580px; }
.center { text-align: center; justify-content: center; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
h1, h2, h3 { line-height: 1.35; margin: 0 0 12px; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.eyebrow { color: var(--muted); font-size: .85rem; font-weight: 600; margin: 0 0 4px; }

/* ---------- نماذج ---------- */
label { display: block; font-weight: 600; margin: 16px 0 6px; }
input[type=text], input[type=password], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--field);
  border-radius: 10px;
  font: inherit;
  background: #fff;
  color: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 110px; resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; margin: 12px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.hint { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.hint.warn-text { color: var(--warn); }
.hint.ok-text { color: var(--ok); }
.choice-row { display: flex; gap: 10px; flex-wrap: wrap; }
.choice {
  display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 500; cursor: pointer;
  border: 1px solid var(--field); border-radius: 10px; padding: 9px 16px; background: #fff; flex: 1; min-width: 120px;
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }
.choice input { accent-color: var(--accent); width: 17px; height: 17px; margin: 0; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters label { margin: 0 0 4px; font-size: .82rem; color: var(--muted); }
.filters select { min-width: 140px; padding: 7px 10px; }
.upload {
  border: 1.5px dashed var(--field); border-radius: 12px; padding: 16px; background: #fbfaf6;
}
.upload input[type=file] { width: 100%; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--accent-2); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--field); }
.btn.secondary:hover { background: #f3f0e8; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #8f1c13; }
.btn.ghost-danger { background: #fff; color: var(--danger); border-color: #f1c3be; }
.btn.ghost-danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 5px 11px; font-size: .85rem; border-radius: 8px; }
.btn.lg { padding: 14px 28px; font-size: 1.08rem; }
.btn.block { display: flex; width: 100%; margin-top: 22px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 18px; }
@media (max-width: 720px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
form.inline { display: inline; }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; border: 1px solid; }
.alert.error { background: var(--danger-soft); border-color: #f6c4be; color: #7a1a12; }
.alert.ok { background: var(--ok-soft); border-color: #b5ebc8; color: #05532f; }
.alert.warn { background: var(--warn-soft); border-color: #f6dc95; color: #7a3d06; }
.alert.info { background: #eaf2fb; border-color: #c4d9f1; color: #1d3f6b; }

/* ---------- جداول ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { font-weight: 600; color: var(--muted); font-size: .82rem; background: #faf8f3; white-space: nowrap; }
td.num, th.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.dim td { color: var(--muted); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; background: #eef0f3; color: #344054; white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.live { background: var(--accent-soft); color: var(--accent-2); }
.badge.live::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); margin-inline-end: 6px; vertical-align: middle; animation: blink 1.2s infinite;
}
@keyframes blink { 50% { opacity: .25; } }

/* ---------- الطالب ---------- */
body.student main.wrap { padding-top: 36px; }
.hero { text-align: center; margin-bottom: 22px; }
.hero h1 { font-size: 1.75rem; margin-bottom: 4px; }
.empty { text-align: center; padding: 12px 0; }
.foot { text-align: center; margin-top: 8px; }

.lobby h1 { margin-bottom: 18px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 20px; }
.facts div { background: #f7f5ef; border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.facts b { display: block; font-size: 1.5rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.facts span { color: var(--muted); font-size: .82rem; }
.instructions { background: #f7f5ef; border-radius: 12px; padding: 14px 16px; margin-bottom: 18px; }
.rules { margin: 0; padding-inline-start: 20px; }
.rules li { margin-bottom: 6px; }

.result { text-align: center; }
.result-icon {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 14px;
  display: grid; place-items: center; font-size: 2rem; font-weight: 700;
  background: var(--ok-soft); color: var(--ok);
}
.result-icon.bad { background: var(--danger-soft); color: var(--danger); }
.score { border-radius: 14px; padding: 18px; margin: 8px 0 16px; }
.score b { display: block; font-size: 2.4rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.score.pass { background: var(--ok-soft); color: var(--ok); }
.score.fail { background: var(--warn-soft); color: var(--warn); }

/* ---------- صفحة الامتحان ---------- */
body.exam-page { -webkit-user-select: none; user-select: none; }
.exam-bar {
  position: sticky; top: 0; z-index: 20;
  background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px 14px;
}
.eb-title { display: flex; flex-direction: column; line-height: 1.4; min-width: 0; }
.eb-title b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eb-title span { color: #b9c1d1; font-size: .85rem; }
.eb-right { display: flex; align-items: center; gap: 10px; }
.timer {
  font-variant-numeric: tabular-nums; font-size: 1.45rem; font-weight: 700; letter-spacing: .5px;
  background: rgba(255, 255, 255, .1); padding: 2px 14px; border-radius: 10px; direction: ltr;
}
.timer.warn { background: var(--warn); }
.timer.crit { background: var(--danger); animation: blink 1s infinite; }
.viol { font-size: .82rem; color: #b9c1d1; white-space: nowrap; }
.viol.has { color: #ffd2cc; font-weight: 600; }
.time-track { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.12); }
.time-track i { display: block; height: 100%; width: 100%; background: #46c2a8; transition: width .5s linear; }

.exam-grid { display: grid; grid-template-columns: 1fr 290px; gap: 20px; align-items: start; padding-top: 22px; }
@media (max-width: 860px) { .exam-grid { grid-template-columns: 1fr; } }
.qcard { padding: 28px; }
.qhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.save { font-size: .8rem; color: var(--muted); }
.save.saved { color: var(--ok); }
.save.error { color: var(--danger); font-weight: 600; }
.qtext { font-size: 1.22rem; font-weight: 600; white-space: pre-wrap; margin-bottom: 18px; line-height: 1.8; }
.opt {
  display: flex; gap: 14px; align-items: flex-start; width: 100%;
  padding: 14px 16px; margin: 10px 0;
  border: 1.5px solid var(--line); border-radius: 12px;
  background: #fff; color: inherit; font: inherit; text-align: start; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.opt:hover { border-color: #bdb6a3; }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.opt .letter {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; background: #f1eee5; font-weight: 700;
}
.opt.sel .letter { background: var(--accent); color: #fff; }
.opt .otext { padding-top: 3px; white-space: pre-wrap; }
.qfoot { display: flex; justify-content: space-between; margin-top: 22px; gap: 10px; }
.qfoot .btn[hidden] { display: none; }

.side { position: sticky; top: 92px; }
.qnav { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; margin: 10px 0 14px; }
.qnav button {
  height: 40px; border-radius: 8px; border: 1px solid var(--field); background: #fff;
  font: inherit; font-weight: 600; cursor: pointer; color: var(--ink); font-variant-numeric: tabular-nums;
}
.qnav button.answered { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-2); }
.qnav button.current { outline: 2px solid var(--ink); outline-offset: 1px; }
.legend { display: flex; gap: 14px; }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 3px; border: 1px solid var(--field); background: #fff; vertical-align: middle; }
.dot.answered { background: var(--accent-soft); border-color: var(--accent); }

.overlay {
  position: fixed; inset: 0; z-index: 100; display: none; place-items: center; padding: 20px;
  background: rgba(17, 21, 31, .96); color: #fff; text-align: center;
}
.overlay.soft { background: rgba(17, 21, 31, .55); }
.overlay.show { display: grid; }
.overlay-box { max-width: 460px; }
.overlay-box.light { background: #fff; color: var(--ink); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.overlay-icon {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 16px;
  display: grid; place-items: center; font-size: 2rem; font-weight: 700; background: var(--danger);
}
.overlay p { color: inherit; opacity: .9; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 200; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media print { body.exam-page * { display: none !important; } }

/* ---------- لوحة الأستاذ ---------- */
.topbar { background: var(--ink); color: #fff; }
.topbar .wrap { display: flex; align-items: center; gap: 22px; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; }
.topbar nav { display: flex; gap: 18px; flex-wrap: wrap; }
.topbar a { color: #b9c1d1; text-decoration: none; font-weight: 500; }
.topbar a.active, .topbar a:hover { color: #fff; }
.topbar .brand { color: #fff; font-weight: 700; }


.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; }

.linkbox { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.linkbox code {
  background: #f3f0e8; border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px;
  direction: ltr; font-size: .95rem; user-select: all;
}

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat b { display: block; font-size: 1.55rem; line-height: 1.3; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .82rem; }

.histo { display: grid; grid-template-columns: repeat(10, 1fr); gap: 8px; align-items: end; height: 170px; direction: ltr; }
.histo .col { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.histo .bar { width: 100%; background: var(--accent); border-radius: 6px 6px 0 0; min-height: 2px; }
.histo .bar.low { background: #d68b2f; }
.histo .n { font-size: .78rem; font-weight: 600; margin-bottom: 3px; font-variant-numeric: tabular-nums; }
.histo .lbl { font-size: .7rem; color: var(--muted); margin-top: 4px; white-space: nowrap; }

.meter { height: 8px; background: #eeebe3; border-radius: 99px; overflow: hidden; min-width: 90px; }
.meter i { display: block; height: 100%; background: var(--accent); }
.meter.low i { background: var(--danger); }
.meter.mid i { background: #d68b2f; }

.qlist { list-style: none; margin: 0; padding: 0; }
.qlist > li { border-bottom: 1px solid var(--line); padding: 16px 0; }
.qlist > li:last-child { border-bottom: 0; }
.qlist .qt { font-weight: 600; white-space: pre-wrap; }
.qlist ol { margin: 8px 0 8px; padding-inline-start: 22px; }
.qlist ol li.right { color: var(--ok); font-weight: 600; }
.qlist ol li.wrong { color: var(--danger); }
.opt-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.opt-row input[type=radio] { width: 20px; height: 20px; accent-color: var(--ok); flex: none; }
.tag { font-size: .78rem; padding: 1px 8px; border-radius: 6px; background: #f3f0e8; color: var(--muted); }

details.box { border: 1px solid var(--line); border-radius: 12px; padding: 4px 16px; background: #fbfaf6; margin-bottom: 16px; }
details.box summary { cursor: pointer; font-weight: 600; padding: 10px 0; }
pre.sample { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; direction: rtl; font-size: .85rem; }

.login-card { max-width: 420px; margin: 70px auto; }

/* ---------- Quizy: الهوية والشرائط ---------- */
.logo { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: inherit; direction: ltr; }
.logo-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent); color: #fff; font: 700 18px/1 "Poppins", Arial, sans-serif;
}
.logo-word { font: 700 1.2rem/1 "Poppins", Arial, sans-serif; letter-spacing: -.2px; }
.sbar { background: var(--card); border-bottom: 1px solid var(--line); }
.sbar .wrap { display: flex; align-items: center; justify-content: space-between; padding-top: 12px; padding-bottom: 12px; }
.sbar .logo { color: var(--ink); }
.lang-switch {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-weight: 600; font-size: .9rem;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--field); color: var(--ink); background: #fff;
}
.lang-switch:hover { border-color: var(--accent); color: var(--accent); }
.topbar .logo { color: #fff; }
.topbar .lang-switch { background: transparent; color: #fff; border-color: rgba(255,255,255,.25); }
.topbar .lang-switch:hover { color: #fff; border-color: #fff; }
.tb-end { margin-inline-start: auto; display: flex; align-items: center; gap: 14px; }
.who { color: #b9c1d1; font-size: .88rem; direction: ltr; }

.summary { background: var(--accent-soft); border: 1px solid #bfe3d8; border-radius: 12px; padding: 14px 16px; margin-bottom: 18px; }
.summary h3 { color: var(--accent-2); margin-bottom: 6px; }
.dnd { background: #f7f5ef; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-top: 18px; }
.dnd ul { margin: 6px 0 4px; padding-inline-start: 20px; }
.dnd li { margin-bottom: 4px; }
.dnd .check { margin-bottom: 0; font-weight: 600; }

/* علامة مائية فوق الأسئلة: اسم الطالب */
.watermark { position: fixed; inset: 0; pointer-events: none; z-index: 15; background-repeat: repeat; }
/* إخفاء الأسئلة عند محاولة التصوير */
.shield { display: none; position: fixed; inset: 0; z-index: 90; background: var(--bg); }
body.shielded .shield { display: block; }
body.shielded #examGrid { visibility: hidden; }

.accounts td form { display: inline-flex; gap: 6px; align-items: center; }
.accounts input[type=password] { width: 160px; padding: 6px 10px; }
.you-tag { font-size: .75rem; color: var(--accent-2); background: var(--accent-soft); border-radius: 6px; padding: 1px 8px; }
