/*
  سیستم طراحی این پنل عیناً از فروشگاه (5darsad-shop/src/styles/tokens.css) گرفته شده
  تا مدیر/انباردار/پیک همون حس‌وحال برند رو ببینن، نه یه ابزار جدا و اداری.
*/
@font-face {
  font-family: "Vazirmatn";
  src: local("Vazirmatn"), local("Vazirmatn UI"),
       url("assets/fonts/Vazirmatn-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --green: #06604E;
  --green-dark: #045743;
  --green-light: #E5F2EF;
  --navy: #101050;
  --black: #111111;
  --gray: #8A8D99;
  --border: #E7EBF1;
  --card-border: #ECEFF3;
  --badge-red: #EF3340;
  --badge-red-light: #FDECEE;
  --badge-amber: #B8860B;
  --badge-amber-light: #FBF3DF;
  --bg: #F8F9FD;
  --white: #FFFFFF;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --font: "Vazirmatn", "IRANSansX", system-ui, "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif;
  --shadow-card: 0 1px 2px rgba(16, 16, 80, 0.04);
  --shadow-bar: 0 -2px 12px rgba(16, 16, 80, 0.06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-synthesis: none;
  background: var(--bg);
  color: var(--black);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4, p { margin: 0; }
img { display: block; max-width: 100%; }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* ───────────────────────── هدر بالا ───────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}
.topbar__brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar__logo { width: 30px; height: 30px; object-fit: contain; flex: none; border-radius: 8px; }
.topbar__title { display: flex; flex-direction: column; min-width: 0; }
.topbar h1 {
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar__role {
  font-size: 11px;
  font-weight: 600;
  color: var(--green);
}
.topbar__side { display: flex; align-items: center; gap: 10px; flex: none; }
.topbar .meta { font-size: 12px; color: var(--gray); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }

.btn-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--navy);
  font: 600 12px/1 var(--font);
  white-space: nowrap;
}
.btn-logout svg { width: 15px; height: 15px; flex: none; }
.btn-logout:active { background: var(--bg); }

/* ───────────────────────── ساختار صفحه ───────────────────────── */
.container { max-width: 1000px; margin: 0 auto; padding: 16px; }
.container.narrow { max-width: 480px; }

.card {
  background: var(--white);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 16px;
  margin-bottom: 14px;
}

/* ───────────────────────── تب‌ها (سبک نوار دسته‌بندی فروشگاه) ───────────────────────── */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  flex: none;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--navy);
  font: 600 13px/1 var(--font);
  white-space: nowrap;
}
.tab-btn.active { background: var(--green); color: #fff; border-color: var(--green); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade-in .15s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ───────────────────────── جدول (دسکتاپ) ───────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--card-border); }
th { color: var(--gray); font-weight: 600; font-size: 11.5px; text-transform: none; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

input[type="text"], input[type="number"], input[type="email"], input[type="password"], select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  background: var(--white);
  color: var(--black);
}
input:focus, select:focus { outline: none; border-color: var(--green); }
input.small { width: 100px; height: 34px; }
label { display: block; font-size: 12.5px; color: var(--gray); font-weight: 600; margin: 12px 0 5px; }

/* ───────────────────────── دکمه‌ها ───────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  padding: 0 20px;
  font: 600 14px/1 var(--font);
}
.btn-primary:active { background: var(--green-dark); }
.btn-primary:disabled { opacity: .5; }
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0 14px;
  color: var(--navy);
  font: 600 12.5px/1 var(--font);
}
.btn-secondary:active { background: var(--bg); }
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  background: var(--badge-red-light);
  color: var(--badge-red);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  padding: 0 16px;
  font: 600 13px/1 var(--font);
}
.btn-danger:active { opacity: .8; }
@media (hover: hover) {
  .btn-primary:hover { background: var(--green-dark); }
  .btn-secondary:hover { background: var(--bg); }
  .btn-danger:hover { opacity: .85; }
  .tab-btn:not(.active):hover { background: var(--bg); }
}

/* ───────────────────────── نشان‌ها (وضعیت) ───────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 700;
  background: var(--green-light);
  color: var(--green);
  white-space: nowrap;
}
.badge.gray { background: #F1F2F6; color: var(--gray); }
.badge.danger { background: var(--badge-red-light); color: var(--badge-red); }
.badge.amber { background: var(--badge-amber-light); color: var(--badge-amber); }

/* ───────────────────────── کارت‌های آمار (پروفایل مشتری) ───────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.stat-card .label { font-size: 11.5px; color: var(--gray); margin-bottom: 4px; }
.stat-card .value { font-size: 17px; font-weight: 700; color: var(--navy); }
.stat-card .value.green { color: var(--green); }

/* ───────────────────────── چت پشتیبانی ───────────────────────── */
.chat-thread { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; max-height: 420px; overflow-y: auto; padding: 4px; }
.chat-msg {
  max-width: 80%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.6;
}
.chat-msg .meta { display: block; font-size: 10.5px; margin-top: 4px; opacity: .7; }
.chat-msg.from-user { align-self: flex-start; background: var(--bg); color: var(--black); border-bottom-left-radius: 4px; }
.chat-msg.from-agent { align-self: flex-end; background: var(--green); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.from-bot { align-self: flex-start; background: #F1F2F6; color: var(--gray); border-bottom-left-radius: 4px; }
.reply-box { display: flex; gap: 8px; align-items: flex-end; }
.reply-box textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  resize: vertical;
}
.reply-box textarea:focus { outline: none; border-color: var(--green); }

.error-msg { color: var(--badge-red); font-size: 12.5px; margin-top: 8px; }
.empty-msg, .loading-msg { color: var(--gray); text-align: center; padding: 40px 16px; font-size: 13.5px; }

/* ───────────── موبایل — انبار/پیک: کارت سفارش ───────────── */
.order-card {
  background: var(--white);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 16px;
  margin-bottom: 12px;
}
.order-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.order-card h3 { font-size: 15px; color: var(--navy); font-weight: 700; }
.order-card .total { font-size: 15px; font-weight: 700; color: var(--green); white-space: nowrap; }
.order-card .row { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; margin: 6px 0; color: var(--gray); }
.order-card .row span:last-child { color: var(--black); font-weight: 600; }
.order-card .address {
  display: flex;
  gap: 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin: 10px 0;
  line-height: 1.6;
}
.order-card .address svg { flex: none; width: 16px; height: 16px; color: var(--green); margin-top: 2px; }
.order-card .items { font-size: 12.5px; color: var(--gray); margin: 8px 0; }
.order-card .pick-title { font-size: 11.5px; font-weight: 700; color: var(--gray); margin: 12px 0 6px; }
.order-card .pick-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--card-border); border-radius: var(--radius-sm); overflow: hidden; }
.order-card .pick-row { display: flex; align-items: center; gap: 8px; padding: 9px 12px; font-size: 13px; border-bottom: 1px solid var(--card-border); background: var(--white); }
.order-card .pick-row:nth-child(even) { background: var(--bg); }
.order-card .pick-row:last-child { border-bottom: none; }
.order-card .pick-qty {
  flex: none;
  min-width: 30px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  background: var(--green-light);
  color: var(--green);
  font-weight: 700;
  font-size: 11.5px;
}
.order-card .pick-name { flex: 1; }
.order-card .pick-unit { color: var(--gray); font-size: 11.5px; }
.order-card .actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.order-card .actions select { flex: 1; min-width: 120px; }
.order-card .actions .btn-primary { flex: 1; }
.order-card .link-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  height: 40px;
  text-decoration: none;
  background: var(--green-light);
  color: var(--green);
  border-radius: var(--radius-pill);
  font: 600 12.5px/1 var(--font);
  white-space: nowrap;
}
.order-card .link-btn svg { width: 15px; height: 15px; }
.order-card .link-btn:active { background: #d7ece6; }

/* ───────────── دیالوگ تأیید سفارشی ───────────── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 16, 80, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.dialog-box {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px 20px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 32px rgba(16, 16, 80, 0.18);
}
.dialog-box p { margin: 0 0 18px; font-size: 14.5px; line-height: 1.6; color: var(--navy); }
.dialog-box .dialog-actions { display: flex; gap: 8px; }
.dialog-box .dialog-actions button { flex: 1; padding: 0 12px; height: 42px; }

/* ───────────── رسید امضا هنگام تحویل ───────────── */
.signature-box { max-width: 360px; text-align: center; }
.signature-title { font-size: 15px; font-weight: 700; color: var(--navy); margin-bottom: 4px; line-height: 1.6; }
.signature-customer { font-size: 12.5px; color: var(--gray); margin-bottom: 14px; }
.signature-pad-wrap {
  position: relative;
  height: 170px;
  background: var(--white);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  overflow: hidden;
}
.signature-pad {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}
.signature-pad-line {
  position: absolute;
  right: 14px;
  left: 14px;
  bottom: 34px;
  height: 1px;
  background: var(--border);
  pointer-events: none;
}
.signature-pad-hint {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  color: var(--gray);
  pointer-events: none;
}
.signature-cancel {
  display: block;
  width: 100%;
  margin-top: 12px;
  background: none;
  border: none;
  color: var(--gray);
  font-size: 12.5px;
  text-decoration: underline;
}

/* ───────────── ورود ───────────── */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-box {
  max-width: 360px;
  width: 100%;
  background: var(--white);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 32px 26px;
}
.login-box__logo { width: 56px; height: 56px; margin: 0 auto 14px; object-fit: contain; }
.login-box h1 { font-size: 18px; text-align: center; margin-bottom: 4px; color: var(--navy); font-weight: 700; }
.login-box .subtitle { text-align: center; font-size: 12.5px; color: var(--gray); margin-bottom: 22px; }
.login-box label { margin: 14px 0 6px; }

/* ───────────── اجبار روشن‌بودن لوکیشن (پیک) ───────────── */
.location-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}
.location-gate[hidden] { display: none; }
.location-gate__box {
  max-width: 340px;
  width: 100%;
  text-align: center;
  background: var(--white);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 32px 24px;
}
.location-gate__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin-bottom: 14px;
  border-radius: 50%;
  background: var(--badge-amber-light);
  color: var(--badge-amber);
}
.location-gate__box h2 { font-size: 16px; color: var(--navy); margin-bottom: 8px; }
.location-gate__box p { font-size: 13px; color: var(--gray); line-height: 1.8; margin-bottom: 20px; }

/* ───────────── وضعیت خالی/خطا با آیکون ───────────── */
.state-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 16px;
  color: var(--gray);
  text-align: center;
}
.state-block svg { width: 40px; height: 40px; color: var(--card-border); }
.state-block.is-error svg { color: var(--badge-red-light); }
.state-block p { font-size: 13.5px; }

@media (max-width: 640px) {
  .container { padding: 12px; }
  table, thead, tbody, tr { display: block; }
  thead { display: none; }
  tr { border-bottom: 1px solid var(--card-border); padding: 10px 0; }
  tr:last-child { border-bottom: none; }
  td { border: none; display: flex; justify-content: space-between; align-items: center; padding: 5px 0; gap: 10px; }
  td::before { content: attr(data-label); color: var(--gray); font-size: 11.5px; flex: none; }
  td input, td select { max-width: 140px; }
}
