@import url('/assets/vazir/font-face.css');

:root {
  --navy: #12233f;
  --navy-2: #1b3358;
  --teal: #14a3a1;
  --teal-2: #0e8a88;
  --teal-soft: #e3f6f5;
  --bg: #f3f5f9;
  --card: #fff;
  --text: #1d2939;
  --muted: #667085;
  --line: #e6e9f0;
  --red: #e5484d;
  --red-soft: #fdecec;
  --amber: #f59e0b;
  --amber-soft: #fff4e0;
  --green: #12a150;
  --green-soft: #e4f7ec;
  --blue: #2f6fed;
  --blue-soft: #e8f0ff;
  --violet: #7c5cff;
  --violet-soft: #efebff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --side: 260px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Vazir, Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.75;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal-2); text-decoration: none; }
a:hover { color: var(--navy); }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.5; color: var(--navy); }
h1 { font-size: 1.35rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1.02rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }
td.ltr, th.ltr { display: table-cell; text-align: right; }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: var(--side); background: var(--navy); color: #cfd8e6; position: fixed; inset: 0 0 0 auto;
  display: flex; flex-direction: column; z-index: 60; transition: transform .25s ease;
}
.side .brand { display: flex; align-items: center; gap: .7rem; padding: 1.2rem 1.2rem 1rem; color: #fff; }
.side .brand img { width: 42px; height: 42px; border-radius: 11px; }
.side .brand b { display: block; font-size: 1rem; }
.side .brand span { font-size: .78rem; color: #8fa3c0; }
.side nav { flex: 1; overflow-y: auto; padding: .4rem .7rem 1rem; }
.side .sec { font-size: .72rem; color: #7f93b2; padding: .9rem .7rem .3rem; }
.side nav a {
  display: flex; align-items: center; gap: .7rem; color: #cfd8e6; padding: .55rem .75rem; border-radius: 10px;
  margin-bottom: 2px; font-size: .92rem;
}
.side nav a svg { width: 19px; height: 19px; flex: none; opacity: .85; }
.side nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side nav a.on { background: var(--teal); color: #fff; box-shadow: 0 4px 14px rgba(20, 163, 161, .35); }
.side nav a .cnt { margin-inline-start: auto; background: var(--red); color: #fff; border-radius: 99px; font-size: .72rem; padding: 0 .45rem; line-height: 1.6; }
.side .me { padding: .9rem 1.1rem; border-top: 1px solid rgba(255, 255, 255, .08); font-size: .85rem; }
.side .me b { color: #fff; display: block; }
.side .me form { display: inline; }
.side .me button, .side .me a { background: none; border: 0; color: #8fa3c0; cursor: pointer; font: inherit; padding: 0; margin-inline-end: .8rem; }
.side .me button:hover, .side .me a:hover { color: #fff; }

.main { flex: 1; margin-right: var(--side); min-width: 0; display: flex; flex-direction: column; }
.top {
  height: 62px; background: rgba(255, 255, 255, .85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: .8rem; padding: 0 1.4rem; position: sticky; top: 0; z-index: 40;
}
.top h1 { margin: 0; font-size: 1.05rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.burger { display: none; background: none; border: 0; padding: .3rem; cursor: pointer; color: var(--navy); }
.burger svg { width: 26px; height: 26px; }
.content { padding: 1.4rem; flex: 1; }
.content.full { padding: 0; }
.veil { display: none; }

@media (max-width: 960px) {
  .side { transform: translateX(100%); }
  body.menu .side { transform: none; box-shadow: -10px 0 40px rgba(0, 0, 0, .25); }
  body.menu .veil { display: block; position: fixed; inset: 0; background: rgba(10, 20, 40, .45); z-index: 55; }
  .main { margin-right: 0; }
  .burger { display: inline-flex; }
  .content { padding: 1rem .8rem; }
  .top { padding: 0 .8rem; }
}

/* ---------- components ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem; margin-bottom: 1.1rem; }
.card > h2, .card > h3 { display: flex; align-items: center; gap: .5rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: .9rem; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 1.1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .g2, .g3 { grid-template-columns: 1fr; } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; } }

.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; display: flex; align-items: center; gap: .9rem; color: var(--text); }
.stat:hover { color: var(--text); transform: translateY(-1px); }
.stat .ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.stat .ic svg { width: 23px; height: 23px; }
.stat b { font-size: 1.45rem; display: block; line-height: 1.3; color: var(--navy); }
.stat span { color: var(--muted); font-size: .84rem; }
.ic.teal { background: var(--teal-soft); color: var(--teal-2); }
.ic.green { background: var(--green-soft); color: var(--green); }
.ic.amber { background: var(--amber-soft); color: #c27c06; }
.ic.red { background: var(--red-soft); color: var(--red); }
.ic.blue { background: var(--blue-soft); color: var(--blue); }
.ic.violet { background: var(--violet-soft); color: var(--violet); }
@media (max-width: 700px) { .stat { padding: .8rem; gap: .6rem; } .stat .ic { width: 38px; height: 38px; } .stat b { font-size: 1.2rem; } }

.hero {
  border-radius: 18px; overflow: hidden; position: relative; min-height: 190px; margin-bottom: 1.1rem; color: #fff;
  background: var(--navy) url('/img/dashboard-banner.jpg') left center / cover no-repeat; box-shadow: var(--shadow);
}
.hero .hero-in { position: relative; padding: 1.6rem 1.8rem; max-width: 560px; margin-right: 0; }
.hero::after { content: ''; position: absolute; inset: 0; background: linear-gradient(270deg, rgba(18, 35, 63, .92) 0%, rgba(18, 35, 63, .55) 55%, rgba(18, 35, 63, 0) 100%); }
.hero .hero-in { z-index: 1; }
.hero h2 { color: #fff; font-size: 1.3rem; }
.hero p { color: #d4deec; margin: 0 0 1rem; }
@media (max-width: 700px) { .hero .hero-in { padding: 1.2rem; } .hero::after { background: rgba(18, 35, 63, .78); } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; border: 1px solid transparent; cursor: pointer;
  font: inherit; font-size: .9rem; padding: .5rem 1rem; border-radius: 10px; background: var(--teal); color: #fff; line-height: 1.6;
  transition: background .15s, box-shadow .15s; white-space: nowrap;
}
.btn:hover { background: var(--teal-2); color: #fff; box-shadow: 0 4px 12px rgba(20, 163, 161, .3); }
.btn svg { width: 17px; height: 17px; }
.btn.navy { background: var(--navy); } .btn.navy:hover { background: var(--navy-2); }
.btn.light { background: #fff; color: var(--navy); border-color: var(--line); } .btn.light:hover { background: #f7f9fc; box-shadow: none; }
.btn.red { background: var(--red); } .btn.red:hover { background: #c93a3f; }
.btn.green { background: var(--green); }
.btn.amber { background: var(--amber); }
.btn.sm { padding: .3rem .7rem; font-size: .82rem; border-radius: 8px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: wait; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.badge { display: inline-block; padding: .05rem .6rem; border-radius: 99px; font-size: .78rem; font-weight: 500; white-space: nowrap; }
.b-green { background: var(--green-soft); color: var(--green); }
.b-red { background: var(--red-soft); color: var(--red); }
.b-amber { background: var(--amber-soft); color: #b46f00; }
.b-blue { background: var(--blue-soft); color: var(--blue); }
.b-violet { background: var(--violet-soft); color: var(--violet); }
.b-gray { background: #eef0f4; color: #556070; }
.b-teal { background: var(--teal-soft); color: var(--teal-2); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-inline-end: .35rem; vertical-align: middle; }
.st-moving { background: var(--green); } .st-stopped { background: var(--blue); } .st-offline { background: var(--amber); } .st-nodata { background: var(--red); }

/* tables */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -1.2rem; padding: 0 1.2rem; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: right; color: var(--muted); font-weight: 500; font-size: .8rem; padding: .55rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfd; }
.tbl td { padding: .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #fafcff; }
.tbl .num { font-variant-numeric: tabular-nums; }
.plate {
  display: inline-flex; align-items: center; gap: .25rem; border: 1.5px solid #2b3a55; border-radius: 6px; padding: 0 .45rem;
  font-weight: 700; color: #111; background: #fff; white-space: nowrap; font-size: .88rem; line-height: 1.7; overflow: hidden;
}
.plate::before { content: ''; width: 6px; align-self: stretch; background: #1d4ed8; margin: 0 .3rem 0 -.45rem; order: 9; }

/* responsive table -> cards */
@media (max-width: 760px) {
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .5rem .8rem; margin-bottom: .7rem; }
  table.cards td { border: 0; padding: .25rem 0; display: flex; justify-content: space-between; gap: 1rem; text-align: left; }
  table.cards td::before { content: attr(data-l); color: var(--muted); font-size: .8rem; text-align: right; flex: none; }
  table.cards td.full { display: block; } table.cards td.full::before { display: none; }
  table.cards td.ltr { direction: rtl; }
  .tbl-wrap { margin: 0; padding: 0; }
  table.cards tbody tr:hover { background: #fff; }
}

/* forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1.1rem; }
.form-grid .wide { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
label.f { display: block; }
label.f > span { display: block; font-size: .85rem; color: #344054; margin-bottom: .3rem; font-weight: 500; }
label.f > span i { color: var(--red); font-style: normal; }
.in, select.in, textarea.in {
  width: 100%; font: inherit; font-size: .92rem; padding: .55rem .8rem; border: 1px solid #d0d5dd; border-radius: 10px; background: #fff; color: var(--text);
  transition: border-color .15s, box-shadow .15s; min-height: 42px;
}
.in:focus { outline: 0; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(20, 163, 161, .15); }
textarea.in { min-height: 110px; resize: vertical; }
.hint { font-size: .78rem; color: var(--muted); margin-top: .25rem; display: block; }
.err { color: var(--red); font-size: .82rem; margin-top: .25rem; display: block; }
.check { display: inline-flex; align-items: center; gap: .45rem; cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--teal); }
.plate-input { display: flex; gap: .4rem; align-items: center; direction: rtl; }
.plate-input .in { text-align: center; padding: .55rem .3rem; }
.plate-input .p2 { width: 64px; } .plate-input .pl { width: 74px; } .plate-input .p3 { width: 80px; } .plate-input .p4 { width: 64px; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.filters .in { width: auto; min-width: 150px; }
@media (max-width: 700px) { .filters > * { flex: 1 1 140px; } .filters .in { min-width: 0; width: 100%; } }

.alert { border-radius: 12px; padding: .75rem 1rem; margin-bottom: 1rem; display: flex; gap: .6rem; align-items: flex-start; }
.alert.ok { background: var(--green-soft); color: #0b6b36; }
.alert.bad { background: var(--red-soft); color: #a3262b; }
.alert.info { background: var(--blue-soft); color: #1c4fb8; }
.alert.warn { background: var(--amber-soft); color: #8a5300; }
.alert ul { margin: 0; padding-right: 1.1rem; }

.chips { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip { padding: .3rem .85rem; border-radius: 99px; background: #fff; border: 1px solid var(--line); color: var(--text); font-size: .85rem; }
.chip b { color: var(--navy); margin-inline-start: .25rem; }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); } .chip.on b { color: #fff; }

.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty img { width: 240px; max-width: 70%; display: block; margin: 0 auto 1rem; border-radius: 12px; }

.pager { display: flex; gap: .3rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.pager a, .pager span { min-width: 36px; text-align: center; padding: .3rem .6rem; border-radius: 8px; background: #fff; border: 1px solid var(--line); color: var(--text); }
.pager .on { background: var(--teal); border-color: var(--teal); color: #fff; }
.pager .off { opacity: .45; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.2rem; font-size: .92rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 500; }

/* chat */
.thread { display: flex; flex-direction: column; gap: .9rem; }
.msg { max-width: 82%; padding: .8rem 1rem; border-radius: 14px; background: #f2f4f7; align-self: flex-start; }
.msg.mine { background: var(--teal-soft); align-self: flex-end; }
.msg.staff { background: #eef3ff; }
.msg .who { font-size: .78rem; color: var(--muted); margin-bottom: .2rem; display: flex; gap: .6rem; }
.msg p { margin: 0; white-space: pre-wrap; word-wrap: break-word; }
.msg .att { display: inline-flex; gap: .3rem; align-items: center; margin-top: .5rem; font-size: .85rem; }
@media (max-width: 700px) { .msg { max-width: 95%; } }

/* map */
.map-page { position: relative; height: calc(100vh - 62px); display: flex; }
.map-page #map { flex: 1; height: 100%; }
.map-list { width: 330px; background: #fff; border-left: 1px solid var(--line); display: flex; flex-direction: column; z-index: 5; }
.map-list .head { padding: .8rem; border-bottom: 1px solid var(--line); }
.map-list .rows { overflow-y: auto; flex: 1; }
.map-list .row { display: flex; align-items: center; gap: .6rem; padding: .55rem .8rem; border-bottom: 1px solid #f0f2f5; cursor: pointer; }
.map-list .row:hover, .map-list .row.on { background: var(--teal-soft); }
.map-list .row .t { flex: 1; min-width: 0; }
.map-list .row .t small { display: block; color: var(--muted); font-size: .76rem; }
.map-list .row .sp { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.leaflet-container, .map-wrap { isolation: isolate; }
.map-tools { position: absolute; top: .8rem; left: .8rem; z-index: 500; display: flex; gap: .4rem; flex-wrap: wrap; }
.map-tools .chip { box-shadow: var(--shadow); cursor: pointer; }
.map-toggle { display: none; }
@media (max-width: 960px) {
  .map-list { position: absolute; inset: auto 0 0 0; width: 100%; height: 46%; border: 0; border-radius: 18px 18px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .15); transform: translateY(calc(100% - 54px)); transition: transform .25s; }
  .map-list.open { transform: none; }
  .map-toggle { display: flex; justify-content: center; padding: .4rem; cursor: pointer; color: var(--navy); font-weight: 600; font-size: .9rem; }
  .map-toggle::before { content: ''; width: 44px; height: 4px; border-radius: 4px; background: #c9cfd9; position: absolute; top: 6px; }
  .map-page { height: calc(100vh - 62px); height: calc(100dvh - 62px); }
}
.veh-icon { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); display: grid; place-items: center; }
.veh-icon svg { width: 16px; height: 16px; color: #fff; }
.veh-icon.moving { background: var(--green); } .veh-icon.stopped { background: var(--blue); } .veh-icon.offline { background: var(--amber); } .veh-icon.nodata { background: var(--red); }
.veh-label { background: rgba(18, 35, 63, .88); color: #fff; border: 0; border-radius: 6px; padding: 0 .4rem; font-family: Vazir, Tahoma; font-size: 11px; box-shadow: none; }
.veh-label::before { display: none; }
.leaflet-popup-content { font-family: Vazir, Tahoma; direction: rtl; text-align: right; font-size: 13px; line-height: 1.8; min-width: 190px; }
.leaflet-popup-content .actions { margin-top: .4rem; }
.leaflet-container { font-family: Vazir, Tahoma; }
.marker-cluster div { font-family: Vazir, Tahoma; }

.report-map { height: 460px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
@media (max-width: 700px) { .report-map { height: 340px; } }
.mini-map { height: 260px; border-radius: 12px; overflow: hidden; }
.loading { display: inline-block; width: 18px; height: 18px; border: 2.5px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1.05fr; background: #fff; }
.login .art { background: var(--navy) url('/img/login-hero.jpg') center / cover; position: relative; }
.login .art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(18, 35, 63, .85), rgba(18, 35, 63, 0) 50%); }
.login .art .cap { position: absolute; bottom: 2.2rem; right: 2.2rem; left: 2.2rem; color: #fff; z-index: 1; }
.login .art .cap h2 { color: #fff; font-size: 1.45rem; }
.login .art .cap p { color: #c9d5e6; margin: 0; }
.login .box { display: flex; align-items: center; justify-content: center; padding: 2rem 1.2rem; }
.login form { width: 100%; max-width: 380px; }
.login .logo { display: flex; align-items: center; gap: .8rem; margin-bottom: 1.8rem; }
.login .logo img { width: 54px; height: 54px; border-radius: 14px; }
.login .logo b { font-size: 1.15rem; color: var(--navy); display: block; }
.login .logo span { color: var(--muted); font-size: .85rem; }
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login .art { min-height: 210px; background-position: center 65%; }
  .login .art .cap { bottom: 1rem; right: 1.2rem; left: 1.2rem; }
  .login .art .cap h2 { font-size: 1.1rem; margin: 0; } .login .art .cap p { font-size: .85rem; }
  .login .box { align-items: flex-start; }
}

/* invoice */
.invoice { background: #fff; max-width: 900px; margin: 0 auto; padding: 2rem; border-radius: 12px; box-shadow: var(--shadow); }
.invoice .ih { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; border-bottom: 2px solid var(--navy); padding-bottom: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.invoice .ih img { width: 56px; height: 56px; border-radius: 12px; }
.invoice table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.invoice th, .invoice td { border: 1px solid #d8dde6; padding: .4rem .5rem; text-align: center; }
.invoice th { background: #f2f5f9; }
.invoice .sum td { font-weight: 700; }
.invoice .parties { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.invoice .parties div { background: #f7f9fc; border-radius: 10px; padding: .7rem 1rem; font-size: .9rem; }
@media (max-width: 700px) { .invoice { padding: 1rem; } .invoice .parties { grid-template-columns: 1fr; } }
@media print {
  body { background: #fff; }
  .side, .top, .no-print, .veil { display: none !important; }
  .main { margin: 0; } .content { padding: 0; }
  .invoice { box-shadow: none; padding: 0; max-width: none; }
}

.persian-datepicker-container { font-family: Vazir, Tahoma !important; }
.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: .6rem 1.2rem; border-radius: 10px; z-index: 9999; box-shadow: var(--shadow); }

.g-side { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
@media (max-width: 900px) { .g-side { grid-template-columns: 1fr; } .g-side > .card:last-child img { max-width: 260px; } }
