/* =========================
   Productos Grid - Estilos V2 Optimizado
   ========================= */

/* Contenedor principal */
.pgc-wrapper{
    max-width: 1280px;
    margin: 40px auto;
    font-family: Arial, Helvetica, sans-serif;
    display: flex;
    gap: 40px;
    align-items: flex-start;
    padding: 0 16px;
    position: relative;
}

/* Sidebar (filtros) */
.pgc-sidebar{
    width: 240px;
    flex: 0 0 240px;
    position: sticky;
    top: 20px;
    transition: all 0.3s ease;
}

.pgc-refinar{
    font-family: Arial, Sans-serif;
    font-size: 17px;
    text-transform: uppercase;
    margin: 0 0 18px 0;
    color: #143E6B;
    font-weight: 700;
    letter-spacing: 0.4px;
}

.pgc-toggle-filters{
    display: none;
    margin-bottom: 12px;
    background: #3371D7;
    color: #fff;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.pgc-toggle-filters:hover{
    background: #2a5cb5;
}

.pgc-toggle-filters.active{
    background: #2a5cb5;
}

/* Lista de categorías */
.pgc-cat-list{
    list-style: none;
    padding: 0;
    margin: 0;
}

.pgc-cat-list li{
    margin-bottom: 8px;
    transition: transform 0.2s ease;
}

.pgc-cat-list li:hover{
    transform: translateX(3px);
}

.pgc-cat-list a{
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-decoration: none;
    padding: 8px 10px;
    border-radius: 4px;
    color: #b3afaf;
    text-transform: uppercase;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s ease;
}

.pgc-cat-list a .count{
    color:  #6b6b6b;
    font-weight: 500;
    font-size: 12px;
    transition: color 0.2s ease;
}

.pgc-cat-list li.active a, 
.pgc-cat-list a:hover{
    background: #E9F3FB;
    color: #143E6B;
}

.pgc-cat-list li.active a .count,
.pgc-cat-list a:hover .count{
    color: #143E6B;
}

/* Listado principal */
.pgc-list{
    flex: 1;
    min-width: 0;
    position: relative;
}

.pgc-topbar{
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
	justify-content: flex-end;
}

.pgc-topbar-right{
    font-size: 15px;
    color: #143E6B;
    font-weight: 700;
}

/* Loading overlay */
.pgc-loading-overlay{
  position: absolute;
    top: 0;
    left: 55%;
    transform: translateX(-50%);
    width: calc(100% + 130px);
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 100;
    border-radius: 8px;
}

.pgc-loading-overlay.active{
    display:  flex;
}

.pgc-spinner{
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3371D7;
    border-radius: 50%;
    animation: pgc-spin 1s linear infinite;
    margin-bottom: 15px;
}

.pgc-loading-text{
    color: #143E6B;
    font-weight: 600;
}

