:root {
  --text: #2c2c2b;
  --text-2: #7d7a75;
  --canvas: #ffffff;
  --surface: #f9f8f7;
  --surface-2: #f0efed;
  --border: #e6e5e3;
  --accent: #2783de;
  --accent-soft: #e5f2fc;
  --green: #46a171;
  --green-soft: #e8f1ec;
  --orange: #d5803b;
  --orange-soft: #fbebde;
  --red: #e56458;
  --red-soft: #fce9e7;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #ffffff;
    --text-2: rgba(255, 255, 255, 0.65);
    --canvas: #191919;
    --surface: #202020;
    --surface-2: #383836;
    --border: rgba(255, 255, 255, 0.2);
    --accent: #5e9fe8;
    --accent-soft: rgba(94, 159, 232, 0.12);
    --green: #72bc8f;
    --green-soft: rgba(114, 188, 143, 0.12);
    --orange: #de9255;
    --orange-soft: rgba(222, 146, 85, 0.12);
    --red: #e97366;
    --red-soft: rgba(233, 115, 102, 0.12);
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Vazirmatn, -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--canvas);
}

.container { max-width: 760px; margin: 0 auto; padding: 32px 24px 64px; }
@media (max-width: 480px) { .container { padding: 24px 16px 48px; } }

h1 { font-size: 1.75rem; margin: 0 0 8px; }
h2 { font-size: 1.4rem; margin: 0 0 8px; }
h3 { font-size: 1.1rem; margin: 0 0 8px; }
.muted { color: var(--text-2); }
.small { font-size: 14px; }
a { color: var(--accent); text-decoration: none; }

/* ---------- هدر ---------- */
.topbar { border-bottom: 1px solid var(--border); background: var(--canvas); position: sticky; top: 0; z-index: 10; }
.topbar-inner {
  max-width: 960px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 17px; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; font-size: 14px; }
.user-chip img { width: 26px; height: 26px; border-radius: 50%; }

/* ---------- دکمه‌ها ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 18px; border-radius: var(--radius);
  border: 1px solid transparent; font: inherit; font-size: 15px; font-weight: 500;
  cursor: pointer; background: var(--surface-2); color: var(--text);
  transition: filter 0.12s ease;
}
.btn:hover { filter: brightness(0.96); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-sm { min-height: 36px; padding: 4px 14px; font-size: 14px; }
.btn-google { background: var(--canvas); border: 1px solid var(--border); box-shadow: var(--shadow); font-weight: 600; width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ---------- کارت‌ها ---------- */
.card {
  background: var(--canvas); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px; margin-bottom: 16px;
}
.card-soft { background: var(--surface); }

.survey-card { display: flex; flex-direction: column; gap: 8px; }
.survey-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.survey-meta { display: flex; gap: 16px; flex-wrap: wrap; color: var(--text-2); font-size: 14px; }
.survey-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.badge-open { background: var(--green-soft); color: var(--green); }
.badge-closed { background: var(--red-soft); color: var(--red); }
.badge-scheduled { background: var(--orange-soft); color: var(--orange); }
.badge-info { background: var(--accent-soft); color: var(--accent); }

/* ---------- صفحه ورود ---------- */
.login-wrap { display: flex; justify-content: center; padding-top: 48px; }
.login-card { max-width: 400px; width: 100%; text-align: center; padding: 40px 32px; }
.login-emoji { font-size: 48px; margin-bottom: 12px; }
.login-card p { margin: 0 0 24px; }

/* ---------- فرم‌ها ---------- */
label { display: block; font-weight: 600; margin-bottom: 6px; }
.field { margin-bottom: 20px; }
input[type="text"], input[type="datetime-local"], input[type="number"], textarea, select {
  width: 100%; padding: 10px 12px; font: inherit; font-size: 15px;
  color: var(--text); background: var(--canvas);
  border: 1px solid var(--border); border-radius: var(--radius);
}
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { min-height: 90px; resize: vertical; }
.checkbox-row { display: flex; align-items: center; gap: 10px; font-weight: 400; cursor: pointer; margin-bottom: 0; }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--accent); }

/* سازنده سوال */
.q-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; background: var(--surface); }
.q-head { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.q-head .q-num { font-weight: 700; color: var(--text-2); }
.q-head select { width: auto; }
.q-remove { margin-inline-start: auto; }

/* فرم پاسخ */
.answer-q { padding: 20px 0; border-bottom: 1px solid var(--border); }
.answer-q:last-of-type { border-bottom: none; }
.answer-q .q-text { font-weight: 600; margin-bottom: 12px; }
.req-star { color: var(--red); }
.option-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-weight: 400;
}
.option-row:hover { background: var(--surface); }
.option-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.rating-row { display: flex; gap: 8px; flex-wrap: wrap; }
.rating-pill {
  min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-weight: 600;
}
.rating-pill:hover { background: var(--surface); }
.rating-pill input { position: absolute; opacity: 0; pointer-events: none; }
.rating-pill.selected { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- نتایج ---------- */
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stat {
  flex: 1 1 140px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px; text-align: center;
}
.stat .num { font-size: 1.75rem; font-weight: 700; color: var(--accent); }
.stat .lbl { color: var(--text-2); font-size: 14px; }

.bar-row { margin-bottom: 12px; }
.bar-label { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; margin-bottom: 4px; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; min-width: 2px; }
.bar-fill.zero { min-width: 0; }

.text-answers { margin: 0; padding: 0; list-style: none; }
.text-answers li { padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; }

table.resp-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table-wrap { overflow-x: auto; }
.resp-table th, .resp-table td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.resp-table th { color: var(--text-2); font-weight: 600; }

/* مدیریت */
.manage-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.manage-row input[type="datetime-local"] { width: auto; flex: 1 1 220px; }

/* ---------- عمومی ---------- */
.loading { text-align: center; color: var(--text-2); padding: 48px 0; }
.error-box { background: var(--red-soft); color: var(--red); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.empty { text-align: center; color: var(--text-2); padding: 48px 16px; }
.empty .emoji { font-size: 40px; margin-bottom: 8px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }

.toast {
  position: fixed; bottom: 24px; right: 50%; transform: translateX(50%);
  background: var(--text); color: var(--canvas); padding: 10px 20px;
  border-radius: var(--radius); font-size: 14px; box-shadow: var(--shadow); z-index: 100;
}
.toast.error { background: var(--red); color: #fff; }

.thanks-card { text-align: center; padding: 48px 24px; }
.thanks-card .emoji { font-size: 56px; margin-bottom: 12px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
