/* ========================================
    CSS UNIFICADO DE PRODUCTOS - INDEX
    VERSIÓN MEJORADA CON UI/UX PROFESIONAL
    ======================================== */

/* Compensar menú fijo */
#idlosproCuerpo {
    padding-top: 80px !important;
    padding-bottom: 60px !important;
    margin-top: 0 !important;
}

@media (max-width: 576px) {
    #idlosproCuerpo {
        padding-top: 70px !important;
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
}

.product-image-container {
    height: 190px !important;
}

/* --- 1. IMÁGENES DEL PRODUCTO --- */
.product-image-container {
    height: 180px !important;
    max-width: 100% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    transition: background 0.3s ease;
}
.product-image {
    object-fit: contain !important;
    max-height: 100% !important;
    max-width: 100% !important;
    padding: 15px !important;
    transition: transform 0.3s ease;
}

/* --- 2. TARJETA DEL PRODUCTO (CARD) MODERNA --- */
.product-card {
    min-height: 320px !important;
    border-radius: 16px !important;
    border: 1px solid #e9ecef !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    margin: 8px !important;
    overflow: hidden;
    background: #fff;
}
.product-card:hover {
    transform: translateY(-8px) !important;
    box-shadow: 0 12px 40px rgba(26, 127, 74, 0.15) !important;
    border-color: #198754 !important;
}
.product-card:hover .product-image {
    transform: scale(1.05);
}

/* Badge de oferta/nuevo */
.product-card .badge-oferta {
    background: linear-gradient(135deg, #dc3545, #c82333);
}
.product-card .badge-nuevo {
    background: linear-gradient(135deg, #0d6efd, #0b5ed7);
}

/* --- 3. TÍTULO DEL PRODUCTO --- */
.product-title {
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    color: #212529 !important;
    min-height: 2.8em;
}

/* Ajustes de espaciado de las tarjetas de producto */
.product-card .card-body {
    padding: 12px !important;
}

/* --- 4. PRECIO --- */
.product-price {
    font-size: 1.25rem !important;
    font-weight: 700 !important;
    background: linear-gradient(135deg, #198754, #20c997);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* --- 5. BOTONES +/- --- */
.product-card .btn-qty {
    width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    font-size: 1.1rem !important;
}
.product-card .qty-controls {
    margin-top: auto !important;
}
.product-card .qty-controls input {
    width: 50px !important;
    text-align: center !important;
    font-weight: 600 !important;
}

/* --- 6. CONTENEDOR GRID (LISTADO) - FLEXBOX RESPONSIVE --- */
#idlosproCuerpo {
    max-width: 100% !important;
    margin: 0 auto !important;
    padding: 20px 15px 60px 15px !important;
}

#idlosproCuerpo .row {
    display: flex !important;
    flex-wrap: wrap !important;
    margin: 0 -5px !important;
    width: calc(100% + 10px) !important;
    justify-content: flex-start;
    gap: 0;
}

#idlosproCuerpo .row .col {
    padding: 8px !important;
}

/* 4 columnas: PC Grande */
@media (min-width: 1200px) {
    #idlosproCuerpo .row .col {
        flex: 0 0 25% !important;
        max-width: 25% !important;
    }
}

/* 4 columnas: PC */
@media (min-width: 993px) and (max-width: 1199px) {
    #idlosproCuerpo .row .col {
        flex: 0 0 25% !important;
        max-width: 25% !important;
    }
}

/* 3 columnas: Tablet */
@media (min-width: 577px) and (max-width: 992px) {
    #idlosproCuerpo .row .col {
        flex: 0 0 33.333333% !important;
        max-width: 33.333333% !important;
    }
}

/* 2 columnas: Móvil */
@media (max-width: 576px) {
    #idlosproCuerpo {
        padding: 15px 8px 40px 8px !important;
    }
    #idlosproCuerpo .row {
        margin: 0 -4px !important;
        width: calc(100% + 8px) !important;
    }
    #idlosproCuerpo .row .col {
        flex: 0 0 50% !important;
        max-width: 50% !important;
        padding: 6px !important;
    }
    .product-card {
        min-height: auto !important;
        margin: 0 !important;
    }
    .product-card .card-body {
        padding: 10px 8px !important;
    }
    .product-title {
        font-size: 0.8rem !important;
        min-height: 2.2em !important;
    }
    .product-price {
        font-size: 1rem !important;
    }
    .product-image-container {
        height: 100px !important;
    }
    .product-card .btn-qty {
        width: 28px !important;
        height: 28px !important;
        font-size: 1rem !important;
    }
    .product-card .qty-controls input {
        width: 40px !important;
        font-size: 0.85rem !important;
    }
}

/* Móvil muy pequeño */
@media (max-width: 360px) {
    #idlosproCuerpo .row .col {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
    .product-title {
        font-size: 0.75rem !important;
    }
    .product-price {
        font-size: 0.9rem !important;
    }
}

/* --- OVERRIDES DE CSS ANTIGUO --- */
.cl-less-img {
    display: none !important;
}
.cl-less-an {
    min-height: auto !important;
}

/* --- SKELETON LOADING --- */
.skeleton-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    width: 100%;
    justify-content: center;
}
.skeleton-card {
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    border: 1px solid #f0f0f0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.skeleton-image {
    height: 140px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: 12px;
    margin-bottom: 16px;
}
.skeleton-title {
    height: 18px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: 8px;
    margin-bottom: 12px;
}
.skeleton-title.short { width: 50%; margin: 0 auto; }
.skeleton-price {
    height: 24px;
    width: 40%;
    margin: 16px auto;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: 8px;
}
.skeleton-btn {
    height: 40px;
    margin-top: 16px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: 10px;
}
/* Final override for image height to ensure consistent look on all devices */
.product-image-container { height: 190px !important; }
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
@media (max-width: 576px) {
    .skeleton-card { padding: 12px; }
    .skeleton-image { height: 100px; }
}

/* --- PAGINACIÓN --- */
#pagination-nav {
    display: none;
    margin-top: 30px;
    justify-content: center;
}
.pagination {
    gap: 8px;
}
.pagination .page-link {
    color: #198754;
    border-color: #e9ecef;
    border-radius: 8px;
    padding: 10px 16px;
    font-weight: 500;
    transition: all 0.2s ease;
}
.pagination .page-link:hover {
    background: #198754;
    border-color: #198754;
    color: white;
}
.pagination .page-item.active .page-link {
    background: linear-gradient(135deg, #198754, #20c997);
    border-color: #198754;
    color: white;
    font-weight: 600;
}
.pagination .page-item.active .page-link:hover {
    background: linear-gradient(135deg, #166b3d, #198754);
}
.pagination .page-item.disabled .page-link {
    color: #6c757d;
    background: #f8f9fa;
}

/* Category header for subcategory pages (consistency) */
.category-header {
  background: #f8f9fa;
  padding: 16px;
  border-radius: 8px;
  margin: 0 1rem 20px;
  text-align: center;
}
.category-header h2 {
  font-size: 1.4rem;
  margin: 0;
}
.category-header p { color: #6c757d; margin: 0; }
@media (max-width: 576px) {
    .pagination .page-link {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
}

/* --- TOAST --- */
#toast-container {
    z-index: 99999;
}
