/* ==========================================================================
   مطالعه کیو — شیوه‌نامه اصلی
   بدون فریم‌ورک و بدون مرحله build، تا آپلود روی هاست اشتراکی ساده بماند.
   ========================================================================== */

@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e2e5ea;
  --border-strong: #cbd2dc;
  --text: #1a1d23;
  --text-muted: #646c7a;
  --primary: #2f5fd8;
  --primary-dark: #2449a8;
  --primary-soft: #eaf0ff;
  --agree: #16a34a;
  --agree-soft: #e7f6ec;
  --neutral: #ca8a04;
  --neutral-soft: #fdf6e3;
  --disagree: #dc2626;
  --disagree-soft: #fdecec;
  --danger: #dc2626;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 10px 28px rgba(16, 24, 40, .10);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1c1f25;
    --surface-2: #23272e;
    --border: #2e333c;
    --border-strong: #3d434e;
    --text: #e8eaee;
    --text-muted: #9aa3b2;
    --primary: #5b86ee;
    --primary-dark: #7ba0f5;
    --primary-soft: #1e2a45;
    --agree-soft: #16301f;
    --neutral-soft: #33290d;
    --disagree-soft: #3a1a1a;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-lg: 0 10px 28px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.85;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.5; margin: 0 0 .6rem; font-weight: 700; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .9rem; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 1rem; }
.container-narrow { max-width: 760px; }

