/* FRONT - New Look (Single) - REFACTORIZADO */

/* === LAYOUT BASE === */
.nlf-wrap {
    display: grid !important;
    gap: 16px;
    align-items: start;
}

.nlf-image {
    grid-area: image;
}

.nlf-gallery {
    grid-area: gallery;
    margin: 0;
}

/* Mobile: imagen arriba, galería abajo */
.nlf-wrap {
    grid-template-columns: 1fr !important;
    grid-template-areas:
        "image"
        "gallery";
}

/* Desktop: dos columnas lado a lado */
@media (min-width: 992px) {
    .nlf-wrap.nlf-image-left {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
        grid-template-areas: "image gallery";
    }

    .nlf-wrap.nlf-image-right {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
        grid-template-areas: "gallery image";
    }
}

/* === IMAGEN === */
.nlf-image {
    position: relative;
}

.nlf-img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 10px;
    border: solid 1px #f5a9cb;
}

.nlf-imgwrap {
    position: relative;
}

.nlf-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* === PINS === */
.nlf-pin {
    position: absolute;
    left: 0;
    top: 0;
    transform: translate(-50%, -50%) !important;
    width: 20px;
    height: 20px;
    border-radius: 50% !important;
    border: 2px solid #fff;
    background: rgba(249, 59, 144, 0.75) !important;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.15) !important;
    pointer-events: auto;
    cursor: pointer !important;
    padding: 0 !important;
}

.nlf-pin:focus {
    outline: 2px solid #333;
    outline-offset: 2px;
}

/* Popover */
.nlf-pop {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translate(-50%, -100%);
    background: #fff;
    border: 1px solid #eee;
    box-shadow: 0 10px 18px rgba(0, 0, 0, 0.12);
    border-radius: 10px;
    padding: 10px 12px;
    width: max-content;
    max-width: 250px;
    display: none;
    white-space: nowrap;
}

.nlf-pop-title {
    display: block;
    margin: 0 0 6px;
    font-weight: 400;
    color: #000;
}

.nlf-pop-link {
    text-decoration: none;
    color: #f5a9cb;
    font-weight: 500;
}

/* Estados de pins */
.nlf-hot-hover .nlf-pin:hover .nlf-pop {
    display: block;
}

.nlf-hot-click .nlf-pin.nlf-open .nlf-pop {
    display: block;
}

.nlf-hot-off .nlf-pin {
    display: none !important;
}

/* === GALERÍA ADAPTATIVA === */

/* Mobile: siempre 2 columnas */
.nlf-gallery {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

/* Desktop: layout adaptativo según cantidad de productos */
@media (min-width: 992px) {
    .nlf-gallery {
        height: var(--nlf-img-h, auto);
        align-content: start;
    }

    /* 1 producto: 1 columna, 1 fila */
    .nlf-wrap[data-count="1"] .nlf-gallery {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    /* 2 productos: 1 columna, 2 filas iguales */
    .nlf-wrap[data-count="2"] .nlf-gallery {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(2, 1fr);
    }

    /* 3 productos: 2 arriba, 1 abajo (más grande) */
    .nlf-wrap[data-count="3"] .nlf-gallery {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: 1fr 1fr;
    }

    .nlf-wrap[data-count="3"] .nlfg-card:nth-child(3) {
        grid-column: 1 / -1;
        /* ocupa ambas columnas */
    }

    /* 4 productos: 2x2 grid perfecto */
    .nlf-wrap[data-count="4"] .nlf-gallery {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(2, 1fr);
    }

    /* 5 productos: 2 arriba, 3 abajo */
    .nlf-wrap[data-count="5"] .nlf-gallery {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: 1fr 1fr;
    }

    .nlf-wrap[data-count="5"] .nlfg-card:nth-child(1),
    .nlf-wrap[data-count="5"] .nlfg-card:nth-child(2) {
        grid-column: span 1;
    }

    .nlf-wrap[data-count="5"] .nlfg-card:nth-child(1) {
        grid-column: 1 / span 2;
        /* ocupa 2 columnas */
    }

    /* 6 productos: 3x2 grid perfecto */
    .nlf-wrap[data-count="6"] .nlf-gallery {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(2, 1fr);
    }

    /* 7+ productos: 3 columnas con scroll */
    .nlf-wrap[data-count="7"] .nlf-gallery,
    .nlf-wrap[data-count="8"] .nlf-gallery,
    .nlf-wrap[data-count="9"] .nlf-gallery,
    .nlf-wrap[data-count="10"] .nlf-gallery {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(2, 1fr);
        overflow-y: auto;
    }
}

/* === CARDS === */
.nlfg-card {
    border: 1px solid #f5a9cb;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    display: flex;
    flex-direction: column;
    height: 100%;
    /* importante para que ocupen toda la celda del grid */
}

.nlfg-media {
    aspect-ratio: 4/3;
    background: #f6f6f6;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 auto;
    /* permite que se adapte en cards de diferente altura */
    min-height: 0;
}

.nlfg-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-bottom: solid 1px #f5a9cb;
}

.nlfg-thumbph {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #f2f2f2, #fafafa, #f2f2f2);
}

.nlfg-body {
    padding: 12px;
    flex: 0 0 auto;
    /* mantiene tamaño fijo */
}

.nlfg-title {
    margin: 0 0 10px;
    font-weight: 400;
    font-size: 0.9em;
    color: #000;
    line-height: 1.2;
    text-align: center;
}

.nlfg-actions {
    padding: 0 12px 12px;
    flex: 0 0 auto;
    /* mantiene tamaño fijo */
}

.nlfg-btn {
    display: inline-block;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #f5a9cb;
    background: #f5a9cb;
    color: #fff;
    text-decoration: none;
    font-weight: 400;
    font-size: clamp(0.7rem, 2.5vw, 0.8rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.06);
    width: 100%;
    text-align: center;
    box-sizing: border-box;
}

.nlfg-btn:hover {
    filter: brightness(1.05);
}

.nlfg-btn:focus {
    outline: 2px solid #333;
    outline-offset: 2px;
}

/* === CASOS ESPECIALES === */

/* Para 2 productos: asegurar que ocupen toda la altura disponible */
@media (min-width: 992px) {
    .nlf-wrap[data-count="2"] .nlfg-card {
        min-height: 0;
    }

    .nlf-wrap[data-count="2"] .nlfg-media {
        flex: 1 1 auto;
        min-height: 120px;
        /* altura mínima razonable */
    }
}

/* Para 3 productos: el tercero (más grande) tiene más espacio para la imagen */
@media (min-width: 992px) {
    .nlf-wrap[data-count="3"] .nlfg-card:nth-child(3) .nlfg-media {
        aspect-ratio: 8/3;
        /* más ancho */
    }
}

/* === CARDS ANCHOS LIMITADOS Y CENTRADOS === */
@media (min-width: 992px) {

    /* 1 producto: card solo ocupa toda la fila */
    .nlf-wrap[data-count="1"] .nlfg-card {
        max-width: 400px;
        justify-self: center;
    }

    /* 2 productos: cada card ocupa toda la fila (1 columna, 2 filas) */
    .nlf-wrap[data-count="2"] .nlfg-card {
        max-width: 400px;
        justify-self: center;
    }

    /* 3 productos: el tercer card ocupa las 2 columnas de abajo */
    .nlf-wrap[data-count="3"] .nlfg-card:nth-child(3) {
        max-width: 400px;
        justify-self: center;
    }
}