/* =========================================================
   INDUSTRIAL 505 — catalogo.css
   (usa las variables/tokens definidos en styles.css)
   ========================================================= */

/* ---------- Encabezado de la página ---------- */
.catalog-hero {
  padding-top: calc(var(--header-h) + var(--space-lg));
  padding-bottom: var(--space-lg);
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
  color: var(--white);
}
.catalog-hero .eyebrow { color: var(--safety); }
.catalog-hero .eyebrow::before { background: repeating-linear-gradient(45deg, var(--white) 0 4px, var(--safety) 4px 8px); }
.catalog-hero h1 { color: var(--white); text-transform: uppercase; font-size: clamp(1.7rem, 4vw, 2.4rem); margin-top: var(--space-xs); }
.catalog-hero p { color: rgba(255,255,255,0.72); margin-top: 8px; max-width: 56ch; }

/* ---------- Buscador con sugerencias ---------- */
.search-wrap { position: relative; margin-top: var(--space-lg); max-width: 560px; }
.search-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.08);
  border: 1.5px solid rgba(255,255,255,0.18);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.2rem 0.2rem 1rem;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.search-input-row:focus-within { border-color: var(--safety); background: rgba(255,255,255,0.12); }
.search-input-row svg { width: 18px; height: 18px; color: rgba(255,255,255,0.6); flex-shrink: 0; }
.search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--white);
  padding: 0.75rem 0;
  font-size: 0.95rem;
  min-width: 0;
}
.search-input::placeholder { color: rgba(255,255,255,0.45); }
.search-input:focus { outline: none; }
.search-clear {
  width: 30px; height: 30px;
  display: none;
  align-items: center; justify-content: center;
  color: rgba(255,255,255,0.6);
  border-radius: 50%;
  flex-shrink: 0;
}
.search-clear.is-visible { display: flex; }
.search-clear:hover { background: rgba(255,255,255,0.12); color: var(--white); }
.search-clear svg { width: 16px; height: 16px; }

/* FIX #1: el listado de sugerencias quedaba tapado por la barra de filtros
   porque ambos compartían el mismo z-index (40) y la barra de filtros va
   después en el HTML. Ahora el buscador siempre queda por encima, y se le
   agrega scroll interno para que tampoco se salga de la pantalla en móviles. */
.search-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  max-height: min(360px, 60vh);
  z-index: 500;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  -webkit-overflow-scrolling: touch;
}
.search-suggestions.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--fog);
  transition: background-color 0.12s ease;
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover, .suggestion-item.is-active { background: var(--off-white); }
.suggestion-thumb {
  width: 34px; height: 34px;
  border-radius: 7px;
  background: var(--fog);
  overflow: hidden;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--steel-gray-light);
}
.suggestion-text { flex: 1; min-width: 0; }
.suggestion-text .name { font-size: 0.87rem; font-weight: 700; color: var(--heading); }
.suggestion-text .meta { font-size: 0.76rem; color: var(--steel-gray); }
.suggestion-price { font-family: var(--font-display); font-size: 0.85rem; color: var(--heading); flex-shrink: 0; }
.suggestion-empty { padding: 16px; text-align: center; color: var(--steel-gray); font-size: 0.85rem; }

/* ---------- Barra de filtros ---------- */
.filters-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--fog);
  padding-block: var(--space-sm);
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.filter-select-wrap { display: flex; align-items: center; gap: 8px; }
.filter-select-wrap label { font-size: 0.78rem; font-weight: 700; color: var(--steel-gray); white-space: nowrap; }

.filter-select {
  padding: 0.55rem 2.1rem 0.55rem 0.85rem;
  font-size: 0.85rem;
  color: var(--heading);
  background: var(--off-white) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%235C6670" stroke-width="2"><path d="m6 9 6 6 6-6"/></svg>') no-repeat right 0.6rem center / 14px;
  border: 1.5px solid var(--fog);
  border-radius: var(--radius-sm);
  appearance: none;
  cursor: pointer;
  transition: border-color 0.15s ease;
  max-width: 100%;
}
.filter-select:focus { outline: none; border-color: var(--steel-blue); }

