@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #1a56ff;
  --primary-dark: #0d3fd6;
  --primary-light: #5c85ff;
  --accent: #00c2ff;
  --bg: #f3f6ff;
  --surface: #ffffff;
  --surface-2: #eef2fc;
  --text: #101425;
  --text-dim: #5b6272;
  --border: #e2e7f5;
  --success: #17b26a;
  --danger: #ef4444;
  --warning: #f5a623;
  --radius: 16px;
  --shadow: 0 4px 24px rgba(20, 40, 120, .08);
  --shadow-lg: 0 16px 48px rgba(20, 40, 120, .16);
  --header-h: 76px;
}

[data-theme="dark"] {
  --bg: #060a17;
  --surface: #0f1630;
  --surface-2: #141c3d;
  --text: #eef1ff;
  --text-dim: #9aa3c4;
  --border: #22294a;
  --shadow: 0 4px 24px rgba(0, 0, 0, .4);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .55);
  --primary-light: #6f93ff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Vazirmatn', sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  transition: background .35s ease, color .35s ease;
  min-height: 100vh;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
ul { list-style: none; }

.container { max-width: 1280px; margin: 0 auto; padding: 0 20px; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--surface-2); }
::-webkit-scrollbar-thumb { background: var(--primary-light); border-radius: 10px; }

/* ================= HEADER ================= */
.header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  transition: box-shadow .3s ease, background .35s ease;
}
.header.scrolled { box-shadow: var(--shadow); }
.header-inner {
  height: 100%; display: flex; align-items: center; gap: 24px;
  justify-content: space-between;
}
.header-left { display: flex; align-items: center; gap: 14px; }

/* tiny logo, top-right corner as requested */
.brand-mark {
  display: flex; align-items: center; gap: 8px;
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  opacity: .95;
}
.brand-mark img { width: 22px; height: 22px; border-radius: 5px; }
.brand-mark span { font-size: 11px; color: var(--text-dim); font-weight: 600; letter-spacing: .3px; }

.logo-full { display: flex; align-items: center; gap: 10px; }
.logo-full img { width: 40px; height: 40px; border-radius: 9px; }
.logo-full .logo-text { display: flex; flex-direction: column; line-height: 1.15; }
.logo-full .logo-text b { font-size: 17px; font-weight: 800; }
.logo-full .logo-text small { font-size: 10.5px; color: var(--text-dim); letter-spacing: 1px; }

.search-box {
  flex: 1; max-width: 560px; position: relative;
  display: flex; align-items: center;
}
.search-box input {
  width: 100%; height: 44px; border-radius: 22px; border: 1.5px solid var(--border);
  background: var(--surface-2); padding: 0 46px 0 18px; font-family: inherit;
  color: var(--text); font-size: 14px; transition: border-color .2s, box-shadow .2s;
}
.search-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(26, 86, 255, .12); }
.search-box svg { position: absolute; right: 16px; width: 18px; height: 18px; stroke: var(--text-dim); }

.header-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: var(--text); position: relative; transition: background .2s, transform .2s;
}
.icon-btn:hover { background: var(--surface-2); transform: translateY(-1px); }
.icon-btn svg { width: 21px; height: 21px; }

.cart-badge {
  position: absolute; top: 2px; left: 2px; background: var(--danger); color: #fff;
  font-size: 10px; min-width: 17px; height: 17px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
  transform: scale(0); transition: transform .25s cubic-bezier(.34,1.56,.64,1);
}
.cart-badge.show, .cart-badge:not(:empty) { transform: scale(1); }

.theme-toggle {
  width: 52px; height: 28px; border-radius: 20px; background: var(--surface-2);
  border: 1.5px solid var(--border); position: relative; transition: background .3s;
}
.theme-toggle .knob {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  transition: transform .35s cubic-bezier(.6,-0.28,.74,.05);
  display: flex; align-items: center; justify-content: center; color: #fff;
}
[data-theme="dark"] .theme-toggle .knob { transform: translateX(-24px); }
.theme-toggle svg { width: 12px; height: 12px; }

