/* ==========================================================================
   css/catalog.css — Catálogo de productos
   Depende de css/style.css
   ========================================================================== */

.catalog-section { padding: 3rem 0 5rem; }

/* Encabezado de sección */
.section-header    { margin-bottom: 2rem; }
.section-title-wrap { display: flex; flex-direction: column; gap: .35rem; }
.section-badge {
  color: var(--primary); font-size: .82rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
}
.section-title { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; }
.section-desc  { color: var(--text-muted); font-size: .95rem; max-width: 600px; }

/* Barra de filtros */
.filter-bar {
  display: flex; flex-wrap: wrap;
  align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 2rem;
  padding-bottom: 1.25rem; border-bottom: 1px solid var(--border);
}

/* Chips de categoría */
.category-chips { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.category-chips input[type="radio"] {
  position: absolute; opacity: 0; width: 0; height: 0;
}
.chip-btn {
  display: inline-block;
  padding: .42rem 1rem; border-radius: var(--radius-full);
  font-size: .86rem; font-weight: 600;
  background: var(--bg-card); color: var(--text-muted);
  border: 1px solid var(--border); cursor: pointer;
  transition: all var(--t-fast); user-select: none; white-space: nowrap;
}
.chip-btn:hover { border-color: var(--primary); color: var(--primary); }
.chip-btn--sub {
  font-size: .81rem;
  padding: .35rem .85rem;
  border-style: dashed;
  opacity: .95;
}
.category-chips input[type="radio"]:checked + .chip-btn {
  background: var(--primary); color: white;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(37,99,235,.25);
}

/* Sort + contador */
.filter-actions { display: flex; align-items: center; gap: .75rem; }
.sort-select {
  padding: .42rem 1rem; border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--bg-card);
  font-size: .86rem; color: var(--text-main);
  outline: none; cursor: pointer; transition: border-color var(--t-fast);
}
.sort-select:focus { border-color: var(--primary); }
.products-count { font-size: .88rem; color: var(--text-muted); font-weight: 500; white-space: nowrap; }

/* Grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(265px, 1fr));
  gap: 1.75rem; list-style: none; margin: 0; padding: 0;
}

/* Tarjeta */
.product-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden; display: flex; flex-direction: column;
  transition: all var(--t-normal); position: relative;
}
.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
  border-color: var(--border-hover);
}
/* El div clickeable para el modal */
.product-card__link {
  display: flex; flex-direction: column;
  text-decoration: none; color: inherit;
}

/* Nombre arriba de la imagen */
.product-card__header { padding: .9rem 1.1rem .5rem; }
.product-card__name {
  font-size: 1rem; font-weight: 700; color: var(--text-main);
  line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 2.6rem;
  transition: color var(--t-fast);
}
.product-card:hover .product-card__name { color: var(--primary); }

/* Imagen */
.product-card__media {
  position: relative; aspect-ratio: 4/3; width: 100%;
  background: var(--bg-muted); overflow: hidden; flex-shrink: 0;
}
.product-card__img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .5s ease;
}
.product-card:hover .product-card__img { transform: scale(1.07); }

/* Placeholder sin imagen */
.product-card__no-img {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: .5rem;
  color: var(--text-light); font-size: .8rem;
}
.product-card__no-img svg { opacity: .4; }

/* Overlay "Ver producto" */
.card-overlay {
  position: absolute; inset: 0;
  background: rgba(15,23,42,.32); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--t-fast);
}
.product-card:hover .card-overlay { opacity: 1; }

.btn-quick-view {
  background: white; color: var(--text-main);
  padding: .5rem 1.1rem; border-radius: var(--radius-full);
  font-size: .83rem; font-weight: 700;
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; gap: .4rem;
  transform: translateY(10px); transition: all var(--t-fast);
}
.product-card:hover .btn-quick-view { transform: translateY(0); }
.btn-quick-view:hover { background: var(--primary); color: white; }

/* Cuerpo */
.product-card__body {
  padding: .85rem 1.1rem 1rem;
  display: flex; flex-direction: column; flex: 1; gap: .4rem;
}
.product-card__desc {
  font-size: .82rem; color: var(--text-muted); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 2.4rem;
}
.product-card__pricing {
  display: flex; align-items: baseline; gap: .5rem;
  margin-top: auto; padding-top: .35rem;
}
.product-card__price { font-size: 1.3rem; font-weight: 800; color: var(--text-main); }

/* Botones — fuera del área de clic del modal, al pie de la tarjeta */
.card-actions {
  display: grid; grid-template-columns: 1fr auto;
  gap: .55rem;
  padding: 0 1.1rem 1rem;
  margin-top: auto;
}

.btn-view-card {
  padding: .58rem .8rem; border-radius: var(--radius-md);
  background: var(--bg-muted); color: var(--text-main);
  font-size: .85rem; font-weight: 600; text-align: center;
  transition: all var(--t-fast); display: block;
}
.btn-view-card:hover { background: #e2e8f0; color: var(--primary); }

.btn-add-card {
  padding: .58rem 1rem; border-radius: var(--radius-md);
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center; gap: .4rem;
  font-weight: 600; font-size: .85rem; transition: all var(--t-fast);
}
.btn-add-card:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37,99,235,.3);
}

/* Estado vacío */
.catalog-empty {
  grid-column: 1/-1; text-align: center;
  padding: 4rem 1rem; color: var(--text-muted);
}
.catalog-empty-icon { font-size: 2.5rem; margin-bottom: .75rem; }

/* Mostrar más */
#load-more-wrapper {
  display: flex; flex-direction: column;
  align-items: center; gap: .75rem; margin-top: 2.5rem;
}
.btn-load-more {
  padding: .7rem 2rem; background: transparent;
  border: 2px solid var(--primary);
  border-radius: var(--radius-full);
  color: var(--primary); font-size: .92rem; font-weight: 700;
  cursor: pointer; transition: all var(--t-fast);
}
.btn-load-more:hover {
  background: var(--primary); color: white;
  box-shadow: 0 4px 12px rgba(37,99,235,.25);
}
#load-more-indicator { font-size: .8rem; color: var(--text-muted); }

#catalog-results.htmx-request {
  opacity: .55; transition: opacity .2s; pointer-events: none;
}

/* Responsive */
@media (max-width: 768px) {
  .filter-bar { flex-direction: column; align-items: flex-start; }
  .filter-actions { width: 100%; justify-content: space-between; }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
  .section-title { font-size: 1.5rem; }
}
@media (max-width: 420px) {
  .product-grid { grid-template-columns: 1fr; }
}
