/* ═══════════════════════════════════════════════════════════════
   products.css — Product grid, cards, loading states
   ═══════════════════════════════════════════════════════════════ */

/* ── Product section wrapper ─────────────────────────────────── */
.product-section, .reco-section {
  width: 100%;
  padding: 2rem 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
}

.reco-section-label {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin: 0 0 1.25rem 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── 5-column grid ───────────────────────────────────────────── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1.25rem;
  width: 100%;
}

.main-section-label {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin: 0 0 1.25rem 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.main-section-label::before {
  content: "📂";
  font-size: 1.3rem;
}

/* ── Filter & Sort Row ── */
.filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.filter-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px; /* for scrollbar */
}
@media (max-width: 768px) {
  .filter-pills { display: none; }
}
.filter-pills::-webkit-scrollbar { display: none; }
.filter-pill {
  padding: 6px 14px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all .2s;
}
.filter-pill:hover, .filter-pill.active {
  background: var(--text-primary);
  color: var(--bg-solid);
  border-color: var(--text-primary);
}
.sort-dropdown select {
  padding: 6px 12px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--input-text);
  cursor: pointer;
  background: var(--input-bg);
  outline: none;
}

/* ── Product card ────────────────────────────────────────────── */
.product-card {
  background: var(--bg-surface);
  border-radius: var(--pg-radius);
  box-shadow: var(--pg-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--pg-transition), box-shadow var(--pg-transition);
}

.product-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 30px rgba(0,0,0,.12);
}

/* ── Stock Badge ── */
.card-stock-badge {
  position: absolute;
  bottom: 8px;
  left: 8px;
  font-size: .65rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  color: var(--accent-inverted-text);
  z-index: 2;
  pointer-events: none;
  background: var(--text-secondary);
}
.card-stock-badge.out-of-stock { background: var(--text-primary); }
.card-stock-badge.low-stock { background: var(--text-muted); }

/* ── Image Placeholder ── */
.css-placeholder {
  width: 100%;
  height: 100%;
  background-color: var(--skeleton-bg);
  background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" fill="%23d4d4d4" xmlns="http://www.w3.org/2000/svg"><path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/></svg>');
  background-repeat: no-repeat;
  background-position: center calc(50% - 10px);
  background-size: 3rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.css-placeholder::after {
  content: "No picture available";
  position: absolute;
  top: calc(50% + 20px);
  left: 0;
  width: 100%;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Image wrap (holds the Quick View button) */
.card-img-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  background: var(--bg-surface-alt);
}

.card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--pg-transition);
}

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


/* Card text area */
.card-info {
  padding: .85rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  flex: 1;
}

.card-name {
  font-size: .9rem;
  font-weight: 600;
  color: var(--pg-txt);
  margin: 0;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-price {
  font-size: 1rem;
  font-weight: 700;
  color: var(--pg-accent);
  margin: 0;
}

/* Add to Cart button */
.btn-cart {
  margin-top: auto;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--pg-accent);
  border: 1.5px solid var(--pg-accent);
  border-radius: 8px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transform: translateY(4px);
  transition: background var(--pg-transition), color var(--pg-transition), transform var(--pg-transition);
}

.product-card:hover .btn-cart {
  transform: translateY(0);
}

.btn-cart:hover {
  background: var(--pg-accent);
  color: var(--accent-inverted-text);
}

/* ── Skeleton Loading ───────────────────────────────────────────── */
.skeleton-card {
  pointer-events: none;
}
.skeleton-box {
  background-color: var(--skeleton-bg);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}
.skeleton-box::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  animation: shimmer 1.5s infinite;
  transform: translateX(-100%);
}
@keyframes shimmer { 100% { transform: translateX(100%); } }

.skeleton-img { height: 100%; width: 100%; border-radius: 0; }
.skeleton-title { height: 16px; margin-bottom: 8px; width: 80%; }
.skeleton-price { height: 18px; margin-bottom: 12px; width: 40%; }
.skeleton-btn { height: 32px; border-radius: 8px; width: 100%; margin-top: auto; }

.pg-error,
.no-products {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  color: var(--pg-muted);
}

.pg-error { color: var(--text-primary); }

/* ── Responsive grid ─── */
@media (max-width: 1280px) {
  .product-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 1024px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 640px) {
  .product-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 380px) {
  .product-grid { grid-template-columns: 1fr; }
}

/* ── Mobile/Tablet Responsive Fixes ── */
@media (max-width: 768px) {
  .card-info > div[style*="display:flex"] {
    gap: 4px !important;
  }
  .btn-cart {
    font-size: 0.75rem;
    height: 32px;
    padding: 0 6px;
    min-width: 0; /* Allow shrinking below min-content */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
