/* ==========================================================================
   سیستم طراحی — نظام آراستگی محیط کار (۵S)
   ----------------------------------------------------------------------
   فلسفه‌ی طراحی: پالت رنگیِ ۵ سطحِ امتیازدهی (خیلی‌خوب..خیلی‌ضعیف) که در
   خودِ ماهیت این ابزار وجود دارد را به‌عنوان امضای بصری کل رابط کاربری به کار
   می‌بریم (نه یک رنگ برند دلبخواهی) — روی نوار پیشرفت، کارت‌ها، نمودارها و
   نقشه‌ی حرارتی. زمینه‌ی گرم و بی‌رنگ، شبیه برگه‌ی بازرسی/چک‌لیست کاغذی.
   ========================================================================== */

@import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');

:root {
  /* --- سطوح خنثی (کاغذ بازرسی) --- */
  --paper: #F3F1EA;
  --paper-raised: #FFFFFF;
  --ink: #1C2B33;
  --ink-soft: #5B6770;
  --ink-faint: #8A9199;
  --border: #E1DED3;
  --border-strong: #C9C5B6;

  /* --- ساختاری (فولاد صنعتی) --- */
  --steel: #33566B;
  --steel-deep: #223C4A;
  --steel-mist: #E7EEF1;

  /* --- پالت پنج‌سطحیِ امتیاز (امضای بصری) --- */
  --s5: #3C8F5C;   /* خیلی خوب */
  --s5-bg: #E4F3E9;
  --s4: #7FA24C;   /* خوب */
  --s4-bg: #EDF3E1;
  --s3: #D6A23C;   /* متوسط */
  --s3-bg: #FBF1DE;
  --s2: #D3763B;   /* ضعیف */
  --s2-bg: #FBE9DC;
  --s1: #BE4638;   /* خیلی ضعیف */
  --s1-bg: #F8E1DD;

  /* --- سایه و شعاع --- */
  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 22px;
  --shadow-card: 0 1px 2px rgba(28,43,51,.04), 0 6px 20px rgba(28,43,51,.06);
  --shadow-pop: 0 12px 32px rgba(28,43,51,.16);

  --font-ui: 'Vazirmatn', sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--paper);
  color: var(--ink);
  direction: rtl;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  font-variant-numeric: tabular-nums;
}

#app { min-height: 100%; display: flex; flex-direction: column; }

button { font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* پوشش focus قابل‌مشاهده برای دسترسی‌پذیری */
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--steel);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ============================================================ لایه‌بندی کلی */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  padding: 14px 18px 12px;
}
.topbar__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.topbar__title { font-weight: 800; font-size: 16px; letter-spacing: -.2px; }
.topbar__subtitle { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.topbar__back {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--paper-raised); display: flex; align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer; color: var(--steel); flex: none;
}
.topbar__back:active { transform: scale(.94); }

.tabbar {
  display: flex; gap: 4px; padding: 4px; margin-top: 12px;
  background: var(--steel-mist); border-radius: 999px;
}
.tabbar button {
  flex: 1; border: none; background: transparent; padding: 8px 4px; border-radius: 999px;
  font-size: 11px; font-weight: 700; color: var(--steel); cursor: pointer; line-height: 1.3;
}
.tabbar button.active { background: var(--steel); color: #fff; }

.view { padding: 16px 18px 100px; flex: 1; max-width: 720px; width: 100%; margin: 0 auto; }
.view--wide { max-width: 1080px; }

.center-screen {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px; text-align: center; gap: 14px;
}

/* ==================================================================== کارت‌ها */
.card {
  background: var(--paper-raised); border: 1px solid var(--border);
  border-radius: var(--radius-m); box-shadow: var(--shadow-card);
  padding: 16px; margin-bottom: 12px;
}
.card--tap { cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; }
.card--tap:active { transform: scale(.98); }

.select-list { display: flex; flex-direction: column; gap: 10px; }
.select-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--paper-raised); border: 1px solid var(--border);
  border-radius: var(--radius-s); padding: 15px 16px; cursor: pointer;
  font-weight: 600; font-size: 14.5px;
}
.select-row:active { transform: scale(.98); }
.select-row__chevron { color: var(--ink-faint); font-size: 13px; }
.select-row--done {
  background: var(--s5-bg); border-color: transparent; cursor: default; opacity: .85;
}
.select-row--done:active { transform: none; }
.select-row__badge {
  font-size: 11px; font-weight: 700; color: var(--s5); background: #fff;
  border-radius: 999px; padding: 3px 9px;
}

/* ================================================================= دکمه‌ها */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: var(--radius-s); padding: 14px 18px;
  font-weight: 700; font-size: 14.5px; cursor: pointer; width: 100%;
  transition: transform .1s ease, opacity .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--steel); color: #fff; }
