:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: Vazirmatn, Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.8;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ---------- هدر ---------- */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.brand {
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--primary);
  text-decoration: none;
}
.nav-links { display: flex; align-items: center; gap: 1rem; }
.nav-links a { color: var(--text); text-decoration: none; }
.nav-links a:hover { color: var(--primary); }
.nav-user { font-weight: 700; color: var(--muted); }

/* ---------- دکمه‌ها ---------- */
.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  padding: 0.5rem 1.2rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  text-decoration: none;
  text-align: center;
}
.btn:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-block { width: 100%; }
.btn-danger { background: var(--danger); border-color: var(--danger); }

/* ---------- کارت و فرم ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.auth-container { display: flex; justify-content: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.4rem; margin-bottom: 1.2rem; text-align: center; }
.auth-card label { display: block; margin-bottom: 1rem; font-size: 0.9rem; }
.auth-card input {
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
}
.auth-card input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.auth-switch { text-align: center; margin-top: 1rem; font-size: 0.9rem; color: var(--muted); }
.auth-switch a { color: var(--primary); }

.error {
  background: #fee2e2;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.hidden { display: none; }


/* ---------- نوار فیلتر ---------- */
.filter-bar {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.filter-bar input[type="text"] {
  flex: 1;
  min-width: 200px;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
}
.filter-bar select {
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  background: #fff;
}
.filter-bar input:focus,
.filter-bar select:focus { outline: 2px solid var(--primary); border-color: transparent; }

/* ---------- گرید محصولات ---------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.product-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s, transform 0.15s;
}
.product-card:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}
.product-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #f1f5f9;
}
.product-card .pc-body {
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
}
.pc-cat { font-size: 0.78rem; color: var(--muted); }
.pc-name { font-weight: 700; font-size: 0.95rem; }
.pc-price { font-weight: 800; color: var(--primary); margin-top: auto; }
.pc-out { color: var(--danger); font-size: 0.8rem; font-weight: 700; }

/* ---------- صفحه‌بندی ---------- */
.pagination {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  margin: 1.5rem 0;
}
.pagination button { min-width: 38px; }

/* ---------- تک محصول ---------- */
.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}
.pd-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f1f5f9;
}
.pd-name { font-size: 1.4rem; margin-bottom: 0.5rem; }
.pd-price { font-size: 1.3rem; font-weight: 800; color: var(--primary); margin: 0.7rem 0; }
.pd-cat {
  display: inline-block;
  background: #eff6ff;
  color: var(--primary);
  border-radius: 999px;
  padding: 0.15rem 0.8rem;
  font-size: 0.8rem;
  margin-bottom: 0.8rem;
}
.pd-stock { font-weight: 700; margin-bottom: 1rem; }
.stock-in { color: #16a34a; }
.stock-out { color: var(--danger); }
.pd-desc { white-space: pre-line; margin-bottom: 1.2rem; }
@media (max-width: 720px) {
  .product-detail { grid-template-columns: 1fr; }
}

/* ---------- پیام شناور ---------- */
.toast {
  position: fixed;
  bottom: 1.2rem;
  right: 50%;
  transform: translateX(50%);
  background: #16a34a;
  color: #fff;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius);
  font-weight: 700;
  z-index: 50;
}

/* ---------- سبد خرید ---------- */
.cart-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.cart-badge {
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  min-width: 1.3rem;
  height: 1.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0 0.3rem;
}
.qty-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.qty-control span {
  min-width: 1.6rem;
  text-align: center;
  font-weight: 700;
}
.cart-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.cart-summary .total { font-size: 1.1rem; font-weight: 800; }
.cart-summary .actions { display: flex; gap: 0.6rem; }
/* ---------- تکمیل سفارش ---------- */
.checkout-layout {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 760px) {
  .checkout-layout { grid-template-columns: 1fr; }
}
.checkout-form h2,
.checkout-summary h2 { font-size: 1.05rem; margin-bottom: 1rem; }
.checkout-form label { display: block; margin-bottom: 1rem; font-size: 0.9rem; }
.checkout-form input,
.checkout-form textarea {
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
}
.checkout-form input:focus,
.checkout-form textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }
.checkout-summary .total { font-weight: 800; margin-top: 1rem; text-align: left; }

/* ---------- سفارش‌های من ---------- */
.order-card { margin-bottom: 1.2rem; }
.order-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 0.7rem;
  margin-bottom: 0.7rem;
  border-bottom: 1px solid var(--border);
}
.order-id { font-weight: 800; }
.order-date { color: var(--muted); font-size: 0.85rem; }
.order-total { margin-right: auto; font-weight: 800; color: var(--primary); }
.order-addr { margin-top: 0.7rem; font-size: 0.85rem; color: var(--muted); }

.status-badge {
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.st-pending { background: #fef9c3; color: #854d0e; }
.st-processing { background: #dbeafe; color: #1e40af; }
.st-shipped { background: #ede9fe; color: #5b21b6; }
.st-delivered { background: #dcfce7; color: #166534; }
.st-canceled { background: #fee2e2; color: #991b1b; }

/* ---------- لینک فعال منو ---------- */
.admin-links a.active { color: var(--primary); font-weight: 700; }

/* ---------- کارت‌های آمار داشبورد ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  text-align: center;
}
.stat-card .stat-num { font-size: 1.6rem; font-weight: 800; color: var(--primary); }
.stat-card .stat-label { color: var(--muted); font-size: 0.85rem; margin-top: 0.2rem; }
.stat-warn .stat-num { color: #d97706; }

/* ---------- انتخاب وضعیت سفارش ---------- */
.status-select {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.85rem;
  background: #fff;
}
.status-select:disabled { background: #f1f5f9; color: var(--muted); }