/* ============================================================
   web-products.css — Product Grid, Cards, Detail, Filters
   Module: Catalog / Product display for public web
   Dependencies: web.css (variables, base styles)
   ============================================================ */

/* ── Filters ── */

.web-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 28px;
  align-items: center;
}

.web-search {
  flex: 1 1 220px;
  padding: 12px 16px;
  font-size: 16px;
  border: 1px solid var(--web-border);
  border-radius: var(--web-radius-sm);
  background: var(--web-card);
  color: var(--web-text);
  outline: none;
  transition: border-color var(--web-transition), box-shadow var(--web-transition);
  min-height: 48px;
}

.web-search::placeholder {
  color: var(--web-text-muted);
}

.web-search:focus {
  border-color: var(--web-primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--web-primary) 14%, transparent);
}

.web-select {
  flex: 0 1 180px;
  padding: 12px 16px;
  font-size: 16px;
  border: 1px solid var(--web-border);
  border-radius: var(--web-radius-sm);
  background: var(--web-card);
  color: var(--web-text);
  outline: none;
  cursor: pointer;
  transition: border-color var(--web-transition), box-shadow var(--web-transition);
  min-height: 48px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
}

.web-select:focus {
  border-color: var(--web-primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--web-primary) 14%, transparent);
}

/* ── Product Grid ── */

.web-products-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.web-product-card {
  background: var(--web-card);
  border-radius: var(--web-radius);
  border: 1px solid var(--web-border);
  box-shadow: var(--web-card-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
}

.web-product-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.14), 0 4px 12px rgba(0,0,0,0.08);
  border-color: color-mix(in srgb, var(--web-primary) 40%, var(--web-border));
}

@media (prefers-color-scheme: dark) {
  .web-product-card:hover {
    box-shadow: 0 12px 40px rgba(0,0,0,0.4), 0 0 24px color-mix(in srgb, var(--web-primary) 15%, transparent);
  }
}

.web-product-img {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--web-bg-alt);
  flex-shrink: 0;
  position: relative;
}

.web-product-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  display: block;
}

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

/* Gradient overlay that appears on hover */
.web-product-img::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(to top, rgba(0,0,0,0.4), transparent);
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

.web-product-card:hover .web-product-img::after {
  opacity: 1;
}

.web-product-no-img {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.8rem;
  color: var(--web-text-muted);
  background: var(--web-bg-alt);
  opacity: 0.4;
}

.web-product-info {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.web-product-name {
  font-size: 0.97rem;
  font-weight: 600;
  color: var(--web-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.web-product-brand {
  font-size: 0.78rem;
  color: var(--web-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.web-product-category {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--web-primary) 10%, transparent);
  color: var(--web-primary);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  width: fit-content;
}

.web-product-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--web-primary) 8%, transparent);
  color: var(--web-primary);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.web-product-price {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--web-primary);
  margin-top: auto;
  padding-top: 8px;
  letter-spacing: -0.01em;
}

.web-product-stock {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  width: fit-content;
}

.web-in-stock {
  background: #ecfdf5;
  color: #065f46;
}

.web-out-stock {
  background: #fef2f2;
  color: #991b1b;
}

@media (prefers-color-scheme: dark) {
  .web-in-stock {
    background: rgba(34,197,94,0.15);
    color: #4ade80;
  }
  .web-out-stock {
    background: rgba(239,68,68,0.15);
    color: #f87171;
  }
}

/* Add to Cart button on product cards */
.web-add-to-cart-btn {
  width: 100%;
  margin-top: 0.85rem;
  justify-content: center;
  font-size: 0.85rem;
  padding: 0.55rem 1rem;
}

/* ── Product Detail ── */

.web-product-detail {
  display: grid;
  grid-template-columns: 1fr;
  gap: 36px;
  padding: clamp(24px, 4vw, 48px) clamp(16px, 4vw, 32px);
  max-width: var(--web-max-width);
  margin-inline: auto;
}

