:root {
  --accent: #e2001a;
  --accent-dark: #b30014;
  --bg: #f7f7f5;
  --card-bg: #ffffff;
  --text: #1c1c1c;
  --muted: #777;
  --radius: 18px;
  --shadow: 0 2px 10px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body.rtl {
  direction: rtl;
  font-family: "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
}

/* Password gate */
.site-gate {
  position: fixed; inset: 0; z-index: 999; background: #fff;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.site-gate.hidden { display: none; }
.site-gate-box {
  max-width: 360px; width: 100%; text-align: center;
  padding: 32px 26px; border-radius: var(--radius); box-shadow: var(--shadow);
}
.site-gate-box h2 { margin: 0 0 10px; font-size: 20px; }
.site-gate-box p { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.site-gate-box input {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid #ddd;
  font-size: 14px; margin-bottom: 10px; text-align: center;
}
.site-gate-box .checkout-btn { margin-top: 4px; }

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #fff;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 10px;
  object-fit: contain; background: #fff;
}
.brand-name strong { color: var(--accent); }

.search { flex: 1; }
.search input {
  width: 100%;
  max-width: 420px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid #e5e5e3;
  background: #f2f2f0;
  font-size: 14px;
  outline: none;
}
.search input:focus { border-color: var(--accent); background: #fff; }

.actions { display: flex; align-items: center; gap: 10px; }
.lang-btn {
  border: 1px solid #ddd; background: #fff; border-radius: 999px;
  padding: 8px 14px; font-size: 13px; cursor: pointer;
}
.lang-btn:hover { border-color: var(--accent); color: var(--accent); }
.account-btn {
  border: 1px solid #ddd; background: #fff; color: var(--text);
  border-radius: 999px; padding: 8px 14px; font-size: 13px; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
}
.account-btn:hover { border-color: var(--accent); color: var(--accent); }
.account-btn.logged-in { border-color: var(--accent); color: var(--accent); font-weight: 600; }

.cart-btn {
  position: relative;
  border: none; background: var(--accent); color: #fff;
  border-radius: 999px; padding: 9px 16px; cursor: pointer;
  display: flex; align-items: center; gap: 6px; font-size: 14px;
}
#cartCount {
  background: #fff; color: var(--accent); border-radius: 999px;
  min-width: 20px; height: 20px; display: inline-flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 700; padding: 0 4px;
}

/* Category nav */
.category-nav {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 10px 20px 14px; max-width: 1200px; margin: 0 auto;
}
.category-nav button {
  flex: none; border: 1px solid #e5e5e3; background: #fff;
  padding: 7px 16px; border-radius: 999px; font-size: 13px; cursor: pointer;
  white-space: nowrap;
}
.category-nav button.active, .category-nav button:hover {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

/* Mega menu panel */
.mega-panel {
  background: #f1eefc;
  border-top: 1px solid #e3ddf7;
  padding: 18px 20px 28px;
}
.mega-panel.hidden { display: none; }
.mega-panel-header {
  max-width: 1200px; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.mega-title { font-weight: 700; font-size: 15px; }
.mega-close, .mega-back {
  border: none; background: transparent; cursor: pointer;
  font-size: 14px; color: #444;
}
.mega-close { font-size: 16px; }
.mega-grid {
  max-width: 1200px; margin: 0 auto;
  display: flex; flex-direction: column;
  gap: 2px;
}
.mega-grid button {
  background: none; border: none; cursor: pointer;
  text-align: left; padding: 8px 0;
  color: var(--accent); font-size: 14px; font-weight: 500;
}
body.rtl .mega-grid button { text-align: right; }
.mega-grid button:hover { text-decoration: underline; }

/* Hero */
.hero {
  max-width: 1200px; margin: 24px auto 10px; padding: 0 20px;
}
.hero-banner {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.hero-banner img {
  width: 100%;
  height: clamp(180px, 28vw, 380px);
  object-fit: cover;
  display: block;
}
.hero-text { margin-top: 16px; }
.hero-text h1 { margin: 0 0 6px; font-size: 26px; }
.hero-text p { margin: 0; color: var(--muted); }
.hero-badge {
  position: absolute; top: 14px; inset-inline-end: 14px;
  background: #fff3cd; border: 1px solid #ffe08a; color: #7a5b00;
  padding: 8px 14px; border-radius: 12px; font-size: 13px; font-weight: 600;
}

/* Product grid */
.product-grid {
  max-width: 1200px; margin: 20px auto 60px; padding: 0 20px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
}
.card {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,0.1); }
.card-img {
  aspect-ratio: 1 / 1; background: #fafafa;
  display: flex; align-items: center; justify-content: center;
  padding: 14px;
}
.card-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-brand { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.card-name { font-size: 14px; font-weight: 600; line-height: 1.3; min-height: 36px; }
.card-weight { font-size: 12px; color: var(--muted); }
.card-footer {
  margin-top: auto; display: flex; align-items: center; justify-content: space-between;
  padding-top: 8px;
}
.card-price { font-weight: 700; font-size: 15px; color: var(--text); }
.card-price small { font-weight: 400; color: var(--muted); font-size: 11px; }
.add-btn {
  border: none; background: var(--accent); color: #fff; border-radius: 999px;
  width: 32px; height: 32px; font-size: 18px; cursor: pointer; line-height: 1;
}
.add-btn:hover { background: var(--accent-dark); }

.empty-state { grid-column: 1/-1; text-align: center; color: var(--muted); padding: 60px 0; }

.site-footer {
  text-align: center; color: var(--muted); font-size: 12px;
  padding: 24px 20px 40px;
}
.admin-link {
  display: inline-block; margin-top: 8px; color: #ccc; font-size: 11px;
  text-decoration: none;
}
.admin-link:hover { color: var(--muted); }

.footer-legal { margin-top: 10px; font-size: 12px; }
.footer-legal a { color: var(--muted); text-decoration: none; }
.footer-legal a:hover { color: var(--accent); }
.footer-legal span { margin: 0 6px; color: #ccc; }

.footer-payments {
  list-style: none; display: flex; flex-wrap: wrap; justify-content: center;
  align-items: center; gap: 8px; max-width: 620px; margin: 16px auto 0; padding: 0;
}
.footer-payments li {
  border: 1px solid #e5e5e3; border-radius: 6px; background: #fff;
  display: flex; align-items: center; justify-content: center;
}
.footer-payments .pm-icon {
  width: 46px; height: 30px; padding: 2px;
}
.footer-payments .pm-icon img {
  width: 100%; height: 100%; object-fit: contain;
}
.footer-payments .pm-tag {
  padding: 6px 10px; font-size: 11px; font-weight: 700; letter-spacing: .01em;
  white-space: nowrap;
}
.footer-copyright { margin-top: 12px; font-size: 11px; color: #999; }
.footer-credit { margin-top: 4px; font-size: 11px; color: #999; }
.footer-credit a { color: var(--muted); text-decoration: none; }
.footer-credit a:hover { color: var(--accent); text-decoration: underline; }

/* Admin panel */
.admin-panel {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 60; background: #fff; border-radius: var(--radius);
  width: 720px; max-width: 94vw; max-height: 86vh; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.admin-panel.hidden { display: none; }
.admin-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid #eee;
}
.admin-panel-header h2 { margin: 0; font-size: 16px; }
.admin-panel > .auth-sub { padding: 10px 22px 0; margin: 0; }
.admin-product-list { overflow-y: auto; padding: 10px 22px 20px; }
.admin-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid #f1f1f1;
}
.admin-row img { width: 42px; height: 42px; object-fit: contain; background: #fafafa; border-radius: 8px; }
.admin-row-name { flex: 1; font-size: 13px; }
.admin-row-name small { display: block; color: var(--muted); font-size: 11px; }
.admin-row input[type="number"] {
  width: 90px; padding: 6px 8px; border-radius: 8px; border: 1px solid #ddd; font-size: 13px;
}
.admin-row label.toggle { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }

/* Cart drawer */
.cart-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 40;
}
.cart-overlay.hidden { display: none; }

.cart-drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: 380px; max-width: 90vw;
  background: #fff; z-index: 50; box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  display: flex; flex-direction: column;
  transform: translateX(0);
}
body.rtl .cart-drawer { right: auto; left: 0; }
.cart-drawer.hidden { display: none; }

.cart-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid #eee;
}
.cart-drawer-header h2 { margin: 0; font-size: 16px; }

.cart-items { flex: 1; overflow-y: auto; padding: 10px 18px; }
.cart-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid #f1f1f1;
}
.cart-row img { width: 48px; height: 48px; object-fit: contain; background: #fafafa; border-radius: 8px; }
.cart-row-info { flex: 1; min-width: 0; }
.cart-row-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.cart-row-price { font-size: 12px; color: var(--muted); }
.cart-qty { display: flex; align-items: center; gap: 6px; }
.cart-qty button {
  width: 24px; height: 24px; border-radius: 50%; border: 1px solid #ddd;
  background: #fff; cursor: pointer; font-size: 14px; line-height: 1;
}
.cart-qty span { min-width: 18px; text-align: center; font-size: 13px; }
.cart-remove {
  border: none; background: none; color: var(--muted); cursor: pointer; font-size: 16px;
}
.cart-remove:hover { color: var(--accent); }
.cart-empty { text-align: center; color: var(--muted); padding: 50px 0; font-size: 14px; }

.cart-drawer-footer { padding: 16px 18px; border-top: 1px solid #eee; }
.cart-total-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 15px; margin-bottom: 12px;
}

.payment-methods { margin-bottom: 14px; }
.payment-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.payment-option {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid #e5e5e3; border-radius: 10px;
  padding: 8px 10px; margin-bottom: 6px; cursor: pointer; font-size: 13px;
}
.payment-option:has(input:checked) { border-color: var(--accent); background: #fff5f6; }
.payment-icon { font-size: 15px; }
.payment-option input { accent-color: var(--accent); }
.checkout-btn {
  width: 100%; border: none; background: var(--accent); color: #fff;
  padding: 12px; border-radius: 12px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.checkout-btn:hover { background: var(--accent-dark); }
.checkout-btn:disabled { opacity: .6; cursor: default; }

/* Auth modal */
.auth-modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 60; background: #fff; border-radius: var(--radius);
  width: 440px; max-width: 92vw; max-height: 88vh; overflow-y: auto;
  padding: 28px 24px 24px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.auth-section-title {
  font-size: 12px; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: .03em;
  margin: 18px 0 2px; padding-top: 12px; border-top: 1px solid #f0f0f0;
}
.auth-step .auth-section-title:first-of-type { border-top: none; padding-top: 0; }
.auth-grid-2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px;
}
.auth-modal.hidden { display: none; }
.auth-step.hidden { display: none; }
.auth-close { position: absolute; top: 12px; right: 12px; }
body.rtl .auth-close { right: auto; left: 12px; }
.auth-step h2 { margin: 0 0 6px; font-size: 18px; }
.auth-sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.auth-step label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.auth-step input {
  width: 100%; padding: 9px 12px; border-radius: 10px;
  border: 1px solid #ddd; font-size: 14px; outline: none;
}
.auth-step input:focus { border-color: var(--accent); }
.auth-step .checkout-btn { margin-top: 16px; }
.auth-error { color: #c0392b; font-size: 12px; min-height: 16px; margin-top: 6px; }
.auth-switch { text-align: center; font-size: 12px; color: var(--muted); margin-top: 14px; }
.auth-switch a { color: var(--accent); text-decoration: none; font-weight: 600; cursor: pointer; }
.demo-code-box {
  background: #fff3cd; border: 1px solid #ffe08a; color: #7a5b00;
  padding: 10px 14px; border-radius: 10px; font-size: 20px; font-weight: 700;
  text-align: center; letter-spacing: 4px; margin-top: 6px;
}
.auth-demo-note {
  font-size: 11px; color: var(--muted); margin: 16px 0 0;
  border-top: 1px dashed #ddd; padding-top: 10px;
}
