/* Panel lateral de filtros y distribución general del catálogo. */
.catalogo-layout { display: grid; grid-template-columns: 245px minmax(0, 1fr); gap: 28px; max-width: 1440px; margin: 0 auto; padding: 40px 24px; align-items: start; }
/* Zona que contiene el título, ordenamiento y resultados. */
.catalogo-resultados { min-width: 0; }
.panel-filtros { border: 1px solid var(--borde); border-radius: 12px; background: var(--arena); padding: 20px; }
.panel-filtros summary { font-size: 1.2rem; font-weight: 700; cursor: pointer; min-height: 44px; }
.panel-filtros form > fieldset { border: 0; min-width: 0; }
.panel-filtros fieldset:disabled { opacity: .6; }
.panel-filtros label, .panel-filtros legend { display: block; font-weight: 600; margin: 18px 0 8px; }
.panel-filtros .precio-rango { border: 0; min-width: 0; padding: 0; }
.precio-rango > div { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.precio-rango label { margin-top: 0; font-size: .85rem; }
.panel-filtros input[type="number"], .panel-filtros select, .catalogo-barra select { width: 100%; min-width: 0; min-height: 44px; border: 1px solid #89978f; border-radius: 6px; padding: 10px; font: inherit; background: white; color: var(--texto); }
.panel-filtros .opcion-check { display: flex; gap: 10px; align-items: center; font-size: .9rem; font-weight: 400; min-height: 44px; }
.opcion-check input { width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--verde); }
#restablecer-filtros { width: 100%; margin-top: 18px; min-height: 44px; padding: 10px; border: 1px solid var(--verde); border-radius: 6px; background: white; color: var(--verde); font: inherit; cursor: pointer; }
.ayuda-filtros { font-size: .85rem; line-height: 1.5; margin-top: 18px; color: var(--texto-suave); }
#error-precio { color: #a01b21; font-size: .85rem; margin-top: 8px; }
/* Barra superior: contador de resultados y selector de orden. */
.catalogo-barra { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.catalogo-barra h2 { margin-bottom: 8px; }
.catalogo-barra label { display: block; margin-bottom: 6px; font-size: .85rem; }
.catalogo-barra > div:last-child { min-width: 180px; }
/* Catálogo de escritorio: 4 columnas y 24 productos por página (4 x 6). */
#contenedor-productos { display: grid; max-width: none; padding: 0; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.tarjeta-producto { display: flex; flex-direction: column; transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease; }
/* Los datos abren el modal; el enlace de WhatsApp queda como acción independiente. */
.detalle-producto { display: flex; flex: 1; flex-direction: column; align-items: stretch; width: 100%; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: zoom-in; }
.detalle-producto:focus-visible { outline: 3px solid #d09524; outline-offset: 4px; border-radius: 8px; }
.tarjeta-producto .boton-whatsapp { margin-top: auto; background: #17633c; color: white; }
.tarjeta-producto .precio-producto { margin-bottom: 16px; }
.imagen-producto { height: 200px; transition: opacity .18s ease; }

/* Animación suave de la tarjeta al pasar el cursor sobre ella. */
@media (hover: hover) and (pointer: fine) {
    .tarjeta-producto:hover {
        transform: translateY(-5px);
        border-color: #9dc5ad;
        box-shadow: 0 12px 24px rgba(18, 61, 42, .14);
    }
}

/* Ventana modal con la foto ampliada y los datos del producto elegido. */
.modal-producto {
    /* Centra el diálogo en la ventana y deja un margen adaptable alrededor. */
    position: fixed;
    inset: 0;
    margin: auto;
    width: min(920px, calc(100vw - 32px));
    max-width: none;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    padding: 0;
    overflow: visible;
    border: 0;
    background: transparent;
    color: var(--texto);
}

.modal-producto::backdrop { background: rgba(12, 27, 19, .68); backdrop-filter: blur(3px); }

.modal-producto-contenido {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
    align-items: center;
    gap: clamp(20px, 4vw, 40px);
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    padding: clamp(24px, 4vw, 40px);
    border: 1px solid var(--borde);
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
}

.modal-producto-imagen-contenedor {
    position: relative;
    display: grid;
    min-height: 320px;
    place-items: center;
    overflow: hidden;
    border-radius: 14px;
    background: var(--arena);
}

.modal-producto-imagen-contenedor img { display: block; width: 100%; max-height: 440px; object-fit: contain; cursor: zoom-in; transform-origin: center center; transition: transform .12s ease, opacity .18s ease; }

/* La lupa amplía la zona que queda debajo del cursor y el marco recorta el resto. */
.modal-producto-imagen-contenedor.zoom-activo #modal-producto-imagen { transform: scale(2); cursor: zoom-out; }

/* Flechas laterales para recorrer manualmente las imágenes del producto en el modal. */
.modal-producto-flecha {
    position: absolute;
    top: 50%;
    z-index: 2;
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    transform: translateY(-50%);
    border: 1px solid var(--borde);
    border-radius: 50%;
    background: rgba(255, 255, 255, .94);
    color: var(--verde-oscuro);
    font: inherit;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(18, 61, 42, .16);
    transition: background-color .18s ease, transform .18s ease;
}

.modal-producto-flecha.anterior { left: 12px; }
.modal-producto-flecha.siguiente { right: 12px; }
.modal-producto-flecha:hover { background: var(--verde-claro); transform: translateY(-50%) scale(1.06); }
.modal-producto-flecha:focus-visible { outline: 3px solid #d09524; outline-offset: 3px; }
.modal-producto-informacion h2 { margin: 0 36px 18px 0; color: var(--verde-oscuro); font-size: clamp(1.5rem, 3vw, 2.2rem); line-height: 1.2; }
.modal-producto-informacion p { margin: 0 0 12px; line-height: 1.55; }
.modal-producto-informacion .precio-producto { margin: 24px 0 18px; color: var(--verde); font-size: 1.65rem; font-weight: 800; }
.modal-producto-informacion .boton-whatsapp { display: inline-flex; align-items: center; justify-content: center; min-height: 50px; padding: 12px 18px; }

/* Botón para cerrar el modal. */
.modal-producto-cerrar {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1;
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 1px solid var(--borde);
    border-radius: 50%;
    background: #fff;
    color: var(--verde-oscuro);
    font: inherit;
    font-size: 1.7rem;
    line-height: 1;
    cursor: pointer;
}

.modal-producto-cerrar:hover { background: var(--verde-claro); }
.modal-producto-cerrar:focus-visible { outline: 3px solid #d09524; outline-offset: 3px; }

/* Mensajes de carga, error o ausencia de coincidencias. */
.catalogo-estado, #sin-resultados { padding: 24px; background: var(--arena); border-radius: 8px; grid-column: 1 / -1; }
.catalogo-estado button { display: block; margin-top: 12px; padding: 10px 16px; min-height: 44px; font: inherit; cursor: pointer; }

/* Paginación: botones centrados, cómodos para usar en computadora y celular. */
.paginacion {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 24px auto 4px;
    padding: 0 0 8px;
}

.paginacion button {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 13px;
    border: 1px solid var(--borde);
    border-radius: 12px;
    background: #fff;
    color: var(--verde-oscuro);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform .2s ease, background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.paginacion button:hover:not(:disabled) {
    border-color: var(--verde);
    background: var(--verde-claro);
    box-shadow: 0 5px 12px rgba(18, 61, 42, .12);
    transform: translateY(-2px);
}

.paginacion button[aria-current="page"] {
    border-color: var(--verde);
    background: var(--verde);
    color: #fff;
    box-shadow: 0 5px 12px rgba(18, 61, 42, .18);
}

.paginacion button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.paginacion button:focus-visible {
    outline: 3px solid #d09524;
    outline-offset: 3px;
}

.paginacion > span {
    min-width: 24px;
    color: var(--texto-suave);
    text-align: center;
}

.aviso-precios { margin-top: 20px; font-size: .9rem; line-height: 1.6; color: var(--texto-suave); }
/* Adaptación progresiva: 4, 3, 2 y 1 columna según el ancho. */
@media (max-width: 1200px) { #contenedor-productos { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 980px) { #contenedor-productos { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 850px) { .catalogo-layout { grid-template-columns: 1fr; padding: 24px 16px; } .catalogo-barra { align-items: start; } }
@media (max-width: 700px) {
    .modal-producto-contenido { grid-template-columns: 1fr; gap: 20px; padding: 22px; }
    .modal-producto-imagen-contenedor { min-height: 220px; }
    .modal-producto-imagen-contenedor img { max-height: 320px; }
    .modal-producto-informacion .boton-whatsapp { width: 100%; }
}
@media (max-width: 600px) { #contenedor-productos { grid-template-columns: 1fr; } .catalogo-barra { flex-direction: column; } .catalogo-barra > div:last-child { width: 100%; } .buscador-contenedor { flex-direction: column; } }
@media (prefers-reduced-motion: reduce) { .tarjeta-producto { transition: none; } }