.web-detail-gallery {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.web-detail-main-img {
  width: 100%;
  max-width: 100%;
  border-radius: var(--web-radius);
  border: 1px solid var(--web-border);
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: var(--web-bg-alt);
  transition: border-color var(--web-transition);
}

.web-detail-main-img:hover {
  border-color: color-mix(in srgb, var(--web-primary) 30%, var(--web-border));
}

.web-detail-thumbs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x mandatory;
}

.web-detail-thumbs::-webkit-scrollbar {
  height: 4px;
}

.web-detail-thumb {
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  border-radius: var(--web-radius-sm);
  overflow: hidden;
  border: 2px solid var(--web-border);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity var(--web-transition), border-color var(--web-transition), transform var(--web-transition);
  scroll-snap-align: start;
}

.web-detail-thumb:hover {
  opacity: 0.85;
  border-color: color-mix(in srgb, var(--web-primary) 50%, var(--web-border));
  transform: scale(1.05);
}

.web-detail-thumb.active {
  opacity: 1;
  border-color: var(--web-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--web-primary) 20%, transparent);
}

.web-detail-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.web-detail-info {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.web-detail-name {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 800;
  color: var(--web-text);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.web-detail-meta {
  font-size: 0.88rem;
  color: var(--web-text-muted);
  margin-bottom: 4px;
}

.web-detail-price {
  font-size: clamp(1.8rem, 4.5vw, 2.4rem);
  font-weight: 800;
  color: var(--web-primary);
  line-height: 1;
  letter-spacing: -0.02em;
}

.web-detail-wholesale {
  font-size: 0.9rem;
  color: var(--web-text-muted);
  margin-top: -6px;
}

.web-detail-stock {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--web-radius-sm);
  width: fit-content;
}

.web-detail-desc {
  font-size: 0.95rem;
  color: var(--web-text-muted);
  line-height: 1.75;
  border-top: 1px solid var(--web-border);
  padding-top: 20px;
  margin-top: 8px;
}

.web-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--web-primary);
  font-weight: 500;
  font-size: 0.92rem;
  margin-bottom: 1rem;
  transition: transform var(--web-transition);
}

.web-back-link:hover {
  transform: translateX(-4px);
  text-decoration: none;
}

/* ── Pagination ── */

.web-pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 36px;
  flex-wrap: wrap;
}

.web-page-btn {
  min-width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--web-border);
  border-radius: var(--web-radius-sm);
  background: var(--web-card);
  color: var(--web-text);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--web-transition);
}

.web-page-btn:hover:not(.web-page-active) {
  border-color: var(--web-primary);
  color: var(--web-primary);
  transform: translateY(-2px);
  box-shadow: var(--web-glow-primary);
}

.web-page-active {
  background: linear-gradient(135deg, var(--web-primary), color-mix(in srgb, var(--web-primary) 80%, #7c3aed));
  border-color: transparent;
  color: #ffffff;
  pointer-events: none;
  box-shadow: 0 2px 12px color-mix(in srgb, var(--web-primary) 30%, transparent);
}

.web-page-btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* ── Responsive: Products ── */

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

@media (min-width: 768px) {
  .web-products-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .web-product-detail {
    grid-template-columns: 1fr 1fr;
  }
  .web-detail-gallery {
    position: sticky;
    top: calc(var(--web-header-height) + 1.5rem);
    align-self: start;
  }
}

@media (min-width: 1024px) {
  .web-products-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .web-product-detail {
    grid-template-columns: 5fr 4fr;
  }
}

@media (max-width: 768px) {
  .web-products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .web-product-detail {
    grid-template-columns: 1fr;
  }
  .web-filters {
    flex-wrap: wrap;
    gap: 8px;
  }
}

@media (max-width: 430px) {
  .web-filters {
    flex-direction: column;
  }
  .web-search,
  .web-select {
    flex-basis: 100%;
    width: 100%;
  }
}

@media print {
  .web-product-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
  .web-products-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
  .web-filters,
  .web-pagination {
    display: none !important;
  }
}
