/* ---------- Fonts ---------- */
@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-Medium.woff2') format('woff2');
  font-weight: 500; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('fonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700; font-display: swap;
}

/* ---------- Theme ---------- */
:root {
  --bg: #f4f6fb;
  --bg-grad-1: #6d5efc;
  --bg-grad-2: #4a90e2;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --border: #e6e8f0;
  --fg: #1c2434;
  --muted: #7b8497;
  --accent: #5b6ef5;
  --accent-ink: #ffffff;
  --success: #17a673;
  --success-bg: #e7f7f0;
  --danger: #e5484d;
  --danger-bg: #fdecec;
  --warn: #d98a00;
  --warn-bg: #fdf4e3;
  --shadow: 0 6px 24px rgba(28, 36, 52, .08);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1117;
    --bg-grad-1: #4c3fd6;
    --bg-grad-2: #2f6bb0;
    --surface: #171b24;
    --surface-2: #1e2330;
    --border: #2a3040;
    --fg: #e9edf5;
    --muted: #93a0b5;
    --accent: #7c8bff;
    --accent-ink: #0e1117;
    --success: #34d399;
    --success-bg: #133226;
    --danger: #f2686c;
    --danger-bg: #3a1d1e;
    --warn: #f0b453;
    --warn-bg: #3a2f18;
    --shadow: 0 8px 28px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Vazirmatn', 'Tahoma', system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  direction: rtl;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 680px; margin-inline: auto; padding: 0 16px 48px; }

/* ---------- Header ---------- */
.hero {
  background: linear-gradient(135deg, var(--bg-grad-1), var(--bg-grad-2));
  color: #fff;
  padding: 26px 16px 30px;
  text-align: center;
  border-radius: 0 0 26px 26px;
  box-shadow: var(--shadow);
}
.hero h1 { margin: 0; font-size: 1.5rem; font-weight: 700; }
.hero p { margin: 6px 0 0; opacity: .9; font-size: .95rem; }
.hero .brand { font-size: 1.9rem; margin-bottom: 2px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 18px 0 6px;
}
.topbar h2 { margin: 0; font-size: 1.25rem; }

/* ---------- Search ---------- */
.searchbox { position: relative; margin-top: -22px; margin-bottom: 8px; }
.searchbox .icon {
  position: absolute; inset-inline-start: 16px; top: 50%; transform: translateY(-50%);
  font-size: 1.15rem; opacity: .6; pointer-events: none;
}
input[type=text], input[type=password], input[type=number], input[type=search] {
  width: 100%; font-family: inherit; font-size: 1rem; color: var(--fg);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 44px 14px 16px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 110, 245, .18); }
#q { font-size: 1.15rem; box-shadow: var(--shadow); }

/* ---------- Cards ---------- */
#results { margin-top: 6px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; margin-top: 12px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card .info { min-width: 0; }
.card .name { font-size: 1.15rem; font-weight: 700; }
.card .price { color: var(--accent); font-weight: 700; margin-top: 2px; }
.card .price small { color: var(--muted); font-weight: 400; }

/* stock badge */
.badge {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: .9rem; font-weight: 500; padding: 6px 12px; border-radius: 999px;
}
.badge.ok { color: var(--success); background: var(--success-bg); }
.badge.low { color: var(--warn); background: var(--warn-bg); }
.badge.out { color: var(--danger); background: var(--danger-bg); }

/* ---------- Admin list rows ---------- */
.prow {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-top: 12px;
  box-shadow: var(--shadow);
}
.prow .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.prow .name { font-size: 1.1rem; font-weight: 700; }
.prow .meta { color: var(--muted); margin-top: 4px; display: flex; gap: 16px; flex-wrap: wrap; font-size: .95rem; }
.prow .meta .price { color: var(--accent); font-weight: 500; }
.prow .actions { display: flex; gap: 8px; margin-top: 12px; }

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit; font-size: .98rem; font-weight: 500;
  padding: 11px 18px; border: 1px solid transparent; border-radius: 12px;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
  gap: 7px; justify-content: center; transition: transform .05s, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: var(--surface-2); color: var(--fg); border-color: var(--border); }
.btn.danger { background: var(--danger-bg); color: var(--danger); }
.btn.danger:hover { filter: brightness(.97); }
.btn.block { width: 100%; padding: 14px; font-size: 1.05rem; }
.btn.sm { padding: 8px 14px; font-size: .9rem; }

/* ---------- Forms / cards ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-top: 16px; box-shadow: var(--shadow);
}
.panel h3 { margin: 0 0 4px; font-size: 1.15rem; }
.panel .sub { color: var(--muted); margin: 0 0 16px; font-size: .92rem; }
.field { margin-top: 14px; }
.field label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 6px; }
.field .hint { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Alerts ---------- */
.alert { border-radius: 12px; padding: 12px 16px; margin-top: 14px; font-size: .95rem; font-weight: 500; }
.alert.error { color: var(--danger); background: var(--danger-bg); }
.alert.success { color: var(--success); background: var(--success-bg); }

.flash {
  position: sticky; top: 8px; z-index: 5;
  border-radius: 12px; padding: 12px 16px; margin-top: 14px;
  color: var(--success); background: var(--success-bg); font-weight: 500;
  box-shadow: var(--shadow);
}

/* ---------- Misc ---------- */
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .em { font-size: 2.2rem; display: block; margin-bottom: 8px; }
.stats { display: flex; gap: 10px; margin-top: 14px; }
.stat { flex: 1; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 14px; text-align: center; box-shadow: var(--shadow); }
.stat .num { font-size: 1.35rem; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: .85rem; }
/* ---------- Pagination ---------- */
.pager { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; margin-top: 20px; }
.pager .pg {
  font-family: inherit; font-size: .95rem; min-width: 42px; padding: 9px 14px;
  border: 1px solid var(--border); background: var(--surface); color: var(--fg);
  border-radius: 10px; cursor: pointer; text-decoration: none; text-align: center;
  transition: filter .15s;
}
.pager .pg:hover:not([disabled]):not([aria-disabled="true"]):not(.active) { filter: brightness(1.08); border-color: var(--accent); }
.pager .pg.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; cursor: default; }
.pager .pg[disabled], .pager .pg[aria-disabled="true"] { opacity: .45; cursor: default; pointer-events: none; }
.pager .dots { color: var(--muted); padding: 0 2px; }

.link { color: var(--accent); text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; }
.center { text-align: center; }
.mt { margin-top: 16px; }
