:root{
  --bg: #0d1117; --bg-alt: #010409; --card: #161b22; --border: #30363d;
  --accent: #2f81f7; --accent-hover: #4895fd; --text: #c9d1d9; --text-dim: #8b949e;
  --success: #2ea043; --danger: #da3633; --pink: #db61a2; --radius: 12px;
  --shadow: 0 8px 24px rgba(1, 4, 9, 0.6);
  --transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: 'Vazirmatn', system-ui, sans-serif; color: var(--text);
  background-color: var(--bg-alt);
  background-image: radial-gradient(circle at 1px 1px, var(--border) 1px, transparent 0);
  background-size: 24px 24px; line-height: 1.6; overscroll-behavior: none;
}
body.modal-open { overflow: hidden; }
.container { width: min(1200px, 92%); margin-inline: auto; }
[hidden] { display: none !important; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 10; background: rgba(13, 17, 23, 0.7);
  backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--border); padding: 1rem 0;
}
.main-nav { display: flex; align-items: center; justify-content: space-between; }
.logo h1 { margin: 0; font-size: 1.5rem; }
.nav-actions { display: flex; align-items: center; gap: 0.5rem; }
.nav-btn {
  position: relative; background: none; border: none; color: var(--text);
  font-size: 1.5rem; cursor: pointer; padding: 0.5rem; transition: color 0.2s ease;
}
.nav-btn:hover { color: var(--accent); }
.nav-btn.shake { animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake { 10%, 90% { transform: translate3d(-1px, 0, 0); } 20%, 80% { transform: translate3d(2px, 0, 0); } 30%, 50%, 70% { transform: translate3d(-4px, 0, 0); } 40%, 60% { transform: translate3d(4px, 0, 0); } }
.nav-count {
  position: absolute; top: 0; right: 0; background: var(--accent); color: white;
  font-size: 0.7rem; font-weight: 600; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; border: 2px solid var(--bg); transform: translate(25%, -25%);
}
#wishlistCount { background-color: var(--pink); }
.hero-section { text-align: center; padding: 2rem 0 3rem; }
.hero-section h2 { margin: 0 0 0.5rem; font-size: 2.2rem; }
.hero-section p { margin: 0 0 1.5rem; color: var(--text-dim); font-size: 1.1rem; }
.search-bar { display: flex; max-width: 500px; margin: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); overflow: hidden; }
.search-bar input { flex-grow: 1; background: none; border: none; outline: none; padding: 0.8rem 1rem; color: var(--text); font-size: 1rem; }
.search-bar button { background: var(--accent); border: none; color: white; padding: 0 1rem; font-size: 1.2rem; cursor: pointer; }

/* Main Layout */
main.container { display: grid; grid-template-columns: 240px 1fr; gap: 2rem; padding: 2rem 0; align-items: flex-start; }
.filters-panel { position: sticky; top: 100px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.filters-panel h3 { margin: 0 0 1rem; display: flex; align-items: center; gap: 0.5rem; }
.filter-group { display: grid; gap: 0.5rem; margin-bottom: 1rem; }
.filter-group label { font-size: 0.9rem; color: var(--text-dim); }
.filter-group select { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem; outline: none; }
.filter-group select:focus { border-color: var(--accent); }

/* Product Grid & Cards */
.product-grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.product-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column; box-shadow: 0 4px 12px rgba(1, 4, 9, 0.4);
  transition: var(--transition);
}
.product-card:hover { transform: translateY(-5px); box-shadow: var(--shadow); border-color: var(--accent); }
.card-image-link { display: block; cursor: pointer; }
.card-image { aspect-ratio: 16 / 10; background: var(--bg-alt); padding: 1rem; }
.card-image img { width: 100%; height: 100%; object-fit: contain; }
.card-content { padding: 1rem; flex-grow: 1; display: flex; flex-direction: column; }
.product-title-link { text-decoration: none; color: var(--text); }
.product-title { margin: 0; font-size: 1.1rem; cursor: pointer; }
.product-brand { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 1rem; }
.card-footer { margin-top: auto; display: flex; align-items: center; justify-content: space-between; }
.product-price { font-weight: 600; font-size: 1.2rem; }
.card-actions { display: flex; gap: 0.5rem; }
.card-action-btn {
  background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 50%;
  width: 44px; height: 44px; font-size: 1.2rem; cursor: pointer; transition: var(--transition);
  display: grid; place-items: center; position: relative; overflow: hidden;
}
.card-action-btn:hover { border-color: var(--accent); color: var(--accent); transform: scale(1.1); }
.card-action-btn.wishlist-btn.active { color: var(--pink); border-color: var(--pink); }
.card-action-btn.add-to-cart-btn.added { background: var(--success); border-color: var(--success); color: white; }
.card-action-btn.add-to-cart-btn .bi-plus-lg, .card-action-btn.add-to-cart-btn .bi-check-lg { transition: transform 0.2s ease-out; }
.card-action-btn.add-to-cart-btn.added .bi-plus-lg { transform: translateY(-150%); }
.card-action-btn.add-to-cart-btn .bi-check-lg { position: absolute; transform: translateY(150%); }
.card-action-btn.add-to-cart-btn.added .bi-check-lg { transform: translateY(0); }