/* ================= NAV CATEGORIES ================= */
.subnav {
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.subnav .container { display: flex; gap: 28px; overflow-x: auto; padding-top: 12px; padding-bottom: 12px; }
.subnav a { font-size: 13.5px; color: var(--text-dim); white-space: nowrap; font-weight: 500; transition: color .2s; position: relative; }
.subnav a:hover, .subnav a.active { color: var(--primary); }
.subnav a.active::after { content:''; position:absolute; bottom:-13px; right:0; left:0; height:2px; background: var(--primary); border-radius: 2px; }

/* ================= HERO ================= */
.hero {
  position: relative; margin: 24px auto; border-radius: 24px; overflow: hidden;
  background: linear-gradient(120deg, var(--primary-dark), var(--primary) 55%, var(--accent));
  min-height: 320px; display: flex; align-items: center;
  box-shadow: var(--shadow-lg);
}
.hero::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 85% 30%, rgba(255,255,255,.18), transparent 55%);
}
.hero-glow {
  position: absolute; width: 420px; height: 420px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.25), transparent 70%);
  top: -160px; left: -100px; animation: float 8s ease-in-out infinite;
}
@keyframes float { 0%,100%{ transform: translateY(0) } 50%{ transform: translateY(30px) } }
.hero-content { position: relative; z-index: 2; padding: 48px; color: #fff; max-width: 560px; }
.hero-content .eyebrow { font-size: 13px; opacity: .85; letter-spacing: .5px; margin-bottom: 10px; display:block; }
.hero-content h1 { font-size: 34px; font-weight: 800; line-height: 1.4; margin-bottom: 14px; }
.hero-content p { font-size: 15px; opacity: .9; margin-bottom: 26px; line-height: 1.8; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 13px 28px; border-radius: 12px;
  font-weight: 700; font-size: 14px; transition: transform .2s ease, box-shadow .2s ease, background .2s;
}
.btn-primary { background: #fff; color: var(--primary-dark); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(0,0,0,.18); }
.btn-outline { border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-block { width: 100%; justify-content: center; }
.btn-danger-outline { border: 1.5px solid var(--danger); color: var(--danger); }

.hero-phone {
  position: absolute; left: 40px; bottom: -30px; width: 240px; opacity: .95;
  animation: floaty 5s ease-in-out infinite;
  filter: drop-shadow(0 20px 30px rgba(0,0,0,.35));
}
@keyframes floaty { 0%,100%{ transform: translateY(0) rotate(-4deg) } 50%{ transform: translateY(-18px) rotate(-1deg) } }

/* ================= SECTION HEADS ================= */
.section { padding: 36px 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.section-head h2 { font-size: 20px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.section-head h2 .dot { width: 9px; height: 22px; border-radius: 5px; background: linear-gradient(var(--primary), var(--accent)); display:inline-block; }
.section-head a { font-size: 13px; color: var(--primary); font-weight: 600; }

/* ================= CATEGORY CHIPS ================= */
.cat-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; }
.cat-card {
  background: var(--surface); border-radius: var(--radius); padding: 20px 12px; text-align: center;
  border: 1px solid var(--border); transition: transform .25s ease, box-shadow .25s ease, border-color .25s;
}
.cat-card:hover { transform: translateY(-6px); box-shadow: var(--shadow); border-color: var(--primary-light); }
.cat-card .ic { width: 48px; height: 48px; margin: 0 auto 10px; border-radius: 14px; background: var(--surface-2); display:flex; align-items:center; justify-content:center; }
.cat-card .ic svg { width: 24px; height: 24px; stroke: var(--primary); }
.cat-card span { font-size: 13px; font-weight: 600; }

/* ================= PRODUCT GRID ================= */
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }

.product-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; position: relative; transition: transform .3s ease, box-shadow .3s ease, border-color .3s;
  display: flex; flex-direction: column;
}
.product-card:hover { transform: translateY(-8px); box-shadow: var(--shadow-lg); border-color: transparent; }
.product-thumb { position: relative; aspect-ratio: 1/1; overflow: hidden; background: var(--surface-2); }
.product-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.product-card:hover .product-thumb img { transform: scale(1.08); }
.badge {
  position: absolute; top: 10px; right: 10px; background: var(--primary); color: #fff;
  font-size: 10.5px; padding: 5px 10px; border-radius: 20px; font-weight: 700;
}
.badge.discount { background: var(--danger); left: 10px; right: auto; }
.wish-btn {
  position: absolute; top: 10px; left: 10px; width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,.85); display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: translateY(-6px); transition: all .25s ease;
}
[data-theme="dark"] .wish-btn { background: rgba(15,22,48,.85); }
.product-card:hover .wish-btn { opacity: 1; transform: translateY(0); }
.wish-btn svg { width: 16px; height: 16px; stroke: var(--text); }

.product-info { padding: 14px 14px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.product-brand { font-size: 11px; color: var(--text-dim); font-weight: 600; }
.product-name { font-size: 13.5px; font-weight: 600; line-height: 1.6; min-height: 42px; }
.product-rating { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-dim); }
.product-rating svg { width: 13px; height: 13px; fill: var(--warning); stroke: none; }
.price-row { display: flex; align-items: baseline; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.price-now { font-size: 15px; font-weight: 800; color: var(--text); }
.price-old { font-size: 11.5px; color: var(--text-dim); text-decoration: line-through; }
.price-off { font-size: 10.5px; background: rgba(239,68,68,.12); color: var(--danger); padding: 2px 6px; border-radius: 6px; font-weight: 700; }

.add-cart-btn {
  margin-top: 10px; width: 100%; padding: 10px; border-radius: 10px; background: var(--surface-2);
  color: var(--primary); font-weight: 700; font-size: 12.5px; display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .25s ease, color .25s ease, transform .15s ease;
}
.add-cart-btn:hover { background: var(--primary); color: #fff; }
.add-cart-btn:active { transform: scale(.95); }
.add-cart-btn svg { width: 15px; height: 15px; }

/* ---- scroll reveal ---- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: translateY(0); }

/* ---- flying cart animation clone ---- */
.fly-clone {
  position: fixed; z-index: 999; border-radius: 12px; pointer-events: none;
  transition: all .7s cubic-bezier(.55,0,.1,1);
  box-shadow: var(--shadow-lg);
}

/* ---- toast ---- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 13px 22px; border-radius: 12px; font-size: 13.5px;
  font-weight: 600; z-index: 1000; opacity: 0; transition: all .35s cubic-bezier(.34,1.56,.64,1);
  display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast svg { width: 16px; height: 16px; stroke: var(--success); }

/* ================= FOOTER ================= */
.footer { background: var(--surface); border-top: 1px solid var(--border); margin-top: 60px; padding: 40px 0 24px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 30px; margin-bottom: 30px; }
.footer h4 { font-size: 14px; margin-bottom: 14px; font-weight: 700; }
.footer p, .footer a { font-size: 13px; color: var(--text-dim); line-height: 2.2; }
.footer a:hover { color: var(--primary); }
.footer-bottom { border-top: 1px solid var(--border); padding-top: 18px; text-align: center; font-size: 12px; color: var(--text-dim); }

/* ================= BREADCRUMB ================= */
.breadcrumb { font-size: 12.5px; color: var(--text-dim); padding: 18px 0 6px; display: flex; gap: 6px; align-items: center; }
.breadcrumb a:hover { color: var(--primary); }

/* ================= PRODUCT PAGE ================= */
.product-view { display: grid; grid-template-columns: 440px 1fr; gap: 40px; padding: 24px 0 50px; }
.gallery-main { aspect-ratio: 1/1; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); overflow: hidden; margin-bottom: 12px; }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs { display: flex; gap: 10px; }
.gallery-thumbs img { width: 70px; height: 70px; object-fit: cover; border-radius: 10px; border: 2px solid var(--border); cursor: pointer; transition: border-color .2s; }
.gallery-thumbs img.active { border-color: var(--primary); }

.pv-title { font-size: 24px; font-weight: 800; margin-bottom: 10px; line-height: 1.5; }
.pv-meta { display: flex; gap: 16px; align-items: center; margin-bottom: 20px; font-size: 13px; color: var(--text-dim); }
.pv-price-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; }
.pv-price-now { font-size: 26px; font-weight: 800; }
.pv-colors { display: flex; gap: 10px; margin: 16px 0; }
.color-dot { width: 30px; height: 30px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; transition: all .2s; }
.color-dot.active { border-color: var(--primary); transform: scale(1.1); }
.qty-box { display: flex; align-items: center; gap: 14px; border: 1.5px solid var(--border); border-radius: 10px; width: fit-content; margin: 16px 0; }
.qty-box button { width: 38px; height: 38px; font-size: 18px; font-weight: 700; color: var(--primary); }
.qty-box span { min-width: 24px; text-align: center; font-weight: 700; }
.pv-desc { line-height: 2.1; color: var(--text-dim); font-size: 14px; margin-top: 30px; }
.pv-desc h3 { color: var(--text); font-size: 16px; margin-bottom: 10px; font-weight: 700; }

/* ================= CART PAGE ================= */
.cart-layout { display: grid; grid-template-columns: 1fr 340px; gap: 24px; padding: 24px 0 60px; align-items: start; }
.cart-item {
  display: flex; gap: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; align-items: center; animation: slideIn .4s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(-20px);} to { opacity: 1; transform: translateX(0);} }