.btn--primary:hover { background: var(--steel-deep); }
.btn--ghost { background: var(--paper-raised); color: var(--steel); border: 1px solid var(--border-strong); }
.btn--danger-ghost { background: #fff; color: var(--s1); border: 1px solid var(--s1); }
.btn--sm { padding: 9px 14px; font-size: 13px; width: auto; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ============================================================= دکمه‌ی امتیاز */
.score-btn {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  border: 1.5px solid var(--border); background: var(--paper-raised);
  border-radius: var(--radius-s); padding: 15px 18px; margin-bottom: 10px;
  font-weight: 700; font-size: 14.5px; cursor: pointer; color: var(--ink);
}
.score-btn:active { transform: scale(.97); }
.score-btn__dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.score-btn[data-score="5"] { border-color: var(--s5); }
.score-btn[data-score="5"] .score-btn__dot { background: var(--s5); }
.score-btn[data-score="4"] { border-color: var(--s4); }
.score-btn[data-score="4"] .score-btn__dot { background: var(--s4); }
.score-btn[data-score="3"] { border-color: var(--s3); }
.score-btn[data-score="3"] .score-btn__dot { background: var(--s3); }
.score-btn[data-score="2"] { border-color: var(--s2); }
.score-btn[data-score="2"] .score-btn__dot { background: var(--s2); }
.score-btn[data-score="1"] { border-color: var(--s1); }
.score-btn[data-score="1"] .score-btn__dot { background: var(--s1); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 4px 12px; font-size: 12.5px; font-weight: 800;
}
.badge--s5 { background: var(--s5-bg); color: var(--s5); }
.badge--s4 { background: var(--s4-bg); color: var(--s4); }
.badge--s3 { background: var(--s3-bg); color: var(--s3); }
.badge--s2 { background: var(--s2-bg); color: var(--s2); }
.badge--s1 { background: var(--s1-bg); color: var(--s1); }

/* ===================================================== نشانگر پنج‌مرحله‌ای S */
.stage-tracker { display: flex; gap: 5px; margin-bottom: 10px; }
.stage-tracker__seg {
  flex: 1; height: 7px; border-radius: 999px; background: var(--border);
  position: relative; overflow: hidden;
}
.stage-tracker__seg-fill {
  position: absolute; inset: 0; width: 0%; border-radius: 999px;
  transition: width .25s ease;
}
.stage-tracker__seg[data-stage="1"] .stage-tracker__seg-fill { background: var(--s1); }
.stage-tracker__seg[data-stage="2"] .stage-tracker__seg-fill { background: var(--s2); }
.stage-tracker__seg[data-stage="3"] .stage-tracker__seg-fill { background: var(--s3); }
.stage-tracker__seg[data-stage="4"] .stage-tracker__seg-fill { background: var(--s4); }
.stage-tracker__seg[data-stage="5"] .stage-tracker__seg-fill { background: var(--s5); }

.progress-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-soft); margin-bottom: 18px; }
.progress-meta strong { color: var(--ink); font-weight: 800; }

/* ================================================================= سوال */
.q-eyebrow { font-size: 12px; font-weight: 800; color: var(--steel); letter-spacing: .3px; margin-bottom: 8px; }
.q-text { font-size: 18px; font-weight: 700; line-height: 1.9; margin-bottom: 22px; }

