/* ============================================================
   حضوریار — سیستم طراحی مشترک (Design System)
   یک فایل واحد برای تمام صفحات: عمومی، پنل شرکت، کیوسک،
   کارمند و مدیر کل. تغییر رنگ/فاصله فقط از همین‌جا انجام شود.
   ============================================================ */

/* ---------- فونت محلی (بدون وابستگی به CDN خارجی) ---------- */
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Variable.woff2') format('woff2-variations'),
       url('../fonts/Vazirmatn-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---------- توکن‌های طراحی ---------- */
:root {
  /* رنگ برند */
  --brand-50:  #eef7f5;
  --brand-100: #d3ebe6;
  --brand-200: #a7d7ce;
  --brand-300: #6fbcaf;
  --brand-400: #3f9d8c;
  --brand-500: #1f7a6c;
  --brand-600: #176155;
  --brand-700: #134e45;
  --brand-800: #103e37;
  --brand-900: #0c2f2a;

  /* رنگ تاکیدی */
  --accent-50:  #fdf5e9;
  --accent-100: #fae7c9;
  --accent-200: #f4cf95;
  --accent-300: #ecb160;
  --accent-400: #e09a41;
  --accent-500: #d98e3b;
  --accent-600: #b8742c;
  --accent-700: #915a23;

  /* خنثی */
  --n-0:  #ffffff;
  --n-25: #fcfcfd;
  --n-50: #f7f8fa;
  --n-100:#eef0f4;
  --n-150:#e4e7ed;
  --n-200:#d8dce4;
  --n-300:#bcc2ce;
  --n-400:#98a0b0;
  --n-500:#6f7788;
  --n-600:#525a6b;
  --n-700:#3c4351;
  --n-800:#272d38;
  --n-900:#171b23;
  --n-950:#0e1117;

  /* معنایی */
  --ok:      #17795f;
  --ok-bg:   #e6f5f0;
  --ok-line: #b4e0d2;
  --warn:      #b4741d;
  --warn-bg:   #fdf3e2;
  --warn-line: #f2ddb5;
  --danger:      #b8434b;
  --danger-bg:   #fdeced;
  --danger-line: #f5cdd0;
  --info:      #2f6296;
  --info-bg:   #eaf2fb;
  --info-line: #c4dbf3;

  /* سطوح */
  --bg:        var(--n-50);
  --bg-soft:   var(--n-100);
  --surface:   var(--n-0);
  --surface-2: var(--n-25);
  --line:      var(--n-150);
  --line-soft: var(--n-100);
  --text:      var(--n-900);
  --text-soft: var(--n-600);
  --text-mute: var(--n-500);
  --brand:     var(--brand-500);
  --brand-ink: var(--brand-700);
  --brand-bg:  var(--brand-50);
  --accent:    var(--accent-500);
  --accent-bg: var(--accent-50);

  /* شعاع */
  --r-xs: 6px;
  --r-sm: 9px;
  --r-md: 13px;
  --r-lg: 18px;
  --r-xl: 26px;
  --r-full: 999px;

  /* سایه */
  --sh-xs: 0 1px 2px rgba(16,22,34,.05);
  --sh-sm: 0 1px 3px rgba(16,22,34,.07), 0 1px 2px rgba(16,22,34,.04);
  --sh-md: 0 4px 12px rgba(16,22,34,.07), 0 2px 4px rgba(16,22,34,.04);
  --sh-lg: 0 12px 28px rgba(16,22,34,.10), 0 4px 10px rgba(16,22,34,.05);
  --sh-xl: 0 24px 56px rgba(16,22,34,.14), 0 8px 20px rgba(16,22,34,.06);
  --sh-brand: 0 6px 20px rgba(31,122,108,.22);

  /* فاصله */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;
  --s-12: 48px; --s-16: 64px; --s-20: 80px;

  --mono: 'SFMono-Regular', ui-monospace, Consolas, 'Liberation Mono', Menlo, monospace;
  --sans: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, sans-serif;

  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

/* ---------- حالت تاریک ---------- */
[data-theme="dark"] {
  --bg:        var(--n-950);
  --bg-soft:   var(--n-900);
  --surface:   #161a22;
  --surface-2: #1c212b;
  --line:      #2a3140;
  --line-soft: #222835;
  --text:      #e8eaef;
  --text-soft: #a3abbb;
  --text-mute: #7d8698;
  --brand:     var(--brand-300);
  --brand-ink: var(--brand-200);
  --brand-bg:  rgba(63,157,140,.13);
  --accent:    var(--accent-300);
  --accent-bg: rgba(224,154,65,.13);

  --ok:      #5cc4a5; --ok-bg:   rgba(92,196,165,.13); --ok-line: rgba(92,196,165,.26);
  --warn:    #e2ab5c; --warn-bg: rgba(226,171,92,.13); --warn-line: rgba(226,171,92,.26);
  --danger:  #e58b91; --danger-bg: rgba(229,139,145,.13); --danger-line: rgba(229,139,145,.26);
  --info:    #79aee4; --info-bg: rgba(121,174,228,.13); --info-line: rgba(121,174,228,.26);

  --sh-xs: 0 1px 2px rgba(0,0,0,.3);
  --sh-sm: 0 1px 3px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.25);
  --sh-md: 0 4px 12px rgba(0,0,0,.4), 0 2px 4px rgba(0,0,0,.25);
  --sh-lg: 0 12px 28px rgba(0,0,0,.48), 0 4px 10px rgba(0,0,0,.3);
  --sh-xl: 0 24px 56px rgba(0,0,0,.55), 0 8px 20px rgba(0,0,0,.35);
  --sh-brand: 0 6px 20px rgba(63,157,140,.2);
  color-scheme: dark;
}

/* ---------- پایه ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
  font-weight: 400;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background .25s var(--ease), color .25s var(--ease);
}

h1, h2, h3, h4, h5 {
  margin: 0 0 var(--s-3);
  line-height: 1.3;
  font-weight: 800;
  letter-spacing: -.015em;
}
h1 { font-size: clamp(28px, 5vw, 46px); font-weight: 900; letter-spacing: -.03em; }
h2 { font-size: clamp(22px, 3.4vw, 32px); letter-spacing: -.022em; }
h3 { font-size: clamp(17px, 2.2vw, 21px); }
h4 { font-size: 16px; }
p  { margin: 0 0 var(--s-4); }

a { color: var(--brand-ink); text-decoration: none; transition: color .16s var(--ease); }
a:hover { color: var(--brand); }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.ltr  { direction: ltr; text-align: left; }
.muted { color: var(--text-soft); }
.footnote { font-size: 12.5px; color: var(--text-mute); line-height: 1.6; }
.empty {
  padding: var(--s-10) var(--s-5);
  text-align: center;
  color: var(--text-mute);
  font-size: 14px;
}

::selection { background: var(--brand-200); color: var(--brand-900); }
[data-theme="dark"] ::selection { background: var(--brand-700); color: #fff; }

:focus-visible {
  outline: 2px solid var(--brand-400);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* اسکرول‌بار */
* { scrollbar-width: thin; scrollbar-color: var(--n-300) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--n-300); border-radius: var(--r-full);
  border: 3px solid var(--bg); background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--n-400); background-clip: padding-box; border: 3px solid var(--bg); }

