@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&display=swap');

:root {
  --green: #59933e;
  --green-2: #6fa84f;
  --green-soft: #d4e5ca;
  --green-pale: #f0f7ec;
  --ink: #3f3f3f;
  --muted: #7a8376;
  --line: #e4eadf;
  --bg: #f7f8f4;
  --white: #fff;
  --shadow: 0 12px 28px rgba(63, 63, 63, .10);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: 'Outfit', Arial, Helvetica, sans-serif;
}

body.modal-open { overflow: hidden; }

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  color: #fff;
  background: linear-gradient(135deg, rgba(89, 147, 62, .97), rgba(111, 168, 79, .97));
  box-shadow: 0 4px 16px rgba(63, 63, 63, .12);
}

.header-inner {
  width: min(1180px, 100%);
  margin: 0 auto;
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
}

.eyebrow {
  margin: 0 0 3px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .82;
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1;
  font-weight: 900;
}

.result-count {
  font-size: 14px;
  font-weight: 800;
}

.filter-bar {
  position: sticky;
  top: 66px;
  z-index: 18;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.filter-inner {
  width: min(1180px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 165px 195px 155px 145px auto;
  gap: 10px;
  align-items: end;
  padding: 12px 18px;
}

.filter-inner label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

/* Campos, desplegables y boton normalizados: mismo tamaño y peso que "Limpiar". */
.filter-inner input,
.filter-inner select {
  width: 100%;
  min-height: 46px;
  border: 2px solid var(--green-soft);
  border-radius: 999px;
  padding: 10px 15px;
  color: var(--ink);
  background: #fff;
  outline: none;
  font-size: 16px;
  font-weight: 700;
}

.filter-inner input::placeholder {
  font-weight: 500;
  color: var(--muted, #5f6f62);
}

.filter-inner input:focus,
.filter-inner select:focus {
  border-color: var(--green);
}

.filter-inner button {
  min-height: 46px;
  border: 2px solid var(--green-soft);
  border-radius: 999px;
  padding: 10px 18px;
  color: var(--ink);
  background: #fff;
  font-size: 16px;
  font-weight: 900;
}

.catalog-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 20px 18px 34px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 16px;
}

/* Numero de columnas elegido por el usuario. Solo a partir de 681px: por debajo
   manda la regla movil de 1 columna, que no se toca. El reparto automatico de
   .product-grid queda como respaldo hasta que el script marca data-columns. */
@media (min-width: 681px) {
  .product-grid[data-columns="1"] { grid-template-columns: minmax(0, 1fr); }
  .product-grid[data-columns="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .product-grid[data-columns="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .product-grid[data-columns="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.view-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}

.view-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  opacity: .75;
}

.column-buttons {
  display: flex;
  gap: 2px;
}

.column-buttons button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  opacity: .5;
}

.column-buttons button svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.column-buttons button:hover {
  opacity: .8;
}

.column-buttons button.active {
  color: var(--green);
  background: var(--green-pale);
  opacity: 1;
}

/* En movil la rejilla es siempre de una columna: el selector no pinta nada. */
@media (max-width: 680px) {
  .view-toolbar { display: none; }
}

.product-card {
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--white);
  box-shadow: 0 2px 10px rgba(63, 63, 63, .07);
  text-align: left;
  transition: transform .22s ease, box-shadow .22s ease;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.card-image {
  aspect-ratio: 1;
  overflow: hidden;
  background: #edf0ea;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .35s ease;
}

.product-card:hover .card-image img {
  transform: scale(1.045);
}

.no-image {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--muted);
  font-weight: 800;
}

.card-body {
  padding: 16px;
}

.card-body h2 {
  font-size: 17px;
  line-height: 1.18;
  font-weight: 900;
}

.card-body p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 48px 18px;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.product-dialog {
  width: min(1100px, calc(100vw - 22px));
  max-height: calc(100vh - 22px);
  overflow: auto;
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: #fff;
  box-shadow: var(--shadow);
}

.product-dialog::backdrop,
.image-dialog::backdrop {
  background: rgba(0, 0, 0, .76);
  backdrop-filter: blur(8px);
}

.round-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: var(--green);
  box-shadow: 0 4px 14px rgba(89, 147, 62, .26);
  font-size: 27px;
  line-height: 1;
}

.close-button {
  /* Flotante: fijo sobre la esquina de la ficha, sin ocupar espacio en el flujo. */
  position: sticky;
  top: 14px;
  float: right;
  z-index: 3;
  margin: 14px 14px -56px 0;
  transition: transform .2s ease, background .2s ease;
}

.close-button:hover {
  transform: rotate(90deg) scale(1.08);
  background: #46742f;
}

.product-detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, .85fr);
  gap: 24px;
  padding: 26px;
}

.gallery-main {
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 18px;
  background: #f1f3ef;
}

.gallery-main img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.thumb {
  overflow: hidden;
  aspect-ratio: 1;
  padding: 0;
  border: 3px solid transparent;
  border-radius: 10px;
  background: #f1f3ef;
}

