/* ==========================================================================
   catalogo.css: pagina Catalogo T02 (SPEC 6 "Catalogo")
   Dark showroom, nivel Carwow: la mercancia manda, sin hero. Header compacto y
   denso (breadcrumb + h1 corto + contador vivo en mono grande), la busqueda IA
   como barra de comando sticky (superficie navy-2 al enfocar), sidebar con
   jerarquia editorial y el grid arrancando above the fold.
   Estilos PROPIOS de esta pagina. Prefijo .cat-. No pisa clases del sistema:
   solo extiende con contenedores/layout y consume tokens.css. Componentes
   (vcard, chip, badge, range-dual, bottom-sheet, pagination, skeleton, field,
   breadcrumbs, btn) vienen de components.css sin redefinir.
   ========================================================================== */

/* Offsets de las piezas sticky. La barra de comando se ancla justo bajo la
   barra principal del header (el topbar delgado se colapsa al scrollear); el
   sidebar se ancla debajo de la barra de comando. */
.cat-body,
.cat-commandbar {
  --cat-cmdbar-top: 64px;
  --cat-sidebar-top: 148px;
}

/* --------------------------------------------------------------------------
   Header de pagina: compacto y denso (sin hero)
   -------------------------------------------------------------------------- */
.cat-head {
  padding-top: var(--space-8);
  padding-bottom: var(--space-4);
}
.cat-head__crumbs {
  margin-bottom: var(--space-4);
}
.cat-head__row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-5) var(--space-8);
  flex-wrap: wrap;
}
.cat-head__lede .section-num {
  margin-bottom: var(--space-2);
}
.cat-head__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-h2);
  letter-spacing: -0.02em;
  line-height: 1.02;
  margin: 0;
}

/* Contador vivo en mono grande (tablero de instrumentos, sello 4) */
.cat-count {
  display: flex;
  align-items: baseline;
  gap: 0.4em;
  margin: 0;
  line-height: 1;
}
.cat-count__num {
  font-weight: 600;
  font-size: clamp(2.25rem, 1.4rem + 3.4vw, 3.5rem);
  line-height: 0.9;
  letter-spacing: -0.04em;
  color: var(--navy);
}
/* Pulso breve al cambiar el resultado (transicion suave del contador) */
.cat-count__num.is-bump {
  animation: cat-count-bump 440ms var(--ease-signature);
}
@keyframes cat-count-bump {
  0% { transform: scale(1); }
  38% { transform: scale(1.12); color: var(--orange-deep); }
  100% { transform: scale(1); }
}
.cat-count__label {
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

/* --------------------------------------------------------------------------
   Barra de comando sticky: la busqueda IA protagonista
   -------------------------------------------------------------------------- */
.cat-commandbar {
  position: sticky;
  top: var(--cat-cmdbar-top);
  z-index: var(--z-sticky);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-block: var(--space-3);
  margin-bottom: var(--space-2);
}

.cat-cmd {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.45rem 0.45rem 0.45rem 1rem;
  background: var(--paper);
  border: 1.5px solid var(--line-2);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-1);
  transition: background var(--t-base), border-color var(--t-base),
    box-shadow var(--t-base);
}
/* Al enfocar, la barra se vuelve superficie navy-2 (command palette) */
.cat-cmd:focus-within {
  background: var(--navy-2);
  border-color: var(--navy-3);
  box-shadow: var(--shadow-2), var(--shadow-focus);
}
.cat-cmd__icon {
  width: 20px;
  height: 20px;
  flex: none;
  color: var(--ink-3);
  transition: color var(--t-base);
}
.cat-cmd:focus-within .cat-cmd__icon {
  color: var(--orange);
}
.cat-cmd__input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  color: var(--ink);
  padding: 0.6rem 0;
  transition: color var(--t-base);
}
.cat-cmd__input:focus {
  outline: none;
}
.cat-cmd__input::placeholder {
  color: var(--ink-3);
}
.cat-cmd:focus-within .cat-cmd__input {
  color: var(--on-navy);
}
.cat-cmd:focus-within .cat-cmd__input::placeholder {
  color: var(--on-navy-50);
}
.cat-cmd__btn {
  flex: none;
}
.cat-cmd__btn-ico {
  display: none;
}
/* Microcopy de la busqueda IA: aparece al enfocar (addendum v2.1 6.1).
   Sobre fondo claro del catalogo el texto va en tinta, no en blanco. */
.cat-cmd__hint {
  margin-top: var(--space-2);
}
.cat-cmd__hint > span {
  color: var(--ink-2);
}
.cat-cmd:focus-within ~ .cat-cmd__hint {
  grid-template-rows: 1fr;
  opacity: 1;
}

/* Leaderboard gestionable bajo la command bar */
.cat-leaderboard {
  margin-top: var(--space-5);
}

