/* catalogo.css
   Estilos para catálogo: grid, tarjetas, filtros, chips, paginación
*/

/* Global safety: avoid horizontal overflow on mobile */
*,
*::before,
*::after{
  box-sizing: border-box;
}
html, body{
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
img, svg, video, canvas{
  max-width: 100%;
}



:root{
  --bg: #ffffff;
  --muted: #6b7280;
  --accent: #0ea5e9;
  --card-radius: 12px;
  --shadow-1: 0 4px 14px rgba(15,22,39,0.04);
  --shadow-2: 0 6px 18px rgba(15,22,39,0.06);
  --chip-bg: #ffffff;
  --chip-border: rgba(15,22,39,0.06);
  --btn-hover-bg: #f3f4f6;  /* hover gris claro para btn Ver */
}

/* Layout general */
header.topbar {
  display:flex;
  align-items:center;
  gap:12px;
  background:white;
  padding:14px 20px;
  box-shadow:0 1px 0 rgba(0,0,0,0.04);
}


/* Logo (reemplaza el título textual) */
header.topbar .brand{
  display:flex;
  align-items:center;
  justify-content:center;
  flex:0 0 auto;
  height:44px;
  padding:0 6px;
}

.brand.brand-text{
  font-weight:700;
  font-size:16px;
  line-height:1;
  color:var(--ink, #0f172a);
  white-space:nowrap;
}
header.topbar .brand img{
  display:block;
  height:34px;
  width:auto;
}
/* Mobile Filters toggle (hidden on desktop) */
.filters-toggle{
  display:none;
  align-items:center;
  gap:8px;
  padding:0;
  border:0;
  background:transparent;
  color:#0B2A4A;
  cursor:pointer;
  white-space:nowrap;
  box-shadow:none;
}
.filters-toggle span{ font-weight:700; }
.filters-toggle i{ font-size:14px; }
.filters-toggle:hover{ text-decoration: underline; }

/* Search centered at 30% */
.search-center {
  margin: 0 auto;
  width: 72%;
  min-width: 220px;
  display:flex;
  justify-content:center;
}
.search-center input[type="search"],
#q {
  width:100%;
  padding:10px 14px;
  border-radius:10px;
  border:1px solid #e6e9ef;
  font-size:0.95rem;
  box-shadow:none;
}

/* Main layout */
main.catalogo {
  padding:18px;
  display:flex;
  gap:20px;
  align-items:flex-start;
  min-width: 0;
  max-width: 100%;
}


main.catalogo > *{
  min-width: 0;
  max-width: 100%;
}

.catalog-area{
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

/* Sidebar filters: autosize to content (max width) */
aside#filters {
  width: auto;
  min-width: 210px;
  max-width: 320px;
  background: #fff;
  padding:16px;
  border-radius:12px;
  box-shadow:var(--shadow-1);
}

/* Filters header (desktop: simple, mobile: shows close button) */
.filters-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom: 12px;
}
.filters-close{
  display:none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(15,23,42,.10);
  background: #fff;
  color: #0f172a;
  cursor:pointer;
}
.filters-close i{ font-size: 16px; }

/* Backdrop for mobile off-canvas filters */
.filters-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
  z-index: 50;
}

body.filters-open{ overflow:hidden; }
body.filters-open .filters-backdrop{ opacity:1; pointer-events:auto; }

body.filters-open{ overflow: hidden; }
body.filters-open .filters-backdrop{
  opacity: 1;
  pointer-events: auto;
}

/* Make select width auto (contents) */
aside#filters select {
  width: 100%;
  box-sizing:border-box;
}

/* Filtro de colores: layout horizontal tipo “rejilla” */
.color-filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  max-height: none;
}

/* Cada color como “botón” compacto */
.color-filter-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 2px;
  border-radius: 999px;           /* sensación circular alrededor del grupo */
  cursor: pointer;
  border: 0;                      /* el círculo azul irá sobre el punto, no sobre el bloque */
  background: transparent;
}

