/**
 * HYBINET SHOP — Sistema de Diseño del Catálogo
 * Archivo: assets/css/catalog-grid.css
 * Responsabilidad: Layout de la grilla principal y scroll infinito
 */

/* ==========================================================================
   BLOQUE: hybinet-catalog (Contenedor y Grilla)
   ========================================================================== */
.hybinet-catalog {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 0;
    /* 1.5rem (24px) arriba y a los lados */
    background-color: var(--hybinet-color-bg-primary);
    /* Usando el color base de la paleta */
}

.hybinet-catalog__grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
    gap: var(--hybinet-card-gap, 12px);
}

/* ==========================================================================
   ESTADOS VACÍOS (Empty States)
   ========================================================================== */
.hybinet-catalog__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 1rem;
    min-height: 40vh;
    background-color: var(--hybinet-color-bg-primary);
    border-radius: var(--hybinet-card-radius, 12px);
}

.hybinet-catalog__empty-icon {
    color: var(--hybinet-color-text-meta);
    margin-bottom: 1.5rem;
    opacity: 0.8;
}

.hybinet-catalog__empty h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--hybinet-color-text-primary);
    margin: 0 0 0.5rem 0;
}

.hybinet-catalog__empty p {
    color: var(--hybinet-color-text-secondary);
    max-width: 420px;
    margin: 0 auto 2rem auto;
    line-height: 1.5;
}

.hybinet-catalog__empty-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    background-color: var(--hybinet-color-brand-accent);
    color: white;
    font-weight: 600;
    border-radius: var(--hybinet-badge-radius, 999px);
    text-decoration: none;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.hybinet-catalog__empty-btn:hover {
    background-color: #111111;
    /* fallback oscuro */
    color: white;
    transform: translateY(-2px);
}

/* ==========================================================================
   PAGINACIÓN / SCROLL INFINITO
   ========================================================================== */
.hybinet-infinite-scroll {
    position: relative;
    width: 100%;
    margin: 3rem 0;
}

.hybinet-pagination-seo {
    display: none !important;
}

.hybinet-infinite-scroll__trigger {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 60px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
}

.hybinet-infinite-scroll__trigger.is-loading {
    opacity: 1;
    visibility: visible;
}

.hybinet-load-more {
    display: none;
    /* Se oculta si hay JS para intersection observer */
    margin: 0 auto;
    padding: 12px 32px;
    background-color: var(--hybinet-color-brand-accent, #000);
    color: #fff;
    border: none;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.hybinet-infinite-scroll.requires-manual .hybinet-load-more {
    display: flex;
}

.hybinet-load-more:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.hybinet-load-more__spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: hybinet-spin 0.8s linear infinite;
}

.hybinet-load-more.is-loading .hybinet-load-more__text {
    display: none;
}

.hybinet-load-more.is-loading .hybinet-load-more__spinner {
    display: block;
}

/* Fallback/No más posts */
.hybinet-infinite-scroll__end {
    display: none;
    text-align: center;
    color: var(--hybinet-color-text-meta);
    font-size: 0.9rem;
    padding: 20px 0;
}

.hybinet-infinite-scroll.is-ended .hybinet-infinite-scroll__end {
    display: block;
}

.hybinet-infinite-scroll.is-ended .hybinet-load-more,
.hybinet-infinite-scroll.is-ended .hybinet-infinite-scroll__trigger {
    display: none !important;
}

/* Spinner genérico */
.hybinet-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--hybinet-color-brand-accent, #000);
    border-radius: 50%;
    animation: hybinet-spin 0.8s linear infinite;
}

@keyframes hybinet-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   MEDIA QUERIES (Responsividad Global del Catálogo)
   ========================================================================== */
@media (max-width: 767px) {
    .hybinet-catalog {
        padding: 1.5rem 0.75rem 0;
    }

    .hybinet-catalog__grid {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr));
        gap: 0.75rem;
    }
}