/* ---------- سربرگ ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}
.site-header .inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 62px;
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1rem; color: var(--text); }
.brand span { display: block; font-weight: 400; font-size: .78rem; color: var(--text-muted); }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: .3rem; align-items: center; flex-wrap: wrap; }
.nav a, .nav button {
  padding: .38rem .7rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: .88rem;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: inherit;
}
.nav a:hover, .nav button:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 500; }

main { padding: 1.6rem 0 4rem; }

/* ---------- کارت ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.1rem;
}
.card > :last-child { margin-bottom: 0; }
.card-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .8rem;
  margin-bottom: .9rem;
  flex-wrap: wrap;
}
.card-title h2, .card-title h3 { margin: 0; }
.muted { color: var(--text-muted); }
.small { font-size: .84rem; }
.tiny { font-size: .76rem; }
.center { text-align: center; }

/* ---------- دکمه ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.05rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 500;
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; background: var(--primary); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--disagree-soft); }
.btn-lg { padding: .75rem 1.8rem; font-size: 1rem; }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }

/* ---------- پیام‌ها ---------- */
.alert {
  padding: .8rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid;
  margin-bottom: 1rem;
  font-size: .9rem;
}
.alert-error { background: var(--disagree-soft); border-color: #f5b5b5; color: #a01818; }
.alert-success { background: var(--agree-soft); border-color: #a9dfbc; color: #0f6b32; }
.alert-info { background: var(--primary-soft); border-color: #bcd0f7; color: var(--primary-dark); }
.alert ul { margin: .4rem 0 0; padding-inline-start: 1.2rem; }
@media (prefers-color-scheme: dark) {
  .alert-error { color: #f9b4b4; border-color: #5c2626; }
  .alert-success { color: #9be0b3; border-color: #235c37; }
  .alert-info { color: #a9c4fb; border-color: #2c3f68; }
}

/* ---------- فرم ---------- */
label { display: block; font-size: .88rem; font-weight: 500; margin-bottom: .35rem; }
input[type=text], input[type=email], input[type=password], select, textarea {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .92rem;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}
textarea { resize: vertical; min-height: 90px; }
.field { margin-bottom: 1rem; }
.field-error { color: var(--danger); font-size: .82rem; margin-top: .3rem; }

/* ---------- شبکه آمار ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: .85rem;
  margin-bottom: 1.1rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .95rem 1.1rem;
  box-shadow: var(--shadow);
}
.stat .label { font-size: .8rem; color: var(--text-muted); margin-bottom: .15rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; line-height: 1.3; }

/* ==========================================================================
   نوار ظرفیت ستون‌ها (چسبان بالای فرم)
   ========================================================================== */
.capacity-bar {
  position: sticky;
  top: 62px;
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .7rem .8rem;
  margin-bottom: 1.2rem;
}
.capacity-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .8rem;
  flex-wrap: wrap;
  margin-bottom: .6rem;
}
.capacity-progress {
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
  flex: 1 1 160px;
  min-width: 120px;
}
.capacity-progress i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--primary);
  border-radius: 99px;
  transition: width .2s ease;
}
.capacity-progress.done i { background: var(--agree); }

.capacity-cols {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  gap: .28rem;
}
.cap-col {
  text-align: center;
  border-radius: var(--radius-sm);
  padding: .3rem .1rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-variant-numeric: tabular-nums;
  transition: background .15s, border-color .15s;
}
.cap-col .score { display: block; font-weight: 700; font-size: .82rem; }
.cap-col .count { display: block; font-size: .72rem; color: var(--text-muted); }
.cap-col[data-band=agree] .score { color: var(--agree); }
.cap-col[data-band=neutral] .score { color: var(--neutral); }
.cap-col[data-band=disagree] .score { color: var(--disagree); }
.cap-col.full { background: var(--agree-soft); border-color: var(--agree); }
.cap-col.full .count { color: var(--agree); font-weight: 700; }
.cap-col.highlight { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ==========================================================================
   فهرست گزاره‌ها
   ========================================================================== */
.stage-block { margin-bottom: 1.6rem; }
.stage-header {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin-bottom: .7rem;
  padding-inline-start: .6rem;
  border-inline-start: 4px solid var(--stage-color, var(--primary));
}
.stage-header h2 { margin: 0; font-size: 1.05rem; }
.stage-header .badge { font-size: .74rem; }

.statement {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  margin-bottom: .6rem;
  box-shadow: var(--shadow);
  transition: border-color .15s, background .15s;
}
.statement.answered { border-inline-start: 4px solid var(--band-color, var(--primary)); }
.statement.pending-highlight { border-color: var(--danger); background: var(--disagree-soft); }

.statement-head {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  margin-bottom: .65rem;
}
.statement-code {
  flex: 0 0 auto;
  font-size: .74rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: 99px;
  padding: .1rem .5rem;
  margin-top: .25rem;
  font-variant-numeric: tabular-nums;
}
.statement-text { flex: 1 1 auto; margin: 0; font-size: .96rem; line-height: 1.9; }

/* دکمه‌های امتیاز */
.score-row {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  gap: .25rem;
}
.score-btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: .42rem .1rem;
  font: inherit;
  font-size: .84rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: transform .08s, background .12s, color .12s, border-color .12s;
  min-height: 38px;
}
.score-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.score-btn:active:not(:disabled) { transform: scale(.94); }
.score-btn[aria-pressed=true] {
  background: var(--sel-bg);
  border-color: var(--sel-border);
  color: #fff;
  font-weight: 700;
}
.score-btn[data-band=agree] { --sel-bg: var(--agree); --sel-border: var(--agree); }
.score-btn[data-band=neutral] { --sel-bg: var(--neutral); --sel-border: var(--neutral); }
.score-btn[data-band=disagree] { --sel-bg: var(--disagree); --sel-border: var(--disagree); }
.score-btn:disabled { opacity: .3; cursor: not-allowed; }
.score-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* نوار پایین چسبان */
.submit-bar {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: .8rem 0;
  margin-top: 1.5rem;
  box-shadow: 0 -4px 14px rgba(16, 24, 40, .06);
  z-index: 30;
}
.submit-bar .inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: .1rem .5rem;
  border-radius: 99px;
  font-size: .75rem;
  background: var(--surface-2);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.badge-agree { background: var(--agree-soft); color: var(--agree); }
.badge-neutral { background: var(--neutral-soft); color: var(--neutral); }
.badge-disagree { background: var(--disagree-soft); color: var(--disagree); }

/* ---------- هرم توزیع (صفحه معرفی و نمایش پاسخ) ---------- */
.pyramid {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  gap: .25rem;
  align-items: end;
  overflow-x: auto;
}
.pyramid-col { display: flex; flex-direction: column-reverse; gap: .2rem; align-items: stretch; }
.pyramid-cell {
  height: 20px;
  border-radius: 3px;
  background: var(--primary-soft);
  border: 1px solid var(--primary);
}
.pyramid-col[data-band=agree] .pyramid-cell { background: var(--agree-soft); border-color: var(--agree); }
.pyramid-col[data-band=neutral] .pyramid-cell { background: var(--neutral-soft); border-color: var(--neutral); }
.pyramid-col[data-band=disagree] .pyramid-cell { background: var(--disagree-soft); border-color: var(--disagree); }
.pyramid-label {
  text-align: center;
  font-size: .78rem;
  font-weight: 700;
  padding-top: .35rem;
  border-top: 1px solid var(--border);
  margin-top: .3rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- جدول ---------- */
.table-wrap { overflow-x: auto; margin: 0 -.25rem; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .55rem .6rem; text-align: right; border-bottom: 1px solid var(--border); }
th {
  font-weight: 700;
  color: var(--text-muted);
  font-size: .8rem;
  background: var(--surface-2);
  position: sticky;
  top: 0;
  white-space: nowrap;
}
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* نوار توزیع کوچک داخل جدول */
.sparkbar { display: flex; gap: 1px; align-items: flex-end; height: 26px; min-width: 132px; }
.sparkbar i {
  flex: 1;
  min-height: 2px;
  border-radius: 1px 1px 0 0;
  background: var(--border-strong);
  display: block;
}
.sparkbar i[data-band=agree] { background: var(--agree); }
.sparkbar i[data-band=neutral] { background: var(--neutral); }
.sparkbar i[data-band=disagree] { background: var(--disagree); }

/* ---------- نمودار ---------- */
.chart-box { position: relative; height: 320px; }
.chart-box.tall { height: 420px; }

/* ---------- صفحه‌بندی ---------- */
.pagination { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: center; margin-top: 1rem; }
.pagination a, .pagination span {
  padding: .35rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  color: var(--text-muted);
  background: var(--surface);
}
.pagination .active span { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- واکنش‌گرایی ---------- */
@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .capacity-bar { top: 0; padding: .55rem; }
  .capacity-cols { gap: .18rem; }
  .cap-col { padding: .22rem .05rem; }
  .cap-col .score { font-size: .72rem; }
  .cap-col .count { font-size: .64rem; }
  .score-row { gap: .18rem; }
  .score-btn { font-size: .74rem; padding: .4rem .05rem; min-height: 40px; }
  .statement { padding: .7rem .75rem; }
  .statement-text { font-size: .92rem; }
  .site-header .inner { min-height: 54px; }
  .chart-box { height: 260px; }
}

/* روی گوشی‌های باریک، ۱۱ دکمه در یک ردیف هرکدام ~۲۶ پیکسل می‌شوند که برای
   لمس دقیق کوچک است. دو ردیفه‌شان می‌کنیم: ردیف اول مخالف تا خنثی، ردیف دوم
   موافق — ترتیب −۵ تا +۵ حفظ می‌شود و هدف لمس دو برابر می‌شود. */
@media (max-width: 440px) {
  .score-row { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .22rem; }
  .score-btn { font-size: .82rem; min-height: 42px; }
  /* دکمه ۰ آخرِ ردیف اول است؛ ردیف دوم با +۱ شروع می‌شود و ۵ خانه دارد. */
  .score-btn[data-score="1"] { grid-column-start: 1; }
}

@media print {
  .site-header, .submit-bar, .nav, .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
}