/* Punto de color base */
/* Punto de color base (motor de swatch) */
.color-dot-mini{
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  transition: transform 0.12s ease, box-shadow 0.12s ease;

  /* base por si no setean nada */
  --sw-base: #999;
  --sw-bg: linear-gradient(180deg, var(--sw-base), var(--sw-base));
  --sw-blend: normal;

  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06), 0 2px 6px rgba(0,0,0,.12);
}
.color-dot-mini::before{
  content:"";
  position:absolute;
  inset:-2px;
  border-radius: inherit;
  background: var(--sw-bg);
  transform: scale(1.06);
  transform-origin: center;
  background-repeat: no-repeat;
  background-position: center;
  background-blend-mode: var(--sw-blend);
  z-index: 0;
}
.color-dot-mini .swatch-inner{
  position: relative;
  z-index: 1;
  font-size: 10px;
  font-weight: 700;
  color: rgba(0,0,0,.55);
}


/* Hover sutil sobre el punto */
.color-filter-item:hover .color-dot-mini {
  transform: scale(1.05);
}

/* Selector circular azul claro alrededor del color activo */
.color-filter-item.active .color-dot-mini{
  box-shadow: 0 0 0 2px #60a5fa, inset 0 0 0 1px rgba(0,0,0,.06), 0 2px 6px rgba(0,0,0,.12);
}

/* Opcional: resaltar también el nombre cuando está activo */
.color-filter-item.active .color-filter-name {
  font-weight: 600;
  color: #1d4ed8;
}

/* Grid general (4 columnas en escritorio) */
.grid-catalog {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
  min-width: 0;
  max-width: 100%;
}

/* Fuerza 4 columnas cuando haya suficiente ancho */
@media (min-width: 1200px) {
  .grid-catalog {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* For pages that use a dedicated grid wrapper */
.grid-products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 22px;
  padding: 20px 0;
  width: 100%;
  align-items: start;
}

/* Template card */
.product-card {
  background: var(--bg);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-1);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  transition: transform .14s ease, box-shadow .14s ease;
  cursor: pointer;
}
.product-card:hover {
  transform: translateY(-4px);
  box-shadow:var(--shadow-2);
}

/* Image: remove gray backgrounds, use white background so images with transparent edges look correct */
.product-card .card-img {
  width:100%;
  height:160px;
  object-fit:contain;
  background: #fff;   /* <-- blanco ahora */
  border-radius:8px;
  padding:0;
  display:block;
}

/* Badge (AGOTADO) adjusted small in top-right */
.badge-agotado {
  position:absolute;
  top:8px;
  right:8px;
  background:#e11d48;
  color:#fff;
  padding:4px 8px;
  border-radius:6px;
  font-size:0.72rem;
  font-weight:700;
  z-index:4;
}

/* SKU chip inside card above name (with "SKU:" label) */
.sku-chip-inline {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  background:#000;
  color:#fff;
  padding:4px 8px;
  border-radius:999px;
  line-height: 1;
  font-size:0.8rem;
  font-weight:600;
  margin-bottom:2px;
}
.sku-chip-inline .sku-label {
  font-weight:700;
  font-size:0.75rem;
  letter-spacing:0.4px;
}

/* Centrado perfecto del contenido dentro del chip (SKU: + valor) */
.sku-chip-inline .sku-label,
.sku-chip-inline .sku-value{
  display:inline-flex;
  align-items:center;
  line-height: 1;
}

/* Centrado fino dentro del chip (label + valor) */
.sku-chip-inline .sku-label,
.sku-chip-inline .sku-value{
  display:inline-flex;
  align-items:center;
  line-height: 1;
}