@keyframes pgc-spin{
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.pgc-initial-loading{
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #666;
}

/* Grid */
.pgc-grid{
    display: grid;
    grid-template-columns: repeat(3, 280px);
    gap: 28px;
    transition: opacity 0.3s ease;
}

.pgc-grid.loading{
    opacity: 0.5;
}

/* Item - CORREGIDO: Contenedor flex para alinear botón al fondo */
.pgc-item{
    background: none;
    border: 1px solid #ececec;
    padding: 3px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    overflow: hidden;
    height: 100%; /* Todos los items tienen la misma altura */
}

.pgc-item:hover{
    box-shadow: 0 12px 24px rgba(17, 24, 39, 0.1);
    transform: translateY(-4px);
    border-color: #EAEAEA;
}

/* Thumb */
.pgc-thumb{
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    background: #f6f6f6;
    min-height: 180px;
}

.pgc-thumb img{
    width: 100%;
    height: 180px;
    object-fit: cover;
    transition: transform 0.5s ease;
    background: #f6f6f6;
}

.pgc-thumb img.pgc-lazy{
    opacity: 0.3;
    filter: blur(5px);
    transition: opacity 0.3s ease, filter 0.3s ease;
}

.pgc-thumb img.pgc-loaded{
    opacity: 1;
    filter: blur(0);
}

.pgc-thumb:hover img{
    transform: scale(1.05);
}

/* Contenedor del contenido - NUEVO: Para alinear el botón al fondo */
.pgc-item-content{
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 0 8px 8px 8px;
}

/* Title */
.pgc-title{
    font-size: 22px;
    margin: 14px 0 8px;
    line-height: 1.2;
}

.pgc-title a{
    color: #143E6B;
    text-decoration: none;
    transition: color 0.2s ease;
}

.pgc-title a:hover{
    color: #3371D7;
    text-decoration: underline;
}

/* Categories text */
.pgc-cats{
    font-size: 13px;
    color: #8a8a8a;
    margin-bottom: 8px;
}

/* Excerpt */
.pgc-excerpt{
    font-size: 13px;
    color: #666;
    margin-bottom: 12px;
    line-height: 1.5;
}

/* Short description */
.pgc-short-description{
    font-size: 0.7em;
    color: #666;
    margin: 10px 0;
    line-height: 1.4;
    overflow: hidden;
}

/* Button - CORREGIDO: Se alinea automáticamente al fondo */
.pgc-button{
    display: inline-block;
    padding: 5px 36px;
    background: #3371D7;
    color: #fff;
    text-decoration: none;
    border-radius: 3px;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    width: 140px;
    height: 40px;
    margin-top: auto; /* Esto es clave: empuja el botón hacia abajo */
    align-self: flex-start;
}

.pgc-button:hover{
    background: #2a5cb5;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(51, 113, 215, 0.3);
}

/* Pagination */
.pgc-pagination{
    margin-top: 22px;
}

.pgc-pages{
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.pgc-pages li a{
    display: inline-block;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #dfe7f5;
    color: #143E6B;
    text-decoration: none;
    font-weight: 700;
    min-width: 40px;
    text-align: center;
    transition: all 0.2s ease;
}

.pgc-pages li a:hover:not(.pgc-page-current){
    background: #E9F3FB;
    border-color: #3371D7;
    transform: translateY(-2px);
}

.pgc-pages li a.pgc-page-current{
    background: #143E6B;
    color: #fff;
    border-color: #143E6B;
    cursor: default;
}

/* Estados de carga y error */
.pgc-loading-cats,
.pgc-error{
    padding: 15px;
    text-align: center;
    color: #666;
    background: #f9f9f9;
    border-radius: 4px;
}

.pgc-error{
    color: #d33;
    background: #ffeaea;
}

.pgc-no-results{
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #666;
    background: #f9f9f9;
    border-radius: 8px;
}

/* Responsive */
@media (max-width: 1024px){
    .pgc-grid{
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

@media (max-width: 900px){
    .pgc-wrapper{
        flex-direction: column;
        padding: 0 12px;
        gap: 20px;
    }
    
    .pgc-sidebar{
        width: 100%;
        order: 2;
        position: static;
        background: #fff;
        padding: 16px;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }
    
    .pgc-sidebar.open{
        max-height: 500px;
        overflow: visible;
    }
    
    .pgc-toggle-filters{
        display: inline-block;
    }
    
    .pgc-list{
        order: 1;
    }
    
    .pgc-topbar{
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .pgc-topbar-right{
        margin-top: 0;
        text-align: left;
    }
}

@media (max-width: 600px){
    .pgc-grid{
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .pgc-item{
        min-height: auto;
    }
    
    .pgc-thumb img{
        height: 160px;
    }
    
    .pgc-pages{
        gap: 4px;
    }
    
    .pgc-pages li a{
        padding: 8px 10px;
        min-width: 36px;
    }
}

@media (max-width: 480px){
    .pgc-wrapper{
        padding: 0 8px;
        margin: 20px auto;
    }
    
    .pgc-refinar{
        font-size: 16px;
    }
    
    .pgc-title{
        font-size: 16px;
    }
    
    .pgc-button{
        width: 100%;
        text-align: center;
    }
}