/* Skeleton Loading */
.skeleton-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.skeleton-card .image { height: 175px; background: var(--border); }
.skeleton-card .content { padding: 1rem; }
.skeleton-card .title { height: 24px; width: 80%; background: var(--border); border-radius: 4px; margin-bottom: 0.5rem; }
.skeleton-card .text { height: 18px; width: 50%; background: var(--border); border-radius: 4px; }
.skeleton-card .image, .skeleton-card .title, .skeleton-card .text {
  background-image: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
  background-size: 200px 100%; background-repeat: no-repeat;
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 0% { background-position: -200px 0; } 100% { background-position: calc(100% + 200px) 0; } }

/* Empty State */
.empty-state { text-align: center; color: var(--text-dim); padding: 3rem; background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty-state .bi { font-size: 3rem; margin-bottom: 1rem; }

/* Modals & Backdrop */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px); opacity: 0; transition: opacity 0.3s ease; pointer-events: none;
}
.modal-backdrop:not([hidden]) { opacity: 1; pointer-events: auto; }
.modal {
  position: fixed; z-index: 50; background: var(--card); border: 1px solid var(--border);
  box-shadow: var(--shadow); opacity: 0; transition: opacity 0.3s ease, transform 0.3s ease;
  display: flex; flex-direction: column; pointer-events: none;
}
.modal.is-open { opacity: 1; pointer-events: auto; }
.modal[data-side="right"] { inset: 0 0 0 auto; width: min(420px, 95vw); border-radius: var(--radius) 0 0 var(--radius); transform: translateX(100%); }
.modal[data-side="right"].is-open { transform: translateX(0); }
.modal[data-side="center"] {
  top: 50%; left: 50%; width: min(800px, 95vw); max-height: 90vh;
  border-radius: var(--radius); transform: translate(-50%, -50%) scale(0.9);
}
.modal[data-side="center"].is-open { transform: translate(-50%, -50%) scale(1); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-header h4 { margin: 0; font-size: 1.2rem; display: flex; align-items: center; gap: 0.5rem; }
.close-btn { background: none; border: none; color: var(--text-dim); font-size: 1.5rem; cursor: pointer; line-height: 1; }
.modal-body { flex-grow: 1; overflow-y: auto; padding: 1.5rem; }
.modal-footer { padding: 1rem; border-top: 1px solid var(--border); margin-top: auto; flex-shrink: 0; }

/* Cart & Wishlist Item Styles */
.cart-item, .wishlist-item {
    display: grid; grid-template-columns: 64px 1fr auto; gap: 1rem; align-items: center;
    padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border);
}
.cart-item:last-child, .wishlist-item:last-child { border-bottom: none; }
.cart-item img, .wishlist-item img { width: 64px; height: 64px; object-fit: contain; background: var(--bg-alt); border-radius: 8px; }
.ci-title, .wi-title { margin: 0; }
.ci-sub, .wi-sub { color: var(--text-dim); font-size: 0.9rem; }
.qty-controls { display: flex; align-items: center; gap: 0.5rem; }
.qty-controls button { width: 28px; height: 28px; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 50%; cursor: pointer; }
.remove-item-btn { color: var(--danger); background: none; border: none; cursor: pointer; font-size: 0.9rem; }

/* Product Detail Modal */
.product-detail-body { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.pd-gallery .main-image { width: 100%; aspect-ratio: 1/1; background: var(--bg-alt); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.pd-gallery .main-image img { width: 100%; height: 100%; object-fit: contain; }
.pd-content h3 { font-size: 1.8rem; margin: 0 0 0.5rem; }
.pd-content .brand { font-size: 1rem; color: var(--text-dim); margin-bottom: 1rem; }
.pd-content .desc { line-height: 1.7; }
.pd-specs { list-style: none; padding: 0; margin: 1.5rem 0; font-size: 0.9rem; }
.pd-specs li { display: flex; justify-content: space-between; padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.pd-specs li:last-child { border: none; }
.pd-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.5rem; }
.pd-price { font-size: 1.5rem; font-weight: 700; }
.pd-actions { display: flex; gap: 1rem; }
.pd-actions .btn-primary { flex-grow: 1; }
.pd-actions .wishlist-btn.active { color: var(--pink); border-color: var(--pink); background-color: rgba(219, 97, 162, 0.1); }

/* Checkout & Invoice */
.checkout-form { display: grid; gap: 1rem; }
.checkout-form input, .checkout-form textarea, .checkout-form select { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 0.8rem; font-size: 1rem; }
.checkout-form *:invalid { border-color: var(--danger); }
.form-row-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.checkbox-row { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.form-actions { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1rem; }

/* General Buttons */
.btn-primary { background: var(--accent); color: white; border: none; padding: 0.8rem 1.5rem; border-radius: 8px; font-weight: 600; cursor: pointer; transition: var(--transition); display: flex; align-items: center; justify-content: center; gap: 0.5rem; width: 100%; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); padding: 0.8rem 1.5rem; border-radius: 8px; font-weight: 600; cursor: pointer; transition: var(--transition); display: flex; align-items: center; justify-content: center; gap: 0.5rem; }
.btn-secondary:hover { border-color: var(--text-dim); }

/* Add to Cart Fly Animation */
.fly-to-cart {
    position: fixed; z-index: 100; border-radius: 50%;
    transition: all 0.7s cubic-bezier(0.5, 0, 1, 0.5); pointer-events: none;
}

/* Media Queries */
@media (max-width: 900px) { .product-detail-body { grid-template-columns: 1fr; } }
@media (max-width: 768px) {
  main.container { grid-template-columns: 1fr; }
  .filters-panel { position: static; margin-bottom: 2rem; }
  .hero-section h2 { font-size: 1.8rem; }
}