/* ===== سامانه برنامه‌ریزی مسیر ویزیتور — professional navigation look ===== */
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/vazirmatn.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #eef1f4;
  --panel: #ffffff;
  --ink: #1a2430;
  --muted: #64748b;
  --line: #dbe2ea;
  --primary: #166534;
  --primary-dark: #14532d;
  --primary-soft: #e8f3ec;
  --accent: #0e7490;
  --warn: #b45309;
  --danger: #b91c1c;
  --ok: #15803d;
  --amber: #d97706;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .10), 0 1px 2px rgba(15, 23, 42, .06);
  --header-h: 62px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Vazirmatn', 'Tahoma', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.7;
  overflow: hidden;
}
h1, h2, h3 { margin: 0; font-weight: 700; }
button { font-family: inherit; }

/* ---------- top bar ---------- */
.topbar {
  height: var(--header-h);
  background: linear-gradient(180deg, #10241a 0%, #143526 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  gap: 12px;
  position: relative;
  z-index: 1200;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand h1 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand p { margin: 0; font-size: 11px; color: #a7c4b5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: rgba(255,255,255,.12); color: #e2e8f0;
  white-space: nowrap;
}
.chip.ok { background: rgba(34,197,94,.25); color: #bbf7d0; }
.chip.bad { background: rgba(239,68,68,.25); color: #fecaca; }

/* ---------- layout ---------- */
.layout {
  display: flex;
  height: calc(100vh - var(--header-h));
  direction: rtl;
}
.panel {
  width: 400px;
  min-width: 340px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 1100;
}
.panel-scroll { overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.map-wrap { flex: 1; position: relative; min-width: 0; }
#map, #routeMap { position: absolute; inset: 0; background: #dde3ea; }

/* ---------- cards ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.card-title { font-size: 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; color: var(--ink); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.card-head .card-title { margin-bottom: 0; }
.step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 12px; flex-shrink: 0;
}

/* ---------- controls ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: block; font-size: 12.5px; color: var(--muted); margin: 8px 0; }
.field input, .field select, .select, .input {
  width: 100%; margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit; font-size: 13.5px;
  background: #fff; color: var(--ink);
}
.select[multiple] { margin-top: 4px; }
.select:focus, .input:focus { outline: 2px solid rgba(22,101,52,.35); border-color: var(--primary); }
.select:disabled, .input:disabled { background: #f1f5f9; color: var(--muted); }

.checkline { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 8px 0; cursor: pointer; }
.checkline input { width: 16px; height: 16px; accent-color: var(--primary); }

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn:hover { background: #f8fafc; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: #d1e7db; }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.1); }
.btn-lg { width: 100%; padding: 12px; font-size: 14.5px; margin-top: 10px; }
.btn-mini { padding: 3px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; margin-top: 8px; }
.btn-od { width: 100%; }
.btn-od.active { outline: 2px solid var(--accent); background: #ecfeff; }
.btn-danger { color: var(--danger); border-color: #fecaca; }

/* ---------- type chips ---------- */
.type-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.type-chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
}
.type-chip .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.type-chip.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }

/* ---------- status & results ---------- */
.status-line {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  background: #f1f5f9;
  color: var(--muted);
  border: 1px dashed var(--line);
}
.status-line.ok { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.status-line.err { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.status-line .bar { height: 5px; border-radius: 3px; background: var(--line); margin-top: 7px; overflow: hidden; }
.status-line .bar > i { display: block; height: 100%; background: var(--primary); transition: width .4s; }

.result-count { font-size: 15px; font-weight: 700; color: var(--primary-dark); margin-top: 10px; }
.result-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.coverage-note { font-size: 11.5px; color: var(--muted); background: #f8fafc; border-radius: 6px; padding: 6px 8px; margin-top: 8px; border: 1px solid var(--line); }

/* ---------- POI list ---------- */
.list-actions { display: flex; gap: 6px; }
.poi-list { display: flex; flex-direction: column; gap: 7px; max-height: 340px; overflow-y: auto; padding-left: 4px; }
.poi-item {
  display: flex; align-items: flex-start; gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  cursor: pointer;
  background: #fff;
}
.poi-item:hover { background: #f8fafc; }
.poi-item.selected { border-color: var(--primary); background: var(--primary-soft); }
.poi-item .poi-dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.poi-item .poi-body { min-width: 0; flex: 1; }
.poi-item .poi-name { font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.poi-item .poi-sub { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.poi-item .brand-tag {
  font-size: 10.5px; font-weight: 700;
  background: #eef2ff; color: #3730a3;
  border-radius: 5px; padding: 1px 6px; margin-inline-start: 6px;
  white-space: nowrap;
}
.poi-item input[type=checkbox] { margin-top: 5px; width: 15px; height: 15px; accent-color: var(--primary); }

/* ---------- OD ---------- */
.od-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.od-grid .btn-od:first-child, .od-grid .btn-od:nth-child(2) { grid-column: auto; }
.od-grid .checkline { grid-column: 1 / -1; }
.od-grid .btn-ghost { grid-column: 1 / -1; }
.od-info { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.od-line { font-size: 12.5px; }
.od-line b { color: var(--ink); }
.od-line .addr { color: var(--muted); display: block; font-size: 11.5px; }
.muted { color: var(--muted); }

/* ---------- plan grid ---------- */
.plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.plan-grid label { font-size: 12px; color: var(--muted); display: block; }
.workdays { margin-top: 10px; }
.workdays-label { font-size: 12px; color: var(--muted); }
.workday-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.wday-chip {
  border: 1px solid var(--line); background: #fff;
  border-radius: 999px; padding: 3px 12px;
  font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.wday-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- routes section ---------- */
.routes-summary { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.route-cards { display: flex; flex-direction: column; gap: 8px; }
.route-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.route-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.route-card .rc-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 13.5px; }
.route-card .rc-badge {
  font-size: 11px; font-weight: 700;
  background: var(--primary-soft); color: var(--primary-dark);
  border-radius: 6px; padding: 2px 8px;
}
.route-card .rc-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.route-card .rc-stops { font-size: 11.5px; color: var(--muted); margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- providers ---------- */
.provider-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.provider-row:last-child { border-bottom: none; }
.provider-row .p-name { font-weight: 700; width: 130px; flex-shrink: 0; }
.provider-row .p-caps { color: var(--muted); font-size: 11px; flex: 1; }
.provider-row .p-meta { font-size: 11px; color: var(--muted); white-space: nowrap; }
.provider-caps { display: block; font-size: 10px; color: var(--muted); font-weight: 400; }
.provider-legend { font-size: 11px; color: var(--muted); padding: 4px 0 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.p-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.p-dot.ok { background: #22c55e; }
.p-dot.warn { background: #f59e0b; }
.p-dot.bad { background: #ef4444; }
.p-dot.off { background: #cbd5e1; }
.provider-parts { font-size: 10.5px; color: var(--muted); margin-top: 2px; }

/* ---------- map hint ---------- */
.map-hint {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(14, 116, 144, .95); color: #fff;
  padding: 8px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 700;
  z-index: 1000; box-shadow: 0 4px 14px rgba(0,0,0,.25);
  white-space: nowrap;
}
.map-bbox-badge {
  position: absolute; bottom: 24px; left: 12px;
  background: rgba(14,116,144,.9); color: #fff;
  font-size: 11.5px; padding: 4px 10px; border-radius: 6px;
  z-index: 1000;
}
.map-legend {
  position: absolute; bottom: 24px; right: 12px;
  background: rgba(255,255,255,.95); color: var(--ink);
  font-size: 11.5px; padding: 5px 10px; border-radius: 6px;
  box-shadow: var(--shadow); z-index: 1000;
}

/* detected chains */
.detected-chains { margin-top: 8px; }
.detected-chains .dc-title { font-size: 11.5px; color: var(--muted); margin-bottom: 5px; }
.dc-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid #e0e7ff; background: #eef2ff; color: #3730a3;
  border-radius: 999px; padding: 3px 10px;
  font-size: 11.5px; font-weight: 600; margin: 0 6px 5px 0;
}
.dc-chip button {
  border: none; background: #3730a3; color: #fff;
  border-radius: 999px; font-size: 10.5px; font-weight: 700;
  padding: 1px 8px; cursor: pointer;
}
.dc-chip button:hover { background: #312e81; }
.dc-chip.added { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }

/* ---------- route view ---------- */
.route-view { display: flex; height: calc(100vh - var(--header-h)); direction: rtl; }
.route-side {
  width: 460px; min-width: 380px;
  background: #fff; border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  z-index: 1100;
}
.route-side-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.route-side-head h1 { font-size: 15px; }
.route-side-scroll { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.route-map-wrap { flex: 1; position: relative; min-width: 0; }

.route-summary {
  background: var(--primary-soft);
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
}
.route-summary .rs-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; text-align: center; }
.route-summary .rs-item b { display: block; font-size: 15px; color: var(--primary-dark); }
.route-summary .rs-item span { font-size: 11px; color: var(--muted); }

/* timeline */
.timeline { position: relative; padding-right: 22px; }
.timeline::before {
  content: ''; position: absolute; right: 7px; top: 8px; bottom: 8px;
  width: 2px; background: var(--line);
}
.tl-item { position: relative; padding: 6px 0 10px; }
.tl-item::before {
  content: ''; position: absolute; right: -20px; top: 10px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent);
}
.tl-item.stop::before { border-color: var(--primary); }
.tl-item.origin::before { border-color: #22c55e; }
.tl-item.dest::before { border-color: var(--danger); }
.tl-leg {
  font-size: 11.5px; color: var(--muted);
  background: #f8fafc; border: 1px solid var(--line);
  border-radius: 7px; padding: 5px 9px; margin-bottom: 6px;
}
.tl-leg b { color: var(--ink); }
.tl-visit {
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 12.5px;
}
.tl-visit .tv-name { font-weight: 700; font-size: 13px; }
.tl-visit .tv-eta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.tl-visit .tv-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 11px; font-weight: 700;
  margin-inline-end: 6px;
}

/* weather */
.weather-card {
  background: linear-gradient(135deg, #ecfeff, #f0fdf4);
  border: 1px solid #a5f3fc;
  border-radius: 10px;
  padding: 12px 14px;
}
.weather-card .wc-head { display: flex; align-items: center; gap: 12px; }
.weather-card .wc-icon { font-size: 34px; line-height: 1; }
.weather-card .wc-temp { font-size: 24px; font-weight: 800; }
.weather-card .wc-label { font-size: 12.5px; color: var(--muted); }
.weather-card .wc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; text-align: center; }
.weather-card .wc-cell b { display: block; font-size: 13px; }
.weather-card .wc-cell span { font-size: 10.5px; color: var(--muted); }
.weather-card .wc-src { font-size: 10.5px; color: var(--muted); margin-top: 8px; }

/* compare */
.compare-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fff; }
.compare-card h3 { font-size: 13.5px; margin-bottom: 8px; }
.compare-card table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.compare-card td, .compare-card th { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--line); }
.compare-card th { color: var(--muted); font-weight: 600; font-size: 11.5px; }
.compare-card .better { color: var(--ok); font-weight: 700; }
.compare-card .worse { color: var(--danger); font-weight: 700; }

/* toasts */
.toast-wrap { position: fixed; bottom: 18px; inset-inline-start: 18px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #0f172a; color: #fff;
  padding: 10px 16px; border-radius: 9px;
  font-size: 13px; max-width: 380px;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
  animation: toast-in .25s ease;
}
.toast.ok { background: #14532d; }
.toast.err { background: #7f1d1d; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.panel-foot { padding-top: 4px; }
.panel-foot p { font-size: 11px; margin: 0; }

/* Leaflet RTL fixes & marker styles */
.leaflet-container { font-family: 'Vazirmatn', sans-serif; }
.leaflet-popup-content { font-family: 'Vazirmatn', sans-serif; direction: rtl; text-align: right; font-size: 12.5px; }
.mk { display: block; }
.mk-circle {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2.5px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.mk-circle.selected { outline: 3px solid rgba(14,116,144,.55); }
.mk-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800;
}
.mk-od {
  width: 26px; height: 26px; border-radius: 50%;
  color: #fff; font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 2.5px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.45);
}
.cluster-icon {
  background: rgba(22,101,52,.85);
  color: #fff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px;
  border: 3px solid rgba(255,255,255,.8);
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}

/* ---------- responsive ---------- */
@media (max-width: 920px) {
  body { overflow: auto; }
  .layout { flex-direction: column; height: auto; }
  .map-wrap { height: 52vh; min-height: 320px; order: -1; }
  .panel { width: 100%; min-width: 0; border-left: none; border-top: 1px solid var(--line); }
  .panel-scroll { max-height: none; }
  .route-view { flex-direction: column; height: auto; }
  .route-map-wrap { height: 46vh; min-height: 300px; order: -1; }
  .route-side { width: 100%; min-width: 0; border-left: none; border-top: 1px solid var(--line); }
  .brand p { display: none; }
  .brand h1 { font-size: 13.5px; }
  #trafficChip { display: none; }
  .route-summary .rs-grid { grid-template-columns: repeat(2, 1fr); }
  .weather-card .wc-grid { grid-template-columns: repeat(2, 1fr); }
}