/* --------------------------------------------------------------------------
   Sugerencias rapidas
   -------------------------------------------------------------------------- */
.cat-quick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.cat-quick__label {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-right: var(--space-1);
}
.cat-quick .chip {
  font-weight: 500;
}
.cat-quick .chip:hover {
  border-color: var(--orange);
  color: var(--orange-deep);
}

/* --------------------------------------------------------------------------
   Respuesta del asistente (interpretacion IA): superficie propia con borde
   izquierdo naranja y el conteo en mono
   -------------------------------------------------------------------------- */
.cat-assistant {
  display: none;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-5);
  padding: var(--space-4) var(--space-5);
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 3px solid var(--orange);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-1);
}
.cat-assistant.is-visible {
  display: flex;
}
.cat-assistant__avatar {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--orange-tint-10);
  color: var(--orange-deep);
}
.cat-assistant__avatar svg {
  width: 18px;
  height: 18px;
}
.cat-assistant__body {
  flex: 1;
  min-width: 0;
}
.cat-assistant__eyebrow {
  display: block;
  font-size: var(--fs-eyebrow);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--orange-deep);
  margin-bottom: 0.25rem;
}
.cat-assistant__text {
  color: var(--ink);
  font-weight: 500;
  line-height: 1.45;
  margin: 0;
}
.cat-assistant__result {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  padding-left: var(--space-5);
  border-left: 1px solid var(--line);
  text-align: right;
}
.cat-assistant__count {
  font-weight: 600;
  font-size: var(--fs-h3);
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--orange-deep);
}
.cat-assistant__count-label {
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* --------------------------------------------------------------------------
   Cuerpo del catalogo: toolbar + layout (sidebar + grid)
   -------------------------------------------------------------------------- */
.cat-body {
  padding-top: var(--space-6);
  padding-bottom: var(--space-20);
}

/* Toolbar: toggle vendidos + boton filtros (movil) + orden */
.cat-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--space-6);
}

/* Toggle "Ver vendidos" */
.cat-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
  margin-right: auto;
}
.cat-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.cat-switch__track {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: var(--r-pill);
  background: var(--line-2);
  transition: background var(--t-base);
  flex: none;
}
.cat-switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: var(--shadow-1);
  transition: transform var(--t-base);
}
.cat-switch input:checked + .cat-switch__track {
  background: var(--orange);
}
.cat-switch input:checked + .cat-switch__track::after {
  transform: translateX(16px);
}
.cat-switch input:focus-visible + .cat-switch__track {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

/* Orden */
.cat-sort {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.cat-sort__label {
  font-size: var(--fs-sm);
  color: var(--ink-3);
}
.cat-sort .field__select {
  padding-block: 0.55rem;
  min-width: 168px;
}

/* Boton filtros (solo movil) con badge de activos */
.cat-filterbtn {
  display: none;
  align-items: center;
  gap: 0.55em;
  padding: 0.6rem 1rem;
  border: 1.5px solid var(--line-2);
  border-radius: var(--r-sm);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--ink);
  background: var(--paper);
}
.cat-filterbtn__badge {
  display: none;
  min-width: 20px;
  height: 20px;
  padding: 0 0.35rem;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-pill);
  background: var(--orange);
  color: var(--navy);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.cat-filterbtn__badge.is-on {
  display: inline-flex;
}

/* Chips de filtros activos (scrollable en movil) */
.cat-activechips {
  display: none;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.cat-activechips.is-on {
  display: flex;
}
.cat-activechips__clear {
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-2);
  padding: 0.55rem 0.4rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.cat-activechips__clear:hover {
  color: var(--orange-deep);
}

/* Layout de dos columnas */
.cat-layout {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: var(--space-8);
  align-items: start;
}

/* Sidebar sticky de filtros */
.cat-sidebar {
  position: sticky;
  top: var(--cat-sidebar-top);
  max-height: calc(100vh - var(--cat-sidebar-top) - var(--space-4));
  overflow-y: auto;
  padding-right: var(--space-2);
}
.cat-sidebar__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.cat-sidebar__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-h5);
  margin: 0;
}
.cat-sidebar__clear {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-3);
}
.cat-sidebar__clear:hover {
  color: var(--orange-deep);
}

/* --------------------------------------------------------------------------
   Filtros (grupos). Se mueven entre sidebar (desktop) y bottom sheet (movil).
   Jerarquia editorial: titulos de grupo en Label/Eyebrow, conteos en mono gris.
   -------------------------------------------------------------------------- */
