/* نقشه تعاملی مناطق تهران — استایل اصلی (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: #f1f5f9;
  --card: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #15803d;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Vazirmatn', Tahoma, 'Segoe UI', sans-serif;
}

/* ---------- چیدمان کلی ---------- */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}
.sidebar {
  width: 380px;
  min-width: 320px;
  background: var(--card);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.map-wrap { flex: 1; position: relative; }
#map { position: absolute; inset: 0; background: #eef2f7; }

.side-head {
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--line);
}
.side-head h1 { margin: 0; font-size: 18px; font-weight: 700; }
.side-head .subtitle { margin: 6px 0 0; font-size: 12px; color: var(--muted); line-height: 1.8; }

.side-foot {
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}

/* ---------- ابزارها ---------- */
.toolbar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.stats { font-size: 12px; color: var(--muted); line-height: 1.9; }
.stats b { color: var(--ink); }

/* ---------- دکمه‌ها ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-danger-ghost { color: var(--danger); border-color: #fecaca; }
.btn-danger-ghost:hover { background: #fef2f2; border-color: #fca5a5; }
.btn:disabled { opacity: .6; cursor: wait; }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.switch input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ---------- کارت‌های مناطق ---------- */
.cards { flex: 1; overflow-y: auto; padding: 10px 14px 16px; }
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  transition: border-color .2s, box-shadow .2s;
}
.card.flash { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.card-head .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.12);
  flex: none;
}
.card-head .card-title { font-weight: 700; font-size: 14px; }
.card-head .status { margin-inline-start: auto; font-size: 11px; color: var(--muted); }
.card-head .status.saving { color: #b45309; }
.card-head .status.saved { color: var(--ok); }
.card-head .status.failed { color: var(--danger); }

.card-grid {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 8px;
}
.card label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
  color: var(--muted);
}
.card-grid label:first-child { justify-content: center; }
.card input[type="text"] {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  width: 100%;
  background: #fff;
}
.card input[type="text"]:focus { outline: 2px solid rgba(37,99,235,.25); border-color: var(--accent); }
.card input[type="color"] {
  width: 46px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
.card .card-label { margin-top: 8px; }

/* ---------- برچسب روی نقشه ---------- */
.district-tip {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}
.district-tip::before { display: none; }
.dlabel {
  direction: rtl;
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  background: rgba(255, 255, 255, .93);
  border: 2px solid #64748b;
  border-radius: 9px;
  padding: 3px 9px;
  text-align: center;
  line-height: 1.5;
  white-space: nowrap;
  color: #111827;
}
.dlabel b { font-size: 14px; }
.dlabel span { display: block; font-size: 11.5px; }
.dlabel .pct { color: #b45309; font-weight: 700; }
.dlabel .val { color: #1d4ed8; }
.dlabel .lbl { color: #374151; }

/* ---------- مودال خروجی ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.modal-overlay[hidden] { display: none; }
.modal {
  width: min(440px, 92vw);
  background: #fff;
  border-radius: 16px;
  padding: 22px 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,.25);
}
.modal h2 { margin: 0 0 14px; font-size: 17px; }
.modal-body { display: flex; flex-direction: column; gap: 12px; }
.modal .field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.modal input[type="text"], .modal select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
}
.modal input[type="text"]:focus, .modal select:focus { outline: 2px solid rgba(37,99,235,.25); border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-start; gap: 8px; margin-top: 18px; }

/* ---------- پیام شناور ---------- */
.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: #111827;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 3000;
  box-shadow: 0 10px 24px rgba(0,0,0,.3);
}
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* ---------- صفحه نصب ---------- */
.setup-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.setup-box {
  max-width: 520px;
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 10px 30px rgba(0,0,0,.08);
  text-align: center;
  line-height: 2;
}
.setup-box h1 { font-size: 20px; margin: 0 0 12px; }
.setup-box code { background: #f1f5f9; padding: 2px 8px; border-radius: 6px; direction: ltr; display: inline-block; }
.setup-box .btn { margin-top: 10px; }

/* ---------- لودر ---------- */
.spinner {
  width: 18px; height: 18px;
  border: 3px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  vertical-align: middle;
  margin-inline-start: 8px;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- ریسپانسیو ---------- */
@media (max-width: 860px) {
  .app { flex-direction: column; height: auto; overflow: auto; }
  .sidebar { width: 100%; min-width: 0; border-left: none; border-bottom: 1px solid var(--line); }
  .map-wrap { min-height: 55vh; }
  .cards { max-height: none; }
}