.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-chip {
  padding: 0.5rem 0.95rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--steel-gray);
  background: var(--off-white);
  border: 1.5px solid var(--fog);
  border-radius: 999px;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.filter-chip:hover { border-color: var(--steel-blue); color: var(--steel-blue); }
.filter-chip.is-active { background: var(--navy); border-color: var(--navy); color: var(--safety); }

.filters-meta {
  margin-left: auto;
  font-size: 0.82rem;
  color: var(--steel-gray);
  white-space: nowrap;
}

.filters-clear {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--steel-blue);
  white-space: nowrap;
}
.filters-clear:hover { text-decoration: underline; }

/* ---------- Grid de resultados ---------- */
.catalog-results { padding-block: var(--space-2xl); }

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}
@media (min-width: 640px) { .catalog-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .catalog-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1440px) { .catalog-grid { grid-template-columns: repeat(5, 1fr); } }
@media (min-width: 1800px) { .catalog-grid { grid-template-columns: repeat(6, 1fr); } }

/* ---------- Estado vacío (catálogo sin productos / sin resultados) ---------- */
.catalog-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
  border: 1px dashed var(--steel-gray-light);
  border-radius: var(--radius-lg);
  background: var(--off-white);
}
.catalog-empty-icon {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--steel-blue);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
}
.catalog-empty-icon svg { width: 28px; height: 28px; }
.catalog-empty h3 { font-size: 1.1rem; text-transform: uppercase; }
.catalog-empty p { color: var(--steel-gray); margin-top: 6px; max-width: 42ch; }

/* ---------- Tarjeta de producto ---------- */
.catalog-card {
  background: var(--surface);
  border: 1px solid var(--fog);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}
.catalog-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); }

/* FIX #2: las imágenes se veían cortadas por "object-fit: cover".
   Ahora se ve la imagen COMPLETA con "object-fit: contain" y un poco de
   padding en el contenedor para que no quede pegada a los bordes. */
.catalog-card-media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--fog);
  display: flex; align-items: center; justify-content: center;
  color: var(--steel-gray-light);
  padding: 12px;
  box-sizing: border-box;
}
.catalog-card-media img { width: 100%; height: 100%; object-fit: contain; }
.catalog-card-media svg { width: 44px; height: 44px; }

.stock-badge {
  position: absolute;
  top: 10px; left: 10px;
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 4px;
}
.stock-badge.available { background: #EAF6EF; color: #1E7B45; }
.stock-badge.out { background: #FCEEEC; color: #A8352A; }

.discount-badge {
  position: absolute;
  top: 10px; right: 10px;
  background: var(--safety);
  color: var(--navy-2);
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
}

.catalog-card-body {
  padding: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-grow: 1;
}

.catalog-card-brand { font-size: 0.7rem; color: var(--steel-gray-light); text-transform: uppercase; letter-spacing: 0.5px; }
.catalog-card-name { font-size: 0.92rem; font-weight: 700; color: var(--ink); line-height: 1.3; min-height: 2.4em; }

.catalog-price-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.catalog-price-current { font-family: var(--font-display); font-size: 1.2rem; color: var(--heading); font-weight: 600; }
.catalog-price-old { font-size: 0.8rem; color: var(--steel-gray-light); text-decoration: line-through; }
/* .price-iva-tag ahora vive en css/styles.css (compartido con index.html) */

.catalog-card-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.catalog-card-actions .btn { width: 100%; }
.btn-icon-row { display: flex; gap: 6px; }
.btn-icon-row .btn { flex: 1; padding-inline: 0.5rem; }
.btn-icon-row .btn svg { width: 15px; height: 15px; }

.btn[disabled], .btn.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* ---------- Paginación ---------- */
.pagination {
  margin-top: var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 38px;
  height: 38px;
  padding-inline: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--heading);
  background: var(--surface);
  border: 1.5px solid var(--fog);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.page-btn:hover { border-color: var(--steel-blue); color: var(--steel-blue); }
.page-btn.is-active { background: var(--navy); border-color: var(--navy); color: var(--safety); }
.page-btn:disabled { opacity: 0.4; pointer-events: none; }
.page-btn svg { width: 16px; height: 16px; }
.page-dots { color: var(--steel-gray-light); padding-inline: 4px; }

/* ---------- Carrito flotante ---------- */
.cart-float {
  position: fixed;
  right: 20px;
  bottom: 88px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--safety);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 90;
  transition: transform 0.2s ease;
}
.cart-float:hover { transform: scale(1.08); }
.cart-float svg { width: 24px; height: 24px; }
.cart-float-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 20px; height: 20px;
  padding-inline: 4px;
  border-radius: 999px;
  background: var(--safety);
  color: var(--navy-2);
  font-size: 0.7rem;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--white);
}

