/* دفتر کلاس دیجیتال — shared styles. RTL-first, mobile-first (360px). */

@font-face {
  font-family: "Vazirmatn";
  src: url("/fonts/Vazirmatn-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #24292f;
  --muted: #667085;
  --line: #e4e7ec;
  --brand: #3366e6;   /* white text on it: 5.0:1 (WCAG AA) */
  --brand-ink: #1e40af;
  --brand-soft: #e8eefc;
  --ok-bg: #dcfce7;   --ok-ink: #166534;
  --bad-bg: #fee2e2;  --bad-ink: #991b1b;
  --late-bg: #fef3c7; --late-ink: #92400e;
  --exc-bg: #e0f2fe;  --exc-ink: #075985;
  --none-bg: #f2f4f7; --none-ink: #475467;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Vazirmatn", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-ink); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.container { max-width: 960px; margin: 0 auto; padding: 12px 16px 80px; }
h1 { font-size: 20px; margin: 8px 0 16px; }
h2 { font-size: 18px; margin: 4px 0 12px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---- top bar --------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 16px; background: var(--card); box-shadow: var(--shadow);
}
.topbar .brand { font-weight: 700; color: var(--brand-ink); }
.topbar .who { color: var(--muted); font-size: 13px; }
.topbar .spacer { flex: 1; }

.sync {
  font-size: 12px; padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.sync-ok { background: var(--ok-bg); color: var(--ok-ink); }
.sync-busy { background: var(--late-bg); color: var(--late-ink); }
.sync-bad { background: var(--bad-bg); color: var(--bad-ink); font-weight: 600; }

/* ---- buttons & inputs ------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px; border-radius: 8px;
  border: 1px solid var(--brand); background: var(--card); color: var(--brand-ink);
  text-decoration: none; font-weight: 500;
}
.btn:hover { background: var(--brand-soft); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: #2b59d1; }
.btn-small { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.btn-plain { border-color: transparent; background: transparent; }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field input, .field select, .input {
  min-height: 40px; padding: 6px 10px; border: 1px solid #d0d5dd; border-radius: 8px;
  background: #fff; color: var(--text); font-size: 15px; width: 100%;
}
.input.invalid, .grade-input.invalid { border-color: var(--bad-ink); background: var(--bad-bg); }

/* ---- login ----------------------------------------------------------- */
.login-card {
  max-width: 360px; margin: 12vh auto 0; background: var(--card); padding: 24px;
  border-radius: var(--radius); box-shadow: var(--shadow); display: grid; gap: 14px;
}
.login-card h1 { margin: 0; text-align: center; }
.form-error { color: var(--bad-ink); font-size: 14px; min-height: 1.4em; margin: 0; }

/* ---- course cards (as in the prototype) ------------------------------ */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.card {
  display: block; background: var(--card); padding: 16px 18px; border-radius: var(--radius);
  box-shadow: var(--shadow); border-inline-start: 4px solid var(--brand);
  color: inherit; text-decoration: none;
}
.card:hover { box-shadow: 0 4px 12px rgba(0, 0, 0, .12); }
.card-title { font-weight: 700; font-size: 17px; }
.card-sub { color: var(--muted); font-size: 14px; }
.card-meta { margin-top: 8px; font-size: 13px; color: var(--brand); }

/* ---- session screen -------------------------------------------------- */
.back-row { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.panel {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px; margin-bottom: 12px;
}
.session-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.session-bar .topic { grid-column: 1 / -1; }
.date-hint { font-size: 12px; color: var(--brand-ink); min-height: 1.2em; }
.toolbar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.toolbar .field { flex: 1 1 180px; }

table.main {
  width: 100%; border-collapse: collapse; background: var(--card);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); table-layout: fixed;
}
table.main th { background: var(--brand); color: #fff; padding: 10px 6px; font-weight: 500; font-size: 14px; }
table.main th:nth-child(1) { width: auto; }
table.main th:nth-child(2) { width: 92px; }
table.main th:nth-child(3) { width: 84px; }
table.main td { padding: 6px; border-bottom: 1px solid var(--line); text-align: center; }
td.student-name { text-align: start; padding-inline-start: 12px; }
.name-btn {
  border: 0; background: none; padding: 6px 0; width: 100%; text-align: start;
  color: #2563eb; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.name-btn:hover { text-decoration: underline; }

.att-btn {
  width: 100%; min-height: 40px; border: 0; border-radius: 8px; font-size: 14px; font-weight: 500;
}
.att-none    { background: var(--none-bg); color: var(--none-ink); }
.att-present { background: var(--ok-bg);   color: var(--ok-ink); }
.att-absent  { background: var(--bad-bg);  color: var(--bad-ink); }
.att-late    { background: var(--late-bg); color: var(--late-ink); }
.att-excused { background: var(--exc-bg);  color: var(--exc-ink); }

.grade-input {
  width: 100%; min-height: 40px; padding: 4px; border: 1px solid #d0d5dd; border-radius: 8px;
  text-align: center; font-size: 15px; background: #fff;
}
.grade-input:disabled { background: var(--none-bg); }

.detail-row td { background: #f8f9fb; padding: 0; }
.detail-content { padding: 12px; text-align: start; }
.summary {
  display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: center;
  padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; margin-bottom: 10px;
}
.summary strong { color: var(--brand-ink); }
.summary .bad { color: var(--bad-ink); }
.detail-table { width: 100%; border-collapse: collapse; background: #fff; font-size: 13px; border: 1px solid var(--line); }
.detail-table th { background: var(--brand-soft); padding: 6px; font-weight: 500; }
.detail-table td { padding: 6px; border-bottom: 1px solid var(--line); text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 12px; font-size: 13px; }
.absent-dates { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* ---- dialog ---------------------------------------------------------- */
dialog {
  border: 0; border-radius: var(--radius); padding: 0; width: min(92vw, 380px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}
dialog::backdrop { background: rgba(0, 0, 0, .35); }
dialog form { display: grid; gap: 12px; padding: 18px; }
dialog h3 { margin: 0; font-size: 17px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---- toasts ---------------------------------------------------------- */
.toasts {
  position: fixed; inset-inline: 16px; bottom: 16px; z-index: 3000;
  display: grid; gap: 8px; justify-items: center; pointer-events: none;
}
.toast {
  background: #1f2937; color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 14px; max-width: 480px; box-shadow: var(--shadow);
}
.toast-error { background: var(--bad-ink); }

@media (min-width: 640px) {
  .container { padding: 20px 24px 80px; }
  .session-bar { grid-template-columns: 1.2fr .8fr 2fr; }
  .session-bar .topic { grid-column: auto; }
  table.main th:nth-child(2) { width: 120px; }
  table.main th:nth-child(3) { width: 110px; }
  td.student-name { padding-inline-start: 20px; }
}

/* ---- vice-principal pages -------------------------------------------- */
.container.wide { max-width: 1200px; }
.year-select { min-height: 32px; padding: 2px 8px; font-size: 13px; width: auto; }
.vp-nav {
  display: flex; gap: 4px; overflow-x: auto; padding: 6px 12px; background: var(--card);
  border-top: 1px solid var(--line); box-shadow: var(--shadow); scrollbar-width: none;
}
.vp-nav::-webkit-scrollbar { display: none; }
.vp-nav a {
  flex: none; padding: 6px 12px; border-radius: 999px; text-decoration: none;
  color: var(--text); font-size: 14px; white-space: nowrap;
}
.vp-nav a:hover { background: var(--brand-soft); }
.vp-nav a[aria-current="page"] { background: var(--brand); color: #fff; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px 16px; margin: 4px 0 12px; }
.page-head h1 { margin: 0; }
.page-sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 6px; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
.btn-danger { color: var(--bad-ink); }
.btn-danger:hover { background: var(--bad-bg); }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.filters .field { flex: 1 1 140px; min-width: 0; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; flex: none; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 14px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--brand-ink); }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-bad .stat-value { color: var(--bad-ink); }

.table-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
table.report { width: 100%; border-collapse: collapse; font-size: 14px; }
table.report th { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; padding: 8px; text-align: start; white-space: nowrap; }
table.report td { padding: 7px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
table.report tbody tr:hover td { background: #fafbfc; }
table.matrix th, table.matrix td { text-align: center; }
table.matrix th:first-child, table.matrix td:first-child { text-align: start; position: sticky; inset-inline-start: 0; background: var(--card); white-space: nowrap; }
table.matrix th:first-child { background: var(--brand-soft); }
table.matrix small { font-weight: 400; color: var(--muted); }
table.compact { font-size: 13px; }
table.compact td, table.compact th { padding: 5px 8px; }
td.ok, .ok { color: var(--ok-ink); }
td.bad, .bad { color: var(--bad-ink); }
td.strong, .strong { font-weight: 700; }
.strike { text-decoration: line-through; }
td.actions span { display: inline-flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
td.actions { text-align: end; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.badge { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 13px; }
.panel.bad { background: var(--bad-bg); }

.course-block h3 { margin: 0 0 8px; font-size: 16px; }
.course-block .table-wrap { box-shadow: none; border: 1px solid var(--line); margin-bottom: 8px; }
.dates-line { margin: 4px 0; font-size: 14px; }

.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 16px; }
.check-list .check { padding: 4px 0; }
.sticky-actions {
  position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--card); box-shadow: 0 -2px 8px rgba(0, 0, 0, .08); border-radius: var(--radius) var(--radius) 0 0;
}
dialog.wide { width: min(96vw, 720px); }
.import-preview .table-wrap { max-height: 40vh; overflow: auto; }

@media (max-width: 639px) {
  .hide-sm { display: none; }
  .vp .topbar .who { display: none; }
  .page-actions { width: 100%; }
}

/* ---- print ------------------------------------------------------------ */
/* migration page (/migrate.html) */
.steps { padding-inline-start: 20px; line-height: 2; }
.ok-panel { background: var(--ok-bg); color: var(--ok-ink); }
.ok-panel .muted { color: var(--ok-ink); }
.panel h2 { font-size: 16px; margin: 0 0 8px; }
.panel textarea.input { width: 100%; font-family: monospace; }
body.migrate table.report select.input { min-width: 150px; }

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 11pt; }
  .topbar, .vp-nav, .no-print, .toasts, .jdp-container, .jdp-overlay, dialog { display: none !important; }
  .container, .container.wide { max-width: none; padding: 0; }
  .page-head { margin-bottom: 8px; }
  .page-sub { color: #000; }
  .panel, .stat, .table-wrap { box-shadow: none; border: 1px solid #ccc; }
  .table-wrap { overflow: visible; }
  table.report { font-size: 10pt; }
  table.report th { background: #eee !important; color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table.matrix th:first-child, table.matrix td:first-child { position: static; }
  thead { display: table-header-group; }
  tr, .stat { break-inside: avoid; }
  .course-block { break-inside: avoid-page; }
  a { color: #000; text-decoration: none; }
  .hide-sm { display: table-cell; }
}