/* ---------- چیدمان ---------- */
.wrap { width: 100%; max-width: 1180px; margin-inline: auto; padding-inline: var(--s-5); }
.wrap-narrow { width: 100%; max-width: 860px; margin-inline: auto; padding-inline: var(--s-5); }

.grid { display: grid; gap: var(--s-5); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 620px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.row { display: flex; align-items: center; gap: var(--s-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.row-wrap { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
.spacer { flex: 1; }

/* ---------- کارت ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  box-shadow: var(--sh-sm);
  transition: box-shadow .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.card + .card { margin-top: var(--s-5); }
.card-hover:hover { box-shadow: var(--sh-lg); border-color: var(--n-200); transform: translateY(-2px); }
[data-theme="dark"] .card-hover:hover { border-color: #38414f; }
.card-flush { padding: 0; overflow: hidden; }
.card-title {
  font-size: 15px; font-weight: 800; margin: 0 0 var(--s-2);
  display: flex; align-items: center; gap: var(--s-2);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3); margin-bottom: var(--s-4); flex-wrap: wrap;
}

/* ---------- دکمه ---------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-line: var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: 10px 18px;
  font-family: inherit; font-size: 14px; font-weight: 700; line-height: 1.4;
  color: var(--btn-fg); background: var(--btn-bg);
  border: 1px solid var(--btn-line); border-radius: var(--r-sm);
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: transform .12s var(--ease), box-shadow .18s var(--ease),
              background .18s var(--ease), border-color .18s var(--ease), opacity .18s var(--ease);
  box-shadow: var(--sh-xs);
}
.btn:hover  { transform: translateY(-1px); box-shadow: var(--sh-md); }
.btn:active { transform: translateY(0); box-shadow: var(--sh-xs); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary { --btn-bg: var(--brand-500); --btn-fg: #fff; --btn-line: var(--brand-500); }
.btn-primary:hover { --btn-bg: var(--brand-600); --btn-line: var(--brand-600); box-shadow: var(--sh-brand); }
[data-theme="dark"] .btn-primary { --btn-bg: var(--brand-400); --btn-line: var(--brand-400); --btn-fg: #08201c; }

.btn-dark { --btn-bg: var(--n-900); --btn-fg: #fff; --btn-line: var(--n-900); }
.btn-dark:hover { --btn-bg: var(--n-800); --btn-line: var(--n-800); }
[data-theme="dark"] .btn-dark { --btn-bg: var(--n-0); --btn-fg: var(--n-900); --btn-line: var(--n-0); }

.btn-accent { --btn-bg: var(--accent-500); --btn-fg: #fff; --btn-line: var(--accent-500); }
.btn-accent:hover { --btn-bg: var(--accent-600); --btn-line: var(--accent-600); }

.btn-danger { --btn-bg: var(--danger-bg); --btn-fg: var(--danger); --btn-line: var(--danger-line); }
.btn-danger:hover { --btn-bg: var(--danger); --btn-fg: #fff; --btn-line: var(--danger); }

.btn-ghost { --btn-bg: transparent; --btn-fg: var(--text-soft); --btn-line: var(--line); box-shadow: none; }
.btn-ghost:hover { --btn-bg: var(--bg-soft); --btn-fg: var(--text); --btn-line: var(--n-200); }
[data-theme="dark"] .btn-ghost:hover { --btn-line: #38414f; }

.btn-plain { --btn-bg: transparent; --btn-line: transparent; --btn-fg: var(--text-soft); box-shadow: none; }
.btn-plain:hover { --btn-bg: var(--bg-soft); --btn-fg: var(--text); box-shadow: none; transform: none; }

.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: var(--r-xs); }
.btn-lg { padding: 14px 28px; font-size: 15.5px; border-radius: var(--r-md); }
.btn-block { display: flex; width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s-3); }

/* ---------- فرم ---------- */
label {
  display: block; font-size: 13px; font-weight: 700;
  color: var(--text-soft); margin-bottom: 6px; margin-top: var(--s-4);
}
label:first-child { margin-top: 0; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=time], input[type=search], input[type=tel], select, textarea {
  width: 100%;
  padding: 10px 13px;
  font-family: inherit; font-size: 14.5px; line-height: 1.5;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), background .16s var(--ease);
  appearance: none;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.7; }
input:hover, select:hover, textarea:hover { border-color: var(--n-300); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-400);
  box-shadow: 0 0 0 3.5px var(--brand-bg);
}
input::placeholder, textarea::placeholder { color: var(--n-400); }
input:disabled, select:disabled, textarea:disabled {
  background: var(--bg-soft); color: var(--text-mute); cursor: not-allowed;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236f7788' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 13px center;
  padding-left: 34px;
}
.field-row { display: flex; gap: var(--s-3); flex-wrap: wrap; }
.field-row > * { flex: 1; min-width: 130px; }

/* ---------- برچسب و نشان ---------- */
.pill, .tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3.5px 11px;
  font-size: 12px; font-weight: 700; line-height: 1.6;
  border-radius: var(--r-full);
  background: var(--bg-soft); color: var(--text-soft);
  border: 1px solid transparent; white-space: nowrap;
}
.pill.on,   .tag.on,      .tag.in,      .tag.active,  .tag.approved { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.pill.warn, .tag.warn,    .tag.trial,   .tag.pending  { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.pill.bad,  .tag.bad,     .tag.out,     .tag.expired,
.tag.disabled, .tag.rejected { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); }
.pill.info, .tag.info,    .tag.paid     { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.pill.brand { background: var(--brand-bg); color: var(--brand-ink); border-color: transparent; }

/* ---------- جدول ---------- */
.table-wrap { width: 100%; overflow-x: auto; border-radius: var(--r-md); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  position: sticky; top: 0; z-index: 1;
  padding: 11px 13px; text-align: right;
  font-size: 11.5px; font-weight: 800; letter-spacing: .03em;
  color: var(--text-mute); text-transform: uppercase;
  background: var(--bg-soft); border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: 12px 13px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr { transition: background .14s var(--ease); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- هشدار ---------- */
.alert {
  padding: 13px 16px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--bg-soft);
  font-size: 13.5px; line-height: 1.7;
}
.alert-ok     { background: var(--ok-bg);     border-color: var(--ok-line);     color: var(--ok); }
.alert-warn   { background: var(--warn-bg);   border-color: var(--warn-line);   color: var(--warn); }
.alert-danger { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger); }
.alert-info   { background: var(--info-bg);   border-color: var(--info-line);   color: var(--info); }

/* ---------- آمار ---------- */
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat-value { font-size: 27px; font-weight: 900; letter-spacing: -.03em; line-height: 1.15; }
.stat-label { font-size: 12.5px; color: var(--text-mute); font-weight: 600; }

/* ---------- هدر پنل ---------- */
.app-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-4); padding: 12px var(--s-5);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 18px; font-weight: 900; letter-spacing: -.03em;
  color: var(--text); text-decoration: none;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(140deg, var(--brand-400), var(--brand-600));
  display: grid; place-items: center;
  color: #fff; font-size: 15px; font-weight: 900;
  box-shadow: var(--sh-brand);
}
.brand span { color: var(--brand); }

/* ---------- تب ---------- */
nav.tabs {
  display: flex; gap: 3px; padding: 0 var(--s-5);
  background: var(--surface); border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
  position: sticky; top: 55px; z-index: 30;
}
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs button {
  position: relative;
  padding: 13px 15px; margin: 0;
  font-family: inherit; font-size: 13.5px; font-weight: 700;
  color: var(--text-mute); background: none; border: none;
  cursor: pointer; white-space: nowrap;
  transition: color .16s var(--ease);
}
nav.tabs button::after {
  content: ''; position: absolute; inset-inline: 10px; bottom: -1px; height: 2.5px;
  background: var(--brand); border-radius: 3px 3px 0 0;
  transform: scaleX(0); transition: transform .22s var(--ease-out);
}
nav.tabs button:hover { color: var(--text); }
nav.tabs button.active { color: var(--brand-ink); }
nav.tabs button.active::after { transform: scaleX(1); }

main { padding: var(--s-6) var(--s-5) var(--s-16); max-width: 1180px; margin-inline: auto; width: 100%; }

/* ---------- صفحه ورود ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: var(--s-6) var(--s-5);
}
.auth-wrap .card { width: 100%; max-width: 430px; box-shadow: var(--sh-lg); padding: var(--s-8); }
.auth-switch { margin-top: var(--s-5); font-size: 13.5px; color: var(--text-soft); text-align: center; }
.auth-switch a { cursor: pointer; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- کلید تم ---------- */
.theme-toggle {
  width: 34px; height: 34px; flex: none; padding: 0;
  display: grid; place-items: center;
  background: transparent; color: var(--text-soft);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  cursor: pointer; transition: all .16s var(--ease);
}
.theme-toggle:hover { background: var(--bg-soft); color: var(--text); }
.theme-toggle .i-sun  { display: none; }
.theme-toggle .i-moon { display: block; }
[data-theme="dark"] .theme-toggle .i-sun  { display: block; }
[data-theme="dark"] .theme-toggle .i-moon { display: none; }

/* ---------- ابزارها ---------- */
.divider { height: 1px; background: var(--line); border: 0; margin: var(--s-5) 0; }
.skeleton {
  background: linear-gradient(90deg, var(--bg-soft) 25%, var(--line-soft) 50%, var(--bg-soft) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--r-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.fade-in { animation: fadeIn .3s var(--ease-out); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .card { padding: var(--s-5); border-radius: var(--r-md); }
  main { padding: var(--s-5) var(--s-4) var(--s-12); }
  .app-header { padding: 10px var(--s-4); }
  nav.tabs { padding: 0 var(--s-4); top: 53px; }
}

@media print {
  body { background: #fff; }
  .app-header, nav.tabs, .btn, .no-print { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
}

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