/* ── Category Sidebar ─────────────────────────────────── */

.products-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 32px;
  align-items: start;
}

.category-sidebar {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
  padding: 24px 16px;
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #d1d5db transparent;
}

.category-sidebar::-webkit-scrollbar {
  width: 5px;
}

.category-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.category-sidebar::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 10px;
}

.category-sidebar::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

.category-sidebar h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #9ca3af;
  margin-bottom: 16px;
  padding: 0 12px;
}

.category-list {
  list-style: none;
}

.category-list li {
  margin-bottom: 2px;
}

.category-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  text-decoration: none;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.category-list a:hover {
  background: #f9fafb;
  color: #111827;
  border-color: #f3f4f6;
}

.category-list a.active {
  background: #111827;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(17,24,39,0.15);
}

.category-list .cat-count {
  font-size: 12px;
  font-weight: 500;
  color: #9ca3af;
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 28px;
  text-align: center;
}

.category-list a.active .cat-count {
  color: rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.15);
}

/* ── Products Area ─────────────────────────────────────── */

.products-area {
  min-width: 0;
}

.products-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.products-toolbar h2 {
  font-size: 24px;
  font-weight: 700;
  color: #111827;
  letter-spacing: -0.3px;
}

.products-toolbar .result-count {
  font-size: 14px;
  color: #9ca3af;
  font-weight: 400;
  margin-left: 8px;
}

.search-box {
  position: relative;
  max-width: 300px;
  flex: 1;
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  font-size: 14px;
  background: #fff;
  color: #111827;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box input:focus {
  border-color: #111827;
  box-shadow: 0 0 0 3px rgba(17,24,39,0.06);
}

.search-box input::placeholder {
  color: #9ca3af;
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: #9ca3af;
  pointer-events: none;
}

/* ── Product Grid ──────────────────────────────────────── */

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.product-card {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.25s ease;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  border: 1px solid #f3f4f6;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  border-color: transparent;
}

.product-card-img-wrap {
  overflow: hidden;
  background: #fff;
}

.product-card-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: #f8f9fa;
  display: block;
  transition: transform 0.3s ease, opacity 0.4s ease;
  padding: 12px;
  opacity: 0;
}

.product-card-img.img-loaded {
  opacity: 1;
  background: #fff;
}

.product-card:hover .product-card-img {
  transform: scale(1.06);
}

.product-card-img-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: linear-gradient(145deg, #f9fafb, #f3f4f6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: #d1d5db;
}

.product-card-body {
  padding: 14px 16px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  border-top: 1px solid #f3f4f6;
}

.product-card-category {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #6366f1;
  margin-bottom: 6px;
}

.product-card-name {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 4px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card-brand {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 12px;
}

.product-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid #f3f4f6;
}

.product-card-price {
  font-size: 18px;
  font-weight: 700;
  color: #111827;
}

.product-card-rating {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #6b7280;
}

.product-card-rating .stars {
  color: #f59e0b;
  font-size: 14px;
  letter-spacing: -1px;
}

.product-card-stock {
  font-size: 12px;
  font-weight: 600;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-block;
  width: fit-content;
}

.stock-in {
  color: #059669;
  background: #ecfdf5;
}

.stock-low {
  color: #d97706;
  background: #fffbeb;
}

.stock-out {
  color: #dc2626;
  background: #fef2f2;
}

/* ── Loading / empty ───────────────────────────────────── */

.products-loading {
  text-align: center;
  padding: 100px 20px;
  color: #9ca3af;
}

.products-loading .spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #f3f4f6;
  border-top-color: #111827;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.products-empty {
  text-align: center;
  padding: 80px 20px;
  color: #9ca3af;
}

.products-empty .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.products-empty h3 {
  font-size: 18px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 6px;
}

.products-empty p {
  font-size: 14px;
  color: #6b7280;
}

/* ── Responsive ────────────────────────────────────────── */

@media (max-width: 768px) {
  .products-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .category-sidebar {
    position: static;
    padding: 16px;
    max-height: none;
    overflow-y: visible;
  }

  .category-sidebar h3 {
    margin-bottom: 12px;
  }

  .category-list {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .category-list::-webkit-scrollbar {
    display: none;
  }

  .category-list li {
    margin-bottom: 0;
  }

  .category-list a {
    padding: 8px 14px;
    font-size: 13px;
    white-space: nowrap;
    border-radius: 20px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
  }

  .category-list a.active {
    background: #111827;
    border-color: #111827;
  }

  .category-list .cat-count {
    display: none;
  }

  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
  }

  .product-card-body {
    padding: 10px 12px 12px;
  }

  .product-card-img {
    padding: 8px;
  }

  .product-card-price {
    font-size: 16px;
  }

  .products-toolbar h2 {
    font-size: 20px;
  }
}

/* ── Infinite Scroll ─────────────────────────────────── */

#scroll-sentinel {
  display: flex;
  justify-content: center;
  padding: 32px 0;
  min-height: 60px;
}

.load-more-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
}

.load-more-spinner .spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #f3f4f6;
  border-top-color: #111827;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.end-of-list {
  font-size: 13px;
  color: #9ca3af;
  text-align: center;
  padding: 8px 16px;
}

/* ── Discount Styles ─────────────────────────────────── */

.product-card {
  position: relative;
}

.product-card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: #dc2626;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  z-index: 2;
}

.product-card-badge--promo {
  background: #6366f1;
  letter-spacing: 0.3px;
}

.product-card-original-price {
  text-decoration: line-through;
  color: #9ca3af;
  font-size: 13px;
  font-weight: 400;
  margin-left: 4px;
}

.product-card-discount {
  color: #dc2626;
  font-size: 12px;
  font-weight: 600;
  margin-left: 4px;
}