/* ---------- Panel lateral del carrito ---------- */
.cart-overlay {
  position: fixed; inset: 0;
  background: rgba(7,26,51,0.5);
  z-index: 150;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.cart-overlay.is-visible { opacity: 1; visibility: visible; }

.cart-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  z-index: 160;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  box-shadow: var(--shadow-lg);
}
.cart-panel.is-open { transform: translateX(0); }

.cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border-bottom: 1px solid var(--fog);
}
.cart-header h3 { font-size: 1rem; text-transform: uppercase; }

.cart-items { flex: 1; overflow-y: auto; padding: var(--space-sm) var(--space-md); }

.cart-empty { text-align: center; color: var(--steel-gray); padding: var(--space-2xl) var(--space-sm); }
.cart-empty svg { width: 40px; height: 40px; color: var(--steel-gray-light); margin-bottom: 10px; }

.cart-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--fog);
}
.cart-item-media {
  width: 56px; height: 56px;
  border-radius: 8px;
  background: var(--fog);
  overflow: hidden;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--steel-gray-light);
}
.cart-item-body { flex: 1; min-width: 0; }
.cart-item-name { font-size: 0.86rem; font-weight: 700; color: var(--heading); }
.cart-item-price { font-size: 0.82rem; color: var(--steel-gray); margin-top: 2px; }

.qty-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.qty-btn {
  width: 24px; height: 24px;
  border-radius: 6px;
  background: var(--fog);
  color: var(--heading);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.qty-btn:hover { background: var(--steel-blue); color: var(--white); }
.qty-value { font-size: 0.85rem; font-weight: 700; min-width: 18px; text-align: center; }
.cart-item-remove { margin-left: auto; color: var(--steel-gray-light); }
.cart-item-remove:hover { color: #A8352A; }
.cart-item-remove svg { width: 16px; height: 16px; }

.cart-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--fog);
}
.cart-total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-sm);
}
.cart-total-row .label { font-size: 0.85rem; color: var(--steel-gray); }
.cart-total-row .value { font-family: var(--font-display); font-size: 1.3rem; color: var(--heading); }

/* ---------- Modal genérico (overlay) ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(7,26,51,0.55);
  z-index: 170;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.modal-overlay.is-visible { opacity: 1; visibility: visible; }
.modal-overlay .panel {
  background: var(--surface);
  border: 1px solid var(--fog);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  box-shadow: var(--shadow-lg);
  max-width: 640px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
}
@media (min-width: 640px) { .modal-overlay .panel { padding: var(--space-lg); } }
.modal-close-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  color: var(--steel-gray);
  flex-shrink: 0;
}
.modal-close-btn:hover { background: var(--fog); color: var(--heading); }
.modal-close-btn svg { width: 18px; height: 18px; }
.modal-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

/* ---------- Lightbox de imagen (ficha técnica) ----------
   FIX #3: en vez de forzar la descarga de un PDF, la ficha técnica ahora
   se muestra como imagen, dentro del mismo sitio, en un visor a pantalla
   completa que se puede cerrar con la X, con clic afuera o con Escape. */
.img-lightbox {
  position: fixed; inset: 0;
  background: rgba(7,26,51,0.88);
  z-index: 220;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg) var(--space-md);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.img-lightbox.is-visible { opacity: 1; visibility: visible; }