.cart-item.removing { animation: slideOut .35s ease forwards; }
@keyframes slideOut { to { opacity: 0; transform: translateX(60px) scale(.9); height: 0; margin: 0; padding: 0; } }
.cart-item img { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; }
.cart-item-info { flex: 1; }
.cart-item-info h4 { font-size: 14px; margin-bottom: 6px; }
.cart-item-info .sub { font-size: 12px; color: var(--text-dim); }
.remove-btn { color: var(--danger); font-size: 12px; font-weight: 600; margin-top: 8px; }

.summary-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; position: sticky; top: 100px; }
.summary-row { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 12px; color: var(--text-dim); }
.summary-row.total { font-size: 16px; font-weight: 800; color: var(--text); border-top: 1px solid var(--border); padding-top: 14px; margin-top: 8px; }
.empty-state { text-align: center; padding: 70px 20px; color: var(--text-dim); }
.empty-state svg { width: 70px; height: 70px; margin-bottom: 16px; opacity: .5; }

/* ================= AUTH ================= */
.auth-wrap { min-height: calc(100vh - var(--header-h)); display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 40px; width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.auth-card h2 { font-size: 20px; font-weight: 800; margin-bottom: 6px; text-align: center; }
.auth-card p.hint { font-size: 13px; color: var(--text-dim); text-align: center; margin-bottom: 26px; }
.field { margin-bottom: 18px; }
.field label { font-size: 12.5px; font-weight: 600; margin-bottom: 8px; display: block; color: var(--text-dim); }
.field input, .field select, .field textarea {
  width: 100%; height: 46px; border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--surface-2); padding: 0 14px; font-family: inherit; color: var(--text); font-size: 14px;
  transition: border-color .2s;
}
.field textarea { height: auto; padding: 12px 14px; min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); }
.otp-inputs { display: flex; gap: 10px; justify-content: center; direction: ltr; margin-bottom: 20px; }
.otp-inputs input { width: 50px; height: 56px; text-align: center; font-size: 22px; font-weight: 800; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface-2); color: var(--text); }
.otp-inputs input:focus { outline: none; border-color: var(--primary); }

/* ================= RESPONSIVE ================= */
@media (max-width: 1024px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  .cat-grid { grid-template-columns: repeat(4, 1fr); }
  .product-view { grid-template-columns: 1fr; }
  .cart-layout { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .search-box { display: none; }
}
@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
  .hero-content h1 { font-size: 22px; }
  .hero-phone { display: none; }
  .hero-content { padding: 28px; }
  .footer-grid { grid-template-columns: 1fr; }
  .brand-mark { position: static; transform: none; order: -1; }
}

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

/* focus visibility */
a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
