/* ═══════════════════════════════════════════
   CB Products Widget – Front-end Styles
   ═══════════════════════════════════════════ */

/* CSS custom properties (overridden inline per widget instance) */
.cb-products-widget {
  --cb-brand:      #5a1010;
  --cb-btn-bg:     #6b1212;
  --cb-btn-text:   #ffffff;
  --cb-card-bg:    #ffffff;
  --cb-img-bg:     #f5ede8;
  --cb-tab-active: #6b1212;
  --cb-card-border:   #e8ddd5;
  --cb-card-radius:   14px;
  --cb-btn-radius:    50px;
  --cb-transition:    0.28s cubic-bezier(.4,0,.2,1);

  font-family: 'Lato', sans-serif;
  width: 100%;
}

/* ── Section title ── */
.cb-products-widget__title {
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  font-weight: 700;
  color: var(--cb-brand);
  text-align: center;
  margin: 0 0 28px;
}

/* ── Filter bar ── */
.cb-products-widget__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 28px;
}

/* Tabs */
.cb-filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cb-filter-tab {
  padding: 8px 20px;
  border: 2px solid var(--cb-card-border);
  border-radius: 50px;
  background: transparent;
  color: #555;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background var(--cb-transition), color var(--cb-transition), border-color var(--cb-transition);
  white-space: nowrap;
}

.cb-filter-tab:hover {
  border-color: var(--cb-tab-active);
  color: var(--cb-tab-active);
}

.cb-filter-tab.is-active {
  background: var(--cb-tab-active);
  border-color: var(--cb-tab-active);
  color: #fff;
}

/* Sort select */
.cb-sort-wrap select.cb-sort-select {
  padding: 8px 36px 8px 14px;
  border: 2px solid var(--cb-card-border);
  border-radius: 50px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23555' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 14px center;
  -webkit-appearance: none;
  appearance: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: #444;
  cursor: pointer;
  transition: border-color var(--cb-transition);
}

.cb-sort-wrap select.cb-sort-select:focus {
  outline: none;
  border-color: var(--cb-tab-active);
}

/* ── Product Grid ── */
.cb-products-grid {
  display: grid;
  gap: 24px;
  min-height: 200px;
  position: relative;
}

.cb-grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.cb-grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.cb-grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.cb-grid-cols-5 { grid-template-columns: repeat(5, 1fr); }

/* ── Loading spinner ── */
.cb-products-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255,255,255,0.85);
  z-index: 5;
}

.cb-products-loader span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--cb-brand);
  animation: cb-bounce 0.9s ease-in-out infinite;
}
.cb-products-loader span:nth-child(2) { animation-delay: 0.15s; }
.cb-products-loader span:nth-child(3) { animation-delay: 0.3s; }

@keyframes cb-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* ── Product Card ── */
.cb-product-card {
  background: var(--cb-card-bg);
  border: 1px solid var(--cb-card-border);
  border-radius: var(--cb-card-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 16px rgba(90,16,16,0.08);
  transition: transform var(--cb-transition), box-shadow var(--cb-transition);
  animation: cb-fade-in 0.35s ease both;
}

@keyframes cb-fade-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cb-product-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 8px 32px rgba(90,16,16,0.18);
}

/* Image wrapper */
.cb-product-card__image-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--cb-img-bg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.cb-product-card__image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform var(--cb-transition);
  display: block;
}

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

/* Card body */
.cb-product-card__body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 8px;
}

/* Title */
a.cb-product-card__title {
  font-size: 0.93rem;
  font-weight: 700;
  color: var(--cb-brand);
  text-decoration: none;
  line-height: 1.4;
  display: block;
}

a.cb-product-card__title:hover { text-decoration: underline; }

/* Price */
.cb-product-card__price {
  font-size: 0.9rem;
  color: #444;
}

.cb-product-card__price .woocommerce-Price-amount {
  font-weight: 700;
  color: var(--cb-brand);
}

.cb-product-card__price del { opacity: 0.55; margin-right: 4px; }

.cb-product-card__spacer { flex: 1; }

/* CTA button */
a.cb-product-card__btn {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: var(--cb-btn-bg);
  color: var(--cb-btn-text) !important;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  text-decoration: none !important;
  border-radius: var(--cb-btn-radius);
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(107,18,18,0.2);
  transition: background var(--cb-transition), transform var(--cb-transition), box-shadow var(--cb-transition);
  margin-top: 4px;
}

a.cb-product-card__btn:hover {
  background: rgba(0, 0, 0, 0.15);
  filter: brightness(0.85);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(107,18,18,0.3);
}

/* ── No results ── */
.cb-no-products {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 0;
  color: #888;
  font-size: 1rem;
}

/* ── Load More ── */
.cb-load-more-wrap {
  text-align: center;
  margin-top: 36px;
}

.cb-load-more {
  padding: 13px 40px;
  background: transparent;
  color: var(--cb-btn-bg);
  border: 2px solid var(--cb-btn-bg);
  border-radius: var(--cb-btn-radius);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background var(--cb-transition), color var(--cb-transition);
}

.cb-load-more:hover {
  background: var(--cb-btn-bg);
  color: #fff;
}

.cb-load-more:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .cb-grid-cols-5 { grid-template-columns: repeat(3, 1fr); }
  .cb-grid-cols-4 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .cb-grid-cols-5,
  .cb-grid-cols-4,
  .cb-grid-cols-3 { grid-template-columns: repeat(2, 1fr); }

  .cb-products-widget__bar {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .cb-grid-cols-5,
  .cb-grid-cols-4,
  .cb-grid-cols-3,
  .cb-grid-cols-2 { grid-template-columns: repeat(2, 1fr); }

  .cb-products-grid { gap: 14px; }
  .cb-product-card__body { padding: 12px 14px 14px; }
  .cb-filter-tab { padding: 6px 14px; font-size: 0.8rem; }
}