.thumb.active {
  border-color: var(--green);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-side {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.detail-side h2 {
  margin-bottom: 16px;
  font-size: 31px;
  line-height: 1.08;
  font-weight: 900;
}

.detail-block {
  margin-bottom: 17px;
}

.detail-block h3 {
  margin-bottom: 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.product-description {
  margin: 0;
  line-height: 1.65;
  color: #5f6f62;
  font-size: 13.5px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 10px;
  color: var(--ink);
  background: var(--green-soft);
  font-size: 12px;
  font-weight: 900;
}

.visual-group {
  margin-bottom: 18px;
}

.visual-title {
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.visual-subtitle {
  margin: -6px 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 10px;
}

.swatch {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-height: 104px;
  padding: 0;
  border: 0;
  background: transparent;
}

.swatch img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border: 3px solid transparent;
  border-radius: 10px;
  transition: border-color .18s ease, transform .18s ease;
}

.swatch:hover img {
  border-color: var(--green);
  transform: translateY(-1px);
}

.swatch span {
  max-width: 82px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.18;
  text-align: center;
  overflow-wrap: anywhere;
}

.catalog-notice {
  margin: 0 0 14px;
  border: 2px solid var(--green-soft);
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
  font-weight: 700;
}

.pdf-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}

.pdf-button {
  min-height: 40px;
  border: 2px solid var(--green-soft);
  border-radius: 999px;
  padding: 9px 14px;
  color: var(--ink);
  background: #fff;
  font-weight: 900;
}

.pdf-button:disabled {
  opacity: .55;
  cursor: wait;
}

.share-button {
  min-height: 40px;
  border: 2px solid var(--green);
  border-radius: 999px;
  padding: 9px 16px;
  color: #fff;
  background: var(--green);
  font-weight: 900;
}

.share-button:hover {
  border-color: var(--green-2);
  background: var(--green-2);
}

.share-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.share-option {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border: 2px solid var(--green-soft);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.share-copy-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pdf-status {
  min-height: 18px;
  width: 100%;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.image-dialog {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: hidden;
}

.image-dialog[open] {
  display: grid;
  place-items: center;
  animation: zoom-in .22s ease;
}

@keyframes zoom-in {
  from {
    opacity: 0;
    transform: scale(.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Carril deslizante tipo galeria de movil: el dedo arrastra y la foto encaja sola. */
.zoom-track {
  position: fixed;
  inset: 0;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  cursor: grab;
}

.zoom-track::-webkit-scrollbar { display: none; }

.zoom-track.is-dragging {
  scroll-snap-type: none;
  cursor: grabbing;
}

.zoom-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

.zoom-slide img {
  max-width: calc(100vw - 120px);
  max-height: calc(100vh - 170px);
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
  user-select: none;
  -webkit-user-drag: none;
}

.image-close {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 3;
  transition: transform .2s ease, background .2s ease;
}

.image-close:hover {
  transform: rotate(90deg) scale(1.08);
  background: #46742f;
}

.image-close:active {
  transform: rotate(90deg) scale(.92);
}

.image-nav {
  position: fixed;
  top: 50%;
  width: 52px;
  height: 52px;
  z-index: 3;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: rgba(89, 147, 62, .92);
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, opacity .18s ease;
}

.image-nav svg {
  width: 26px;
  height: 26px;
  display: block;
}

.image-nav:hover:not(:disabled) {
  background: #46742f;
}

.image-nav.prev:hover:not(:disabled) {
  transform: translateY(-50%) translateX(-3px) scale(1.1);
}

.image-nav.next:hover:not(:disabled) {
  transform: translateY(-50%) translateX(3px) scale(1.1);
}

.image-nav:active:not(:disabled) {
  transform: translateY(-50%) scale(.9);
}

.image-nav:disabled {
  opacity: .2;
  cursor: default;
}

.image-nav.prev { left: max(10px, env(safe-area-inset-left)); }
.image-nav.next { right: max(10px, env(safe-area-inset-right)); }

@media (max-width: 640px) {
  .zoom-slide img {
    max-width: 100vw;
    max-height: calc(100vh - 156px);
    border-radius: 0;
  }

  /* En movil se navega deslizando; las flechas estorban mas que ayudan. */
  .image-nav {
    display: none;
  }
}

#imageCaption {
  position: fixed;
  z-index: 3;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  max-width: min(760px, calc(100vw - 36px));
  padding: 8px 14px;
  border-radius: 999px;
  color: #fff;
  background: rgba(0, 0, 0, .72);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  pointer-events: none;
}

/* ===== Carrusel de miniaturas del zoom ===== */

.zoom-thumbs {
  position: fixed;
  z-index: 3;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  max-width: min(880px, calc(100vw - 24px));
  padding: 8px 10px;
  border-radius: 16px;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(6px);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  cursor: grab;
  scrollbar-width: none;
}

.zoom-thumbs::-webkit-scrollbar { display: none; }

.zoom-thumbs.is-dragging {
  cursor: grabbing;
  scroll-behavior: auto;
}

.zoom-thumb {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
  cursor: pointer;
  opacity: .62;
  transition: opacity .18s ease, border-color .18s ease, transform .18s ease;
}

.zoom-thumb:hover {
  opacity: 1;
  transform: translateY(-2px);
}

.zoom-thumb.active {
  border-color: var(--green, #59933e);
  opacity: 1;
}

.zoom-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  display: block;
}

@media (max-width: 640px) {
  #imageCaption { bottom: 84px; }

  .zoom-thumb {
    width: 46px;
    height: 46px;
  }
}

@media (max-width: 980px) {
  .filter-inner,
  .product-detail {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    position: static;
  }
}

@media (max-width: 680px) {
  .header-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .product-grid {
    grid-template-columns: 1fr;
  }

  .product-detail {
    padding: 18px;
  }

  .detail-side h2 {
    font-size: 25px;
  }
}