.img-lightbox-inner {
  position: relative;
  max-width: min(900px, 94vw);
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.img-lightbox img {
  display: block;
  max-width: 100%;
  max-height: 90vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.img-lightbox-close {
  position: absolute;
  top: -14px; right: -14px;
  background: var(--navy);
  color: var(--white);
  box-shadow: var(--shadow-md);
}
.img-lightbox-close:hover { background: var(--navy-2); color: var(--safety); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  max-width: min(360px, calc(100vw - 40px));
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-md);
  background: var(--navy);
  color: var(--white);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.22s ease, opacity 0.22s ease, visibility 0.22s;
  z-index: 300;
  font-size: 0.88rem;
}
.toast.is-visible { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; color: var(--safety); }

/* ---------- Utilidad ---------- */
.text-muted { color: var(--steel-gray); }
.sheet-modal-body { display: grid; grid-template-columns: 1fr; gap: var(--space-md); }
@media (min-width: 600px) { .sheet-modal-body { grid-template-columns: 1fr 1.2fr; } }
.sheet-media {
  aspect-ratio: 1/1;
  border-radius: var(--radius-md);
  background: var(--fog);
  display: flex; align-items: center; justify-content: center;
  color: var(--steel-gray-light);
  overflow: hidden;
  padding: 14px;
  box-sizing: border-box;
}
.sheet-media img { width: 100%; height: 100%; object-fit: contain; }
.sheet-media svg { width: 44px; height: 44px; }
.sheet-info .brand { font-size: 0.78rem; color: var(--steel-gray-light); text-transform: uppercase; letter-spacing: 0.5px; }
.sheet-info h3 { font-size: 1.15rem; text-transform: uppercase; margin-top: 4px; }
.sheet-info .price { font-family: var(--font-display); font-size: 1.4rem; color: var(--heading); margin-top: 8px; }
.sheet-info .desc { font-size: 0.9rem; color: var(--steel-gray); margin-top: 10px; line-height: 1.6; }
.sheet-info .specs { font-size: 0.86rem; color: var(--ink); margin-top: 10px; white-space: pre-line; background: var(--off-white); padding: 10px 12px; border-radius: var(--radius-sm); }
.sheet-info .sheet-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: var(--space-md); }
.sheet-info .sheet-actions .btn { flex: 1 1 auto; min-width: 160px; text-align: center; }

/* =========================================================
   FIX #4 — RESPONSIVE TOTAL
   Ajustes adicionales para que el catálogo se vea bien en
   cualquier teléfono, tablet, laptop o monitor grande.
   ========================================================= */

/* Pantallas grandes / monitores anchos: ya cubierto arriba con
   los breakpoints de 1440px y 1800px en .catalog-grid. */

/* Tablets y pantallas medianas */
@media (max-width: 900px) {
  .filters-meta { margin-left: 0; }
}

/* Teléfonos (general) */
@media (max-width: 640px) {
  .catalog-hero { padding-top: calc(var(--header-h) + var(--space-md)); padding-bottom: var(--space-md); }
  .catalog-hero p { max-width: 100%; }
  .search-wrap { max-width: 100%; margin-top: var(--space-md); }

  .filters-row { gap: 10px; }
  .filter-select-wrap { width: 100%; }
  .filter-select-wrap .filter-select { flex: 1; min-width: 0; }
  .filter-chips { width: 100%; }
  .filters-clear { order: 3; }
  .filters-meta { order: 4; width: 100%; }

  .catalog-grid { gap: var(--space-sm); }
  .catalog-card-name { font-size: 0.86rem; min-height: 2.2em; }
  .catalog-price-current { font-size: 1.05rem; }

  .cart-panel { max-width: 100%; }
  .modal-overlay { padding: var(--space-sm); }
  .modal-overlay .panel { padding: var(--space-md); max-height: 92vh; }

  .sheet-info .sheet-actions { flex-direction: column; }
  .sheet-info .sheet-actions .btn { width: 100%; min-width: 0; }

  .img-lightbox-close { top: -10px; right: 6px; }
}

/* Teléfonos muy pequeños */
@media (max-width: 380px) {
  .catalog-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .btn-icon-row { flex-direction: column; }
  .btn-icon-row .btn { width: 100%; }
  .catalog-card-body { padding: 10px; }
  .cart-float { right: 14px; bottom: 78px; width: 50px; height: 50px; }
  .cart-float svg { width: 20px; height: 20px; }
}