.cat-filters {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.cat-fset {
  border: none;
  border-top: 1px solid var(--line);
  padding: var(--space-5) 0;
}
.cat-fset:first-child {
  border-top: none;
  padding-top: 0;
}
.cat-fset__title {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--fs-eyebrow);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: var(--space-3);
  padding: 0;
}
.cat-optlist {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  max-height: 220px;
  overflow-y: auto;
}
.cat-opt {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.4rem 0.5rem;
  margin-inline: -0.5rem;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: background var(--t-fast);
}
.cat-opt:hover {
  background: var(--bg);
}
.cat-opt:hover .cat-opt__name {
  color: var(--navy);
}
.cat-opt input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--orange-deep);
  flex: none;
  cursor: pointer;
}
.cat-opt input:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}
.cat-opt__name {
  font-size: var(--fs-sm);
  color: var(--ink);
  flex: 1;
  transition: color var(--t-fast);
}
.cat-opt__count {
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
/* Opcion activa: nombre en navy 600 y conteo naranja (bisturi puntual) */
.cat-opt input:checked ~ .cat-opt__name {
  color: var(--navy);
  font-weight: 600;
}
.cat-opt input:checked ~ .cat-opt__count {
  color: var(--orange-deep);
}

/* Grupo precio: slider dual (range-dual del sistema) + inputs mono */
.cat-price__slider {
  margin-bottom: var(--space-3);
}
.cat-price__inputs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.cat-price__inputs .field {
  flex: 1;
}
.cat-price__field {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: center;
  padding: 0.55rem 0.5rem;
}
.cat-price__sep {
  color: var(--ink-3);
  flex: none;
}

/* --------------------------------------------------------------------------
   Grid de resultados
   -------------------------------------------------------------------------- */
.cat-grid {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
}
.cat-grid[hidden] {
  display: none;
}

/* Paginacion */
.cat-pagination {
  margin-top: var(--space-10);
}
.cat-pagination[hidden] {
  display: none;
}

/* --------------------------------------------------------------------------
   Empty state: panel navy con foto de fondo (grade) y salida clara
   -------------------------------------------------------------------------- */
.cat-empty[hidden] {
  display: none;
}
.cat-empty__panel {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  padding: clamp(2.5rem, 1.5rem + 5vw, 4.5rem) var(--space-6);
  background:
    var(--glow-orange),
    var(--grade-navy-strong),
    url("../../img/heroes/seminuevos-hero.jpg") center / cover no-repeat;
}
.cat-empty__inner {
  position: relative;
  z-index: 1;
  max-width: 44ch;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-4);
}
.cat-empty__icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--orange-tint-10);
  color: var(--orange);
}
.cat-empty__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-h4);
  color: var(--on-navy);
  margin: 0;
}
.cat-empty__text {
  color: var(--on-navy-72);
  margin: 0;
}
.cat-empty__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  text-align: left;
  margin: 0;
}
.cat-empty__list li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-sm);
  color: var(--on-navy-72);
}
.cat-empty__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--orange);
  flex: none;
}
.cat-empty__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

/* --------------------------------------------------------------------------
   Bottom sheet de filtros (movil). Panel vive en HTML, cuerpo recibe el form.
   -------------------------------------------------------------------------- */
.cat-sheet__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-h5);
  margin: 0;
}
.cat-sheet__close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink-2);
}
.cat-sheet__close:hover {
  background: var(--bg);
  color: var(--ink);
}
.cat-sheet__foot .btn {
  flex: 1;
}

/* --------------------------------------------------------------------------
   Responsivo
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .cat-body,
  .cat-commandbar {
    --cat-cmdbar-top: 56px;
  }
  .cat-layout {
    grid-template-columns: 1fr;
  }
  .cat-sidebar {
    display: none;
  }
  .cat-filterbtn {
    display: inline-flex;
  }
  .cat-sort {
    order: 3;
  }
  /* Chips activos scrollables horizontalmente */
  .cat-activechips.is-on {
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding-bottom: var(--space-2);
    -webkit-overflow-scrolling: touch;
  }
  .cat-activechips .chip,
  .cat-activechips__clear {
    flex: none;
    scroll-snap-align: start;
  }
  /* Los grupos de filtro ocupan mas alto dentro del sheet */
  .cat-optlist {
    max-height: none;
  }
  /* El conteo del asistente pasa a fila propia bajo el texto */
  .cat-assistant {
    align-items: flex-start;
  }
}

@media (max-width: 620px) {
  .cat-assistant {
    flex-wrap: wrap;
  }
  .cat-assistant__result {
    flex-direction: row;
    align-items: baseline;
    gap: var(--space-2);
    padding-left: 0;
    border-left: none;
    margin-left: calc(34px + var(--space-4));
  }
}

@media (max-width: 560px) {
  .cat-cmd__btn-label {
    display: none;
  }
  .cat-cmd__btn-ico {
    display: block;
  }
  .cat-cmd__btn {
    padding-inline: 0.95rem;
  }
  .cat-head__row {
    align-items: flex-start;
  }
}
