/* =============================================================
   Choose Products — v2.0 Frontend
   Design: Editorial minimal. Cards are tight units.
   Image box has an explicit height (Slider-controlled).
   Body content flows naturally below — never stretches.
============================================================= */

.cp-widget {
  --cp-accent:   #2563eb;
  --cp-text:     #111827;
  --cp-muted:    #6b7280;
  --cp-border:   #e5e7eb;
  --cp-radius:   10px;
  --cp-ease:     0.18s ease;
  font-family: inherit;
  color: var(--cp-text);
  width: 100%;
  box-sizing: border-box;
}

*, *::before, *::after { box-sizing: inherit; }

/* ── Toolbar ─────────────────────────────────────────────── */
.cp-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}

.cp-search-wrap {
  position: relative;
  flex: 1 1 180px;
  min-width: 140px;
}
.cp-search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--cp-muted);
  pointer-events: none;
}
.cp-search {
  width: 100%;
  height: 36px;
  padding: 0 10px 0 30px;
  border: 1px solid var(--cp-border);
  border-radius: 6px;
  background: #f9fafb;
  font-size: 13px;
  color: var(--cp-text);
  outline: none;
  transition: border-color var(--cp-ease), box-shadow var(--cp-ease);
}
.cp-search::placeholder { color: var(--cp-muted); }
.cp-search:focus {
  border-color: var(--cp-accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.cp-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}
.cp-select-wrap svg {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--cp-muted);
}
.cp-select {
  height: 36px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--cp-border);
  border-radius: 6px;
  background: #f9fafb;
  font-size: 13px;
  color: var(--cp-text);
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color var(--cp-ease);
}
.cp-select:focus {
  border-color: var(--cp-accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* ── Grid ────────────────────────────────────────────────── */
.cp-grid {
  display: grid;
  gap: 16px;
  /* Default: overridden by Elementor slider */
  grid-template-columns: repeat(3, 1fr);
  /* Cards sit at the top — never stretch to fill row height */
  align-items: start;
}
.cp-cols-1 { grid-template-columns: repeat(1, 1fr); }
.cp-cols-2 { grid-template-columns: repeat(2, 1fr); }
.cp-cols-3 { grid-template-columns: repeat(3, 1fr); }
.cp-cols-4 { grid-template-columns: repeat(4, 1fr); }
.cp-cols-5 { grid-template-columns: repeat(5, 1fr); }

@media (max-width: 900px) {
  .cp-cols-4, .cp-cols-5 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .cp-cols-3, .cp-cols-4, .cp-cols-5 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 380px) {
  .cp-grid { grid-template-columns: 1fr !important; }
}

/* ── Card ────────────────────────────────────────────────── */
/*
   THE KEY RULE: the card is display:block — not flex, not grid.
   It has no height set. It grows to exactly fit its contents.
   No more black voids.
*/
.cp-card {
  background: #fff;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius);
  overflow: hidden;
  /* Natural block flow — shrinks to content */
  display: block;
  width: 100%;
  transition: box-shadow var(--cp-ease), transform var(--cp-ease);
}
.cp-card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,.1);
  transform: translateY(-2px);
}

/* ── Image box ───────────────────────────────────────────── */
/*
   Fixed pixel height — controlled by the Elementor slider.
   Default 220px. Image fills with object-fit:cover.
   If no image: a neutral placeholder shows instead.
   CRITICALLY: this element never grows beyond its set height.
*/
.cp-card__img-link {
  display: block;
  position: relative;
  text-decoration: none;
  line-height: 0; /* kill inline gap */
}

.cp-card__img-box {
  width: 100%;
  height: 220px; /* default — overridden by Elementor selector */
  overflow: hidden;
  background: #f1f5f9;
  display: block;
  position: relative;
}

.cp-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform 0.3s ease;
}
.cp-card:hover .cp-card__img { transform: scale(1.04); }

