/* ===== سامانه‌ی پرسشنامه‌های پژوهشی — استایل عمومی و پنل (RTL) ===== */

@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-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-soft: #ccfbf1;
  --accent: #d97706;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #b45309;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 14px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: 'Vazirmatn', Tahoma, 'Segoe UI', 'Noto Sans Arabic', sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.9;
}

.container { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.container.narrow { max-width: 620px; }
.main-content { padding-bottom: 48px; min-height: 70vh; }

h1 { font-size: 1.55rem; margin: 24px 0 8px; }
h2 { font-size: 1.15rem; margin: 18px 0 8px; }
p.lead { color: var(--muted); max-width: 46rem; }
a { color: var(--primary); }
code { background: #eef2f6; padding: 1px 6px; border-radius: 6px; direction: ltr; display: inline-block; }

/* ---------- هدر و فوتر ---------- */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--primary-dark); text-decoration: none; font-size: 1.1rem; }
.site-footer { background: var(--card); border-top: 1px solid var(--line); padding: 18px 0; margin-top: 32px; color: var(--muted); font-size: .9rem; }
.site-footer .container { text-align: center; }

.admin-header .brand { color: #fff; }
.admin-header { background: var(--primary-dark); border-bottom: none; }
.admin-header .admin-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.admin-nav a {
  color: #d1faf3; text-decoration: none; padding: 6px 12px; border-radius: 8px; font-size: .92rem;
}
.admin-nav a:hover { background: rgba(255,255,255,.12); color: #fff; }

/* ---------- کارت‌ها ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin: 16px 0;
}
.card-title { margin-top: 0; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 16px; margin-top: 20px; }
.q-card { position: relative; display: flex; flex-direction: column; gap: 4px; }
.q-card .btn { margin-top: auto; align-self: flex-start; }
.q-card.status-completed { border-color: #bbf7d0; background: #f0fdf4; }
.q-card.status-in_progress { border-color: #fde68a; }

.badge.recommend {
  position: absolute; top: -12px; left: 16px;
  background: var(--accent); color: #fff; font-size: .78rem;
  padding: 2px 12px; border-radius: 999px;
}
.pill {
  display: inline-block; background: #eef2f6; color: var(--muted);
  border-radius: 999px; padding: 2px 12px; font-size: .85rem; margin-left: 6px;
}
.pill.ok { background: #dcfce7; color: #166534; }
.pill.warn { background: #fef3c7; color: #92400e; }
.q-meta { margin: 6px 0 14px; }

.info-card .kv, .kv { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 6px; }
.kv li { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed var(--line); padding: 4px 0; }
.kv li span { color: var(--muted); }
.kv.two-col { grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .kv.two-col { grid-template-columns: 1fr; } }
.code { font-family: 'Vazirmatn', monospace; letter-spacing: 2px; direction: ltr; display: inline-block; }

.success-card { border-color: #86efac; background: #f0fdf4; }

/* ---------- دکمه‌ها ---------- */
.btn {
  display: inline-block; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); border-radius: 10px; padding: 10px 20px;
  font-family: inherit; font-size: .98rem; cursor: pointer; text-decoration: none;
  transition: background .15s ease, transform .05s ease;
}
.btn:hover { background: #f1f5f9; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { background: #fee2e2; border-color: #fecaca; color: var(--danger); }
.btn.danger:hover { background: #fecaca; }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 4px 10px; font-size: .85rem; border-radius: 8px; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px; }

/* ---------- فرم‌ها ---------- */
.field { display: block; margin: 12px 0; }
.field-label { display: block; color: var(--muted); font-size: .92rem; margin-bottom: 4px; }
input[type=text], input[type=number], input[type=password], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-family: inherit; font-size: 1rem; background: #fbfdff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.fieldset { border: 1px dashed var(--line); border-radius: 12px; margin: 14px 0; }
.fieldset legend { padding: 0 8px; color: var(--muted); font-size: .92rem; }
.checkline { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0; font-size: .95rem; }
.checkline input { width: auto; margin-top: 8px; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
.inline-form input, .inline-form select { width: auto; min-width: 140px; }

/* ---------- هشدارها ---------- */
.alert { border-radius: 10px; padding: 10px 14px; margin: 12px 0; font-size: .95rem; }
.alert.error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert.success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert.info { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.center { text-align: center; }

/* ---------- جدول ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th, .table td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: right; vertical-align: top; }
.table thead th { background: #f8fafc; color: var(--muted); font-weight: 700; }
.table tr.missing td { background: #fff7ed; }
.table .total-row td { background: #f8fafc; }
.table textarea { min-width: 260px; }
.edit-table select { min-width: 150px; }
.edit-table input[type=number], .edit-table input[type=text] { min-width: 90px; }
.row-actions { white-space: nowrap; }
.tag { display: inline-block; font-size: .78rem; border-radius: 6px; padding: 1px 8px; margin-top: 4px; }
.tag.muted { background: #eef2f6; color: var(--muted); }
.tag.warn { background: #fef3c7; color: #92400e; }
.pager { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.pager a { border: 1px solid var(--line); border-radius: 8px; padding: 4px 12px; text-decoration: none; }
.pager a.cur { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- گویه‌ها و طیف پاسخ ---------- */
.survey-head { margin-bottom: 12px; }
.progress-wrap { margin: 14px 0; }
.progress-bar {
  height: 12px; background: #e2e8f0; border-radius: 999px; overflow: hidden;
}
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #14b8a6); transition: width .3s ease; }
.progress-text { font-size: .9rem; color: var(--muted); margin-top: 4px; }

.item { margin: 14px 0; }
.item.answered { border-color: #99f6e4; }
.item-text { font-size: 1.02rem; margin-bottom: 10px; }
.item-num { color: var(--primary-dark); font-weight: 700; }

.scale.likert { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
@media (max-width: 640px) {
  .scale.likert { grid-template-columns: 1fr; }
}
.opt {
  display: flex; align-items: center; gap: 10px;
  border: 1.5px solid var(--line); border-radius: 12px;
  padding: 12px 14px; cursor: pointer; min-height: 52px; background: #fbfdff;
  transition: border-color .12s ease, background .12s ease;
}
.opt:hover { border-color: var(--primary); }
.opt input { width: 20px; height: 20px; accent-color: var(--primary); flex: none; }
.opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }

.scale.semantic { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; }
.pole { color: var(--muted); font-size: .9rem; }
.pole.low { text-align: left; }
.pole.high { text-align: right; }
.dots { display: flex; gap: 8px; justify-content: center; }
.dot {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 1.5px solid var(--line); border-radius: 12px; padding: 8px 0;
  width: 46px; cursor: pointer; background: #fbfdff;
}
.dot:hover { border-color: var(--primary); }
.dot input { width: 18px; height: 18px; accent-color: var(--primary); }
.dot:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
@media (max-width: 560px) {
  .scale.semantic { grid-template-columns: 1fr; }
  .dots { justify-content: space-between; }
  .dot { width: 40px; }
  .pole.low, .pole.high { text-align: center; }
}

.summary-table td:nth-child(3) { white-space: nowrap; }
.misslink { color: var(--danger); font-weight: 700; }

/* ---------- داشبورد ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 18px 0; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; text-align: center;
}
.stat-num { display: block; font-size: 1.5rem; font-weight: 700; color: var(--primary-dark); }
.stat-label { font-size: .82rem; color: var(--muted); }

.chart { width: 100%; overflow-x: auto; padding: 6px 0; }
.chart svg { direction: ltr; }
.legend { font-size: .85rem; color: var(--muted); display: flex; gap: 16px; align-items: center; }
.dotc { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-left: 4px; }
.dotc.c1 { background: #94a3b8; }
.dotc.c2 { background: var(--primary); }
.dotc.c3 { background: var(--accent); }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filter-form label { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; color: var(--muted); }
.filter-form input, .filter-form select { width: auto; min-width: 130px; }
.tabs { display: flex; gap: 8px; margin: 14px 0; flex-wrap: wrap; }
.tab { border: 1px solid var(--line); border-radius: 999px; padding: 6px 16px; text-decoration: none; color: var(--muted); background: var(--card); }
.tab.cur { background: var(--primary); color: #fff; border-color: var(--primary); }

.checks { list-style: none; padding: 0; margin: 8px 0; }
.checks li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.checks li.ok { color: var(--ok); }
.checks li.bad { color: var(--danger); font-weight: 700; }

.login-body { display: flex; align-items: center; min-height: 100vh; background: linear-gradient(160deg, #f4f6f8, #e2e8f0); }
.login-card { width: 100%; }