/* ============================================================= فرم/شواهد */
.field-label { font-size: 13px; font-weight: 700; color: var(--ink-soft); margin-bottom: 8px; display: block; }
textarea, input[type=text], input[type=password] {
  width: 100%; border: 1.5px solid var(--border); border-radius: var(--radius-s);
  padding: 13px 14px; font-size: 14px; color: var(--ink); background: var(--paper-raised);
  resize: vertical;
}
.upload-zone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-s);
  padding: 22px; text-align: center; color: var(--ink-soft); cursor: pointer;
  font-size: 13.5px; font-weight: 600;
}
.thumb-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.thumb {
  position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  background: var(--steel-mist); border: 1px solid var(--border);
}
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb__remove {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(28,43,51,.75); color: #fff; border: none; font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ============================================================== داشبورد */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
.stat-card {
  background: var(--paper-raised); border: 1px solid var(--border); border-radius: var(--radius-m);
  padding: 14px 16px; border-right: 4px solid var(--steel);
}
.stat-card__label { font-size: 11.5px; color: var(--ink-soft); font-weight: 700; margin-bottom: 6px; }
.stat-card__value { font-size: 22px; font-weight: 800; letter-spacing: -.5px; }
.stat-card__sub { font-size: 11px; color: var(--ink-faint); margin-top: 3px; }
.stat-card--s5 { border-right-color: var(--s5); }
.stat-card--s1 { border-right-color: var(--s1); }

.section-title {
  font-size: 14.5px; font-weight: 800; margin: 22px 0 12px; display: flex; align-items: center; gap: 8px;
}
.section-title__hint { font-size: 11.5px; font-weight: 500; color: var(--ink-faint); margin-right: auto; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.bar-row__label { flex: 0 0 128px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row__track { flex: 1; height: 20px; background: var(--steel-mist); border-radius: 6px; overflow: hidden; position: relative; }
.bar-row__fill { height: 100%; border-radius: 6px; }
.bar-row__value { flex: 0 0 40px; font-size: 12px; font-weight: 800; text-align: left; }

.heatmap-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-m); background: var(--paper-raised); }
.heatmap { border-collapse: collapse; font-size: 11.5px; min-width: 100%; }
.heatmap th, .heatmap td { padding: 8px 10px; text-align: center; white-space: nowrap; border-bottom: 1px solid var(--border); }
.heatmap th { color: var(--ink-soft); font-weight: 700; position: sticky; top: 0; background: var(--paper-raised); }
.heatmap td:first-child, .heatmap th:first-child { position: sticky; right: 0; background: var(--paper-raised); text-align: right; font-weight: 700; color: var(--ink); z-index: 1; }
.heatmap-cell { font-weight: 800; border-radius: 6px; padding: 4px 8px; display: inline-block; min-width: 34px; }

.chart-wrap { background: var(--paper-raised); border: 1px solid var(--border); border-radius: var(--radius-m); padding: 14px; }

/* ============================================================= لیست‌های ادمین */
.evallist-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.evallist-row:last-child { border-bottom: none; }
.evallist-row__name { font-weight: 700; font-size: 13.5px; }
.evallist-row__meta { font-size: 11.5px; color: var(--ink-soft); margin-top: 2px; }

.media-gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.media-gallery img, .media-gallery video { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); cursor: pointer; }

.kv-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.kv-row:last-child { border-bottom: none; }
.kv-row__k { color: var(--ink-soft); }
.kv-row__v { font-weight: 700; }

/* =========================================================== تنظیمات/آپلود */
.settings-block { margin-bottom: 16px; }
.settings-block__title { font-weight: 800; font-size: 14px; margin-bottom: 4px; }
.settings-block__desc { font-size: 12px; color: var(--ink-soft); margin-bottom: 10px; }
.file-row { display: flex; gap: 8px; align-items: center; }
.file-row input[type=file] { flex: 1; font-size: 12px; }
.log-box {
  background: var(--steel-deep); color: #DCE7EA; border-radius: var(--radius-s);
  padding: 12px 14px; font-size: 12px; line-height: 1.9; margin-top: 12px; max-height: 220px; overflow-y: auto;
  font-family: 'Vazirmatn', monospace;
}

/* ================================================================= عمومی */
.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-soft); }
.empty-state__icon { font-size: 32px; margin-bottom: 10px; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--steel-mist);
  border-top-color: var(--steel); animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--steel-deep); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: 13px; font-weight: 700; box-shadow: var(--shadow-pop); z-index: 60;
  max-width: 90vw; text-align: center;
}
.pill { display: inline-block; background: var(--steel-mist); color: var(--steel); border-radius: 999px; padding: 3px 11px; font-size: 11.5px; font-weight: 700; }
.pill--warn { background: var(--s2-bg); color: var(--s2); }
.pill--ok { background: var(--s5-bg); color: var(--s5); }

/* ============================================= چک‌لیست نظافت (خدمات اداری) */
select {
  width: 100%; border: 1.5px solid var(--border); border-radius: var(--radius-s);
  padding: 12px 14px; font-size: 13.5px; font-weight: 700; color: var(--steel);
  background: var(--paper-raised);
}
.check-row {
  display: flex; align-items: center; gap: 10px; padding: 12px 4px;
  border-bottom: 1px dashed var(--border); font-size: 13.5px; cursor: pointer;
}
.check-row:last-child { border-bottom: none; }
.check-row input[type=checkbox] { width: 19px; height: 19px; accent-color: var(--steel); flex: none; }
.rank-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; background: var(--steel-mist);
  color: var(--steel); font-weight: 800; font-size: 12.5px; flex: none;
}
.rank-badge--top1 { background: var(--s5); color: #fff; }
.rank-badge--top2 { background: var(--s4); color: #fff; }
.rank-badge--top3 { background: var(--s3); color: #fff; }
.leaderboard-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 4px;
  border-bottom: 1px dashed var(--border);
}
.leaderboard-row:last-child { border-bottom: none; }
.copy-chip {
  display: inline-flex; align-items: center; gap: 8px; background: var(--paper-raised);
  border: 1.5px dashed var(--border-strong); border-radius: 999px; padding: 10px 16px;
  font-weight: 800; font-size: 15px; cursor: pointer; color: var(--steel);
}