/* No-image placeholder — same height as the image box */
.cp-card__no-img {
  width: 100%;
  height: 220px; /* matches --image-height default */
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d1d5db;
  position: relative;
}

/* Badges */
.cp-badge-sale,
.cp-badge-oos {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
  color: #fff;
  line-height: 1.5;
  pointer-events: none;
}
.cp-badge-sale { background: var(--cp-accent); }
.cp-badge-oos  { background: #9ca3af; }
.cp-badge-inline {
  position: static;
  display: inline-block;
  margin-top: 6px;
}

/* ── Card body ───────────────────────────────────────────── */
/*
   padding set by Elementor slider.
   Natural block flow — rows stack with small gaps.
   No flex, no min-height, no margin-top:auto tricks.
*/
.cp-card__body {
  padding: 14px;
  /* nothing else — pure block flow */
}

.cp-card__cat {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--cp-muted);
  margin-bottom: 4px;
  line-height: 1.2;
}

.cp-card__title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}
.cp-card__title a {
  color: var(--cp-text);
  text-decoration: none;
  transition: opacity var(--cp-ease);
}
.cp-card__title a:hover { opacity: .65; }

/* Stars */
.cp-card__stars {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-bottom: 8px;
}
.cp-star { flex-shrink: 0; }
.cp-star--full  { color: #f59e0b; }
.cp-star--half  { color: #f59e0b; opacity: .55; }
.cp-star--empty { color: #d1d5db; }
.cp-card__reviews {
  font-size: 11px;
  color: var(--cp-muted);
  margin-left: 3px;
}

/* Footer row */
.cp-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--cp-border);
  flex-wrap: wrap;
}

.cp-card__price {
  font-size: 15px;
  font-weight: 700;
  color: var(--cp-text);
  line-height: 1.2;
}
.cp-card__price del {
  font-weight: 400;
  font-size: 12px;
  color: #9ca3af;
  margin-right: 2px;
}
.cp-card__price ins {
  text-decoration: none;
}

.cp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 13px;
  background: var(--cp-accent);
  color: #fff !important;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none !important;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.5;
  transition: filter var(--cp-ease), transform 0.12s ease;
  flex-shrink: 0;
}
.cp-btn:hover {
  filter: brightness(1.12);
  transform: scale(1.02);
}
.cp-btn--disabled {
  background: #e5e7eb !important;
  color: #9ca3af !important;
  cursor: not-allowed;
  pointer-events: none;
  filter: none !important;
  transform: none !important;
}

/* ── Loader ──────────────────────────────────────────────── */
.cp-results { position: relative; min-height: 60px; }
.cp-loader {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.7);
  border-radius: var(--cp-radius);
}
.cp-spin {
  width: 26px;
  height: 26px;
  border: 2.5px solid var(--cp-border);
  border-top-color: var(--cp-accent);
  border-radius: 50%;
  animation: cp-spin .6s linear infinite;
}
@keyframes cp-spin { to { transform: rotate(360deg); } }

/* ── Empty state ─────────────────────────────────────────── */
.cp-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 20px;
  color: var(--cp-muted);
  font-size: 13px;
  grid-column: 1 / -1;
}

/* ── Pagination ──────────────────────────────────────────── */
.cp-pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  margin-top: 24px;
}
.cp-page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--cp-border);
  border-radius: 6px;
  background: #fff;
  color: var(--cp-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all var(--cp-ease);
}
.cp-page-btn:hover:not(:disabled) {
  border-color: var(--cp-accent);
  color: var(--cp-accent);
}
.cp-page-btn.active {
  background: var(--cp-accent);
  border-color: var(--cp-accent);
  color: #fff;
  font-weight: 700;
}
.cp-page-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ── Editor placeholder ──────────────────────────────────── */
.cp-placeholder {
  padding: 40px 20px;
  text-align: center;
  border: 2px dashed var(--cp-border);
  border-radius: var(--cp-radius);
  color: var(--cp-muted);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.cp-placeholder svg { opacity: .35; }