/* Category / Subcategory chips: background gris claro */
.chips-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.chip {
  display:inline-flex;
  align-items:center;
  padding:4px 8px;
  border-radius:999px;
  background:var(--chip-bg);
  border:1px solid var(--chip-border);
  font-size:0.85rem;
  color:var(--muted);

  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.chip.cat { border-radius:8px 0 0 8px; }
.chip.subcat { border-radius:0 8px 8px 0; }

/* Title */
.product-title { font-weight:700; font-size:0.96rem; color:#111; margin:0; 
  overflow-wrap: anywhere;
  word-break: break-word;
}


/* meta line smaller */
.product-meta { font-size:0.82rem; color:var(--muted); }

/* colors rendered inside card (3 visible + +N) */
.product-colors { display:flex; align-items:center; gap:6px; margin-top:6px; }
.color-dot{
  width:18px;
  height:18px;
  border-radius:50%;
  border:1px solid rgba(0,0,0,0.08);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink:0;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;

  --sw-base: #999;
  --sw-bg: linear-gradient(180deg, var(--sw-base), var(--sw-base));
  --sw-blend: normal;

  box-shadow: inset 0 0 0 1px rgba(0,0,0,.05), 0 2px 6px rgba(0,0,0,.10);
}
.color-dot::before{
  content:"";
  position:absolute;
  inset:-2px;
  border-radius: inherit;
  background: var(--sw-bg);
  transform: scale(1.06);
  transform-origin: center;
  background-repeat: no-repeat;
  background-position: center;
  background-blend-mode: var(--sw-blend);
  z-index: 0;
}
.color-dot .swatch-inner{
  position: relative;
  z-index: 1;
  font-size: 10px;
  font-weight: 700;
  color: rgba(0,0,0,.60);
}
.color-extra {
  background:#f3f4f6; padding:2px 6px; border-radius:6px; font-size:0.75rem; color:#222;
}


/* =========================================================================
   Swatches especiales (aplicados también a dots del catálogo)
   ========================================================================= */
:is(.color-dot, .color-dot-mini)[data-color="AZUL REY" i]{ --sw-base:#0F5CB8; }

:is(.color-dot, .color-dot-mini)[data-color="BICOLOR" i]{
  --sw-bg: linear-gradient(90deg,#1E88E5 0 49.6%, #E53935 50.4% 100%);
}
:is(.color-dot, .color-dot-mini)[data-color="BLANCO CON NEGRO" i]{
  --sw-bg: linear-gradient(90deg,#FFFFFF 0 49.6%, #000000 50.4% 100%);
}

:is(.color-dot, .color-dot-mini)[data-color="MARMOL" i],
:is(.color-dot, .color-dot-mini)[data-color="MÁRMOL" i]{
  --sw-bg:
    radial-gradient(circle at 28% 32%, rgba(255,255,255,0.8), rgba(255,255,255,0) 55%),
    repeating-linear-gradient(120deg, rgba(120,120,120,0.28) 0 2px, rgba(255,255,255,0) 2px 14px),
    repeating-linear-gradient(60deg, rgba(90,90,90,0.22) 0 1px, rgba(255,255,255,0) 1px 12px),
    linear-gradient(180deg, #E0E0E0, #E0E0E0);
}

:is(.color-dot, .color-dot-mini)[data-color="MULTICOLOR" i]{
  --sw-bg: conic-gradient(from -88deg,
    #ff004c,#ff7a00,#ffd000,#00c853,#00bcd4,#1e88e5,#8e24aa,#ff004c
  );
}

:is(.color-dot, .color-dot-mini)[data-color="TORNASOL" i]{
  --sw-bg:
    linear-gradient(135deg,
      rgba(255,255,255,.28) 0%,
      rgba(255,255,255,.06) 36%,
      rgba(0,0,0,.18) 62%,
      rgba(255,255,255,.14) 100%
    ),
    conic-gradient(from -88deg,
      #ff004c,#ff7a00,#ffd000,#00c853,#00bcd4,#1e88e5,#8e24aa,#ff004c
    );
  --sw-blend: overlay, normal;
  filter: saturate(1.10) contrast(1.04);
}

/* Metálicos */
:is(.color-dot, .color-dot-mini)[data-color*="METALIC" i],
:is(.color-dot, .color-dot-mini)[data-color="DORADO" i],
:is(.color-dot, .color-dot-mini)[data-color="PLATA" i],
:is(.color-dot, .color-dot-mini)[data-color="COBRE" i],
:is(.color-dot, .color-dot-mini)[data-color="ROSE GOLD" i]{
  --sw-bg:
    linear-gradient(135deg,
      rgba(255,255,255,.28) 0%,
      rgba(255,255,255,0) 22%,
      rgba(255,255,255,.18) 44%,
      rgba(0,0,0,.10) 60%,
      rgba(255,255,255,.18) 78%,
      rgba(255,255,255,0) 100%
    ),
    linear-gradient(180deg, var(--sw-base), var(--sw-base));
}

:is(.color-dot, .color-dot-mini)[data-color="DORADO" i]{ --sw-base:#D4AF37; }
:is(.color-dot, .color-dot-mini)[data-color="PLATA" i]{ --sw-base:#C0C0C0; }
:is(.color-dot, .color-dot-mini)[data-color="COBRE" i]{ --sw-base:#B87333; }
:is(.color-dot, .color-dot-mini)[data-color="ROSE GOLD" i]{ --sw-base:#B76E79; }

/* Traslúcido + Transparente */
:is(.color-dot, .color-dot-mini)[data-color*="TRASLUC" i],
:is(.color-dot, .color-dot-mini)[data-color*="TRASLÚC" i],
:is(.color-dot, .color-dot-mini)[data-color="TRANSPARENTE" i]{
  --sw-base: rgba(170,220,255,.16);
  --sw-bg:
    radial-gradient(circle at 28% 22%, rgba(255,255,255,.55), rgba(255,255,255,0) 52%),
    radial-gradient(circle at 70% 78%, rgba(255,255,255,.18), rgba(255,255,255,0) 58%),
    linear-gradient(180deg, rgba(170,220,255,.18), rgba(255,255,255,.06)),
    linear-gradient(135deg, rgba(255,255,255,.16), rgba(255,255,255,.04)),
    linear-gradient(180deg, var(--sw-base), var(--sw-base));
  border-color: rgba(209,213,219,.95);
}
:is(.color-dot, .color-dot-mini)[data-color*="TRASLUC" i]::after,
:is(.color-dot, .color-dot-mini)[data-color*="TRASLÚC" i]::after,
:is(.color-dot, .color-dot-mini)[data-color="TRANSPARENTE" i]::after{
  content:"";
  position:absolute;
  inset:0;
  border-radius: inherit;
  pointer-events:none;
  background:
    radial-gradient(circle at 30% 18%, rgba(255,255,255,.60), rgba(255,255,255,0) 55%),
    linear-gradient(135deg, rgba(255,255,255,.28) 45%, rgba(255,255,255,.20) 58% 100%);
  opacity:.80;
  z-index: 2;
}

/* Pastel: borde claro */
:is(.color-dot, .color-dot-mini)[data-color*="PASTEL" i]{ border-color: rgba(229,231,235,.98) !important; }

/* Neón: glow suave */
:is(.color-dot, .color-dot-mini)[data-color*="NEON" i],
:is(.color-dot, .color-dot-mini)[data-color*="NEÓN" i]{
  filter: drop-shadow(0 0 4px rgba(255,255,255,.10));
}

/* Jaspeados: diagonales densas */
:is(.color-dot, .color-dot-mini)[data-color*="JASPEADO" i]{
  --sw-bg:
    repeating-linear-gradient(45deg, rgba(255,255,255,.38) 0 2px, rgba(255,255,255,0) 2px 7px),
    repeating-linear-gradient(45deg, rgba(0,0,0,.14) 0 1px, rgba(0,0,0,0) 1px 10px),
    linear-gradient(180deg, var(--sw-base), var(--sw-base));
  --sw-blend: overlay, soft-light, normal;
}
/* container for colors + button aligned on same row */
.card-bottom {
  margin-top: auto;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

/* Button Ver: starts black, hover to light gray with smooth transition */
.btn-detail {
  padding:6px 10px;
  border-radius:8px;
  border:1px solid rgba(0,0,0,0.12);
  background:#000;       /* default black */
  color:#fff;
  cursor:pointer;
  transition: background .15s ease, color .15s ease, transform .12s ease;
  min-width:72px;
  text-align:center;
}
.btn-detail:hover {
  background: var(--btn-hover-bg);  /* light gray */
  color: #111;
  transform: translateY(-1px);
}

/* Paginación: siempre en una fila (alineada al ancho del grid) */
.pager-container {
  width: 100%;
  max-width: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 12px 0;
  gap: 8px;
  flex-wrap: nowrap;
  overflow: visible; /* el scroll vive en .pager-scroller */
  padding-bottom: 4px;
}

/* Area scrolleable de números */
.pager-scroller{
  flex: 1 1 auto;
  min-width: 0;
  display:flex;
  justify-content:center;
  align-items:center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
  max-width: 100%;
  padding: 2px 0;
}

.pager-scroller::-webkit-scrollbar{ display:none; }

.pager-btn {
  padding:8px 10px;
  border-radius:8px;
  border:1px solid var(--chip-border);
  background:white;
  cursor:pointer;
  min-width:40px;
  text-align:center;
}
.pager-btn.active { background:var(--accent); color:#fff; border-color:var(--accent); }

/* Primera y última página (siempre visibles): estilo fijo en azul marino */
.pager-btn.edge{
  background:#0B1F3A;
  color:#fff;
  border-color:#0B1F3A;
}
.pager-btn.edge:hover{
  background:#0B1F3A;
  color:#fff;
}

.pager-btn:disabled{
  opacity: .45;
  cursor: not-allowed;
}

.pager-btn i{ font-size: 12px; }

/* Ellipsis style */
.pager-ellipsis { display:inline-flex; align-items:center; justify-content:center; padding:8px 10px; color:var(--muted); }
/* Status row (status + botón Filtros en móviles) */
.status-row{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:12px;
  margin-bottom:8px;
}
.status-row .status-line{
  flex:1 1 auto;
  color:var(--muted);
  font-size:0.95rem;
  margin:0;
  text-align:center;
}

/* Créditos (arriba de la paginación inferior) */
.credits-row{
  width: 100%;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  margin: 6px 0 2px;
  padding: 0 2px;
  color: rgba(15,23,42,0.65);
  font-size: 0.86rem;
}
.credits-row a{
  color: inherit;
  text-decoration: none;
}
.credits-openai:hover{
  text-decoration: underline;
}
.credits-dev{
  font-weight: 600;
}
.credits-dev:hover{
  color: dodgerblue;
  text-decoration: underline;
}
.credits-sep{ opacity: .7; }


/* Responsive adjustments */
@media (max-width:900px) {
  header.topbar{
    padding: 12px 14px;
    flex-wrap: wrap;
    gap: 10px;
  }
  header.topbar h1{
    flex: 1 1 100%;
  }
  /* Hide the right placeholder spacer on mobile */
  header.topbar > div[style*="width:120px"]{ display:none; }

  .search-center{
    width: 100%;
    min-width: 0;
    flex: 1 1 100%;
    margin: 0;
  }
  /* Mobile: show Filters button (a la derecha del status) */
  .filters-toggle{
    display:inline-flex;
    flex: 0 0 auto;
  }

  .status-row{
    justify-content: space-between;
  }
  .status-row .status-line{
    text-align: left;
  }

  .credits-row{
    /* En móviles: dos líneas centradas, una encima de otra */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 4px;
    font-size: 0.84rem;
    line-height: 1.2;
    margin: 8px 0 2px;
  }

  .credits-left,
  .credits-right{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
  }

  /* Grid en móviles: 2 por fila (y 3 en pantallas móviles más anchas) */
  .grid-catalog{
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .pager-container{
    max-width: 100%;
    box-sizing: border-box;
    padding: 0;
    justify-content: space-between;
  }
  .pager-btn{ min-width: 36px; }

  /* Off-canvas filters on mobile */
  aside#filters{
    display:block;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: min(92vw, 360px);
    max-width: 92vw;
    transform: translateX(-110%);
    transition: transform .22s ease;
    z-index: 60;
    overflow-y: auto;
    padding-bottom: 90px;
  }

  body.filters-open aside#filters{ transform: translateX(0); }

  .filters-backdrop{
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
    z-index: 50;
  }
  body.filters-open .filters-backdrop{
    opacity: 1;
    pointer-events: auto;
  }

  body.filters-open{
    overflow: hidden;
  }

  .filters-head{
    display:flex;
    align-items:center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
  }

  .filters-close{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1px solid rgba(15,23,42,.10);
    background: #fff;
    cursor: pointer;
  }
}

/* Móviles grandes / tablet angosta: 3 por fila */
@media (min-width:520px) and (max-width:900px){
  .grid-catalog{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Small utility tweaks */
.hidden { display:none !important; }
/* sku-chip-inline safety */
.sku-chip-inline{ max-width:100%; overflow-wrap:anywhere; word-break:break-word; }

/* Ripple effect (Limpiar filtros) */
#clearFilters{
  position: relative;
  overflow: hidden;
}
#clearFilters .ripple{
  position:absolute;
  border-radius: 999px;
  transform: scale(0);
  animation: ripple .6s ease-out;
  background: rgba(15,23,42,.18);
  pointer-events:none;
}
@keyframes ripple{
  to{ transform: scale(4); opacity: 0; }
}


/* Fix: avoid flex min-width freeze on very narrow mobiles (<600px) */
@media (max-width: 600px){
  main.catalogo{ flex-direction: column; }
  .catalog-area{ min-width: 0; }
}
