/* list.css - Estilos para la página de listado de productos */

/* Configuración y layout principal */
.list-page {
    --list-primary-color: #0ea5e9;
    --list-primary-dark: #0284c7;
    --list-secondary-color: #6366f1;
    --list-text-primary: #0f172a;
    --list-text-secondary: #475569;
    --list-text-muted: #94a3b8;
    --list-border-color: #e2e8f0;
    --list-bg-light: #f8fafc;
    --list-bg-white: #ffffff;
    --list-shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --list-shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --list-shadow-lg: 0 10px 20px rgba(0,0,0,0.1);
    --list-shadow-hover: 0 8px 24px rgba(14,165,233,0.15);

    min-height: 100vh;
    background-color: var(--list-bg-light);
}

/* Layout de 2 columnas (desktop) */
.list-container {
    display: flex;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
    align-items: stretch;
}

/* Sidebar de categorías desktop */
.categories-sidebar-desktop {
    display: none; /* Oculto en móvil por defecto */
    width: 280px;
    flex-shrink: 0;
    align-self: stretch;
    transition: width 0.3s ease, margin 0.3s ease;
}

/* Estado colapsado del sidebar */
.categories-sidebar-desktop.collapsed {
    width: 0;
    margin: 0;
    overflow: hidden;
}

.categories-sidebar-desktop.collapsed .categories-sidebar-panel {
    opacity: 0;
    pointer-events: none;
}

.categories-sidebar-panel {
    flex: 1 1 auto;
    background-color: var(--list-bg-white);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--list-shadow-sm);
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.categories-sidebar-content {
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

/* Asegurar que el footer no sea afectado por el sidebar */
.list-page + .main-footer,
.list-page ~ .main-footer {
    clear: both;
    width: 100%;
}

/* Scrollbar personalizado para el sidebar */
.categories-sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.categories-sidebar-content::-webkit-scrollbar-track {
    background: var(--list-bg-light);
    border-radius: 10px;
}

.categories-sidebar-content::-webkit-scrollbar-thumb {
    background: var(--list-border-color);
    border-radius: 10px;
}

.categories-sidebar-content::-webkit-scrollbar-thumb:hover {
    background: var(--list-text-muted);
}

.categories-sidebar-content h5 {
    color: var(--list-text-primary);
    font-weight: 600;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--list-border-color);
}

/* Contenido principal */
.main-content {
    flex: 1;
    min-width: 0; /* Importante para que el flex funcione correctamente */
}

/* Mostrar sidebar desktop en pantallas grandes */
@media (min-width: 992px) {
    .categories-sidebar-desktop {
        display: flex;
        flex-direction: column;
    }
}

/* Breadcrumb personalizado */
.breadcrumb-nav {
    padding: 1rem 0;
    border-bottom: 1px solid var(--list-border-color);
    margin-bottom: 1.5rem;
    font-size: 1rem;
    font-weight: 500;
}

.breadcrumb-nav a {
    color: var(--list-primary-color);
    text-decoration: none;
    transition: all 0.2s ease;
}

.breadcrumb-nav a:hover {
    color: var(--list-primary-dark);
    text-decoration: underline;
}

.breadcrumb-separator {
    margin: 0 0.5rem;
    color: var(--list-text-muted);
    font-weight: 400;
}

.breadcrumb-separator::before {
    content: '›';
    font-size: 1.1rem;
}

/* Controles de productos */
.products-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1.25rem;
    background-color: var(--list-bg-white);
    border-radius: 12px;
    box-shadow: var(--list-shadow-sm);
}

/* Botón para toggle del sidebar en desktop */
.btn-toggle-sidebar {
    background: var(--list-bg-light);
    color: var(--list-text-primary);
    border: 1px solid var(--list-border-color);
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: none;
    align-items: center;
    gap: 0.5rem;
}

@media (min-width: 992px) {
    .btn-toggle-sidebar {
        display: inline-flex;
    }
}

.btn-toggle-sidebar:hover {
    background: var(--list-primary-color);
    color: white;
    border-color: var(--list-primary-color);
}

.results-info {
    color: var(--list-text-primary);
    font-size: 1rem;
    font-weight: 600;
}

.controls-right {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: flex-end;
}

/* Dropdown de ordenamiento */
.sort-dropdown {
    min-width: 200px;
    border-color: var(--list-border-color);
    color: var(--list-text-primary);
    transition: all 0.3s ease;
    font-weight: 500;
}

.sort-dropdown:hover {
    border-color: var(--list-primary-color);
    box-shadow: var(--list-shadow-md);
    transform: translateY(-1px);
}

.sort-dropdown:focus {
    border-color: var(--list-primary-color);
    box-shadow: 0 0 0 3px rgba(14,165,233,0.1);
}

.products-controls .dropdown-menu {
    border: 1px solid var(--list-border-color);
    box-shadow: var(--list-shadow-lg);
    border-radius: 12px;
    padding: 0.5rem;
}

.products-controls .dropdown-item {
    padding: 0.75rem 1.25rem;
    color: var(--list-text-secondary);
    transition: all 0.2s ease;
    border-radius: 8px;
    font-weight: 500;
}

.products-controls .dropdown-item:hover {
    background-color: var(--list-bg-light);
    color: var(--list-primary-color);
    transform: translateX(4px);
}

.products-controls .dropdown-item.active,
.products-controls .dropdown-item:active {
    background-color: var(--list-primary-color);
    color: white;
}

/* Botón de sidebar */
.btn-sidebar {
    background: var(--list-bg-light);
    color: var(--list-text-primary);
    border: 1px solid var(--list-border-color);
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.btn-sidebar:hover {
    transform: translateY(-2px);
    box-shadow: var(--list-shadow-lg);
    background: var(--list-primary-color);
    color: white;
    border-color: var(--list-primary-color);
}

.btn-sidebar.has-filters {
    position: relative;
}

.btn-sidebar .filter-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: #ef4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    border: 2px solid white;
}

/* Grid de productos */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
    animation: fadeInUp 0.6s ease;
}

/* Sidebar de navegación */
.sidenav {
    height: 100%;
    width: 0;
    position: fixed;
    z-index: 1050;
    top: 0;
    left: 0;
    background-color: var(--list-bg-white);
    overflow-x: hidden;
    padding-top: 60px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 20px rgba(0,0,0,0.15);
}

.sidenav.open {
    width: 360px;
}

.sidenav .closebtn {
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 28px;
    color: var(--list-primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.sidenav .closebtn:hover {
    color: var(--list-primary-dark);
}

.sidenav h5 {
    color: var(--list-text-primary);
    font-weight: 600;
    padding: 0 1.5rem;
    margin-bottom: 1rem;
}

/* Backdrop del sidebar */
.sidenav-backdrop {
    display: none;
    position: fixed;
    z-index: 1049;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease;
}

.sidenav-backdrop.show {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Categorías en sidebar */
.categoria-principal {
    display: block;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--list-text-primary);
    text-decoration: none;
    border-bottom: 1px solid var(--list-border-color);
    transition: all 0.2s ease;
    position: relative;
}

/* Ajustes para sidebar desktop */
.categories-sidebar-desktop .categoria-principal {
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
}

.categories-sidebar-desktop .subcategoria-item {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.categoria-principal:hover {
    background-color: var(--list-bg-light);
    color: var(--list-primary-color);
    padding-left: 2rem;
}

/* Estado activo para categoría principal */
.categoria-principal.active {
    background-color: var(--list-bg-light);
    color: var(--list-primary-color);
    font-weight: 700;
}

.categoria-principal::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: var(--list-primary-color);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.categoria-principal:hover::before,
.categoria-principal.active::before {
    transform: scaleY(1);
}

/* Icono de chevron para móvil */
.categoria-principal::after {
    content: '\f078';
    float: right;
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    transition: transform 0.3s ease;
    display: none;
    font-size: 0.8rem;
    color: var(--list-text-muted);
}

.subcategoria-container {
    padding-left: 0.5rem;
    background-color: var(--list-bg-light);
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.categories-sidebar-desktop .subcategoria-container {
    padding-left: 0.25rem;
}

.subcategoria-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 1.5rem;
    color: var(--list-text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
}

.subcategoria-item:hover {
    background-color: var(--list-bg-white);
    color: var(--list-primary-color);
    border-left-color: var(--list-primary-color);
    padding-left: 2rem;
}

/* Estado activo para subcategoría */
.subcategoria-item.active {
    background-color: var(--list-primary-color);
    color: white;
    font-weight: 600;
    border-left: 3px solid var(--list-primary-dark);
}

.subcategoria-item.active:hover {
    background-color: var(--list-primary-dark);
    color: white;
}

.subcategoria-count {
    background-color: var(--list-bg-light);
    color: var(--list-text-muted);
    padding: 0.25rem 0.625rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 28px;
    text-align: center;
    border: 1px solid var(--list-border-color);
}

/* Contador en subcategoría activa */
.subcategoria-item.active .subcategoria-count {
    background-color: rgba(255, 255, 255, 0.25);
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
}

.subcategoria-item:hover .subcategoria-count {
    background-color: var(--list-bg-white);
    border-color: var(--list-primary-color);
    color: var(--list-primary-color);
}

/* Estado vacío */
.empty-state {
    text-align: center;
    padding: 5rem 2rem;
    background: linear-gradient(135deg, var(--list-bg-white) 0%, var(--list-bg-light) 100%);
    border-radius: 16px;
    border: 2px dashed var(--list-border-color);
}

.empty-state i {
    color: var(--list-primary-color);
    margin-bottom: 1.5rem;
    opacity: 0.4;
}

.empty-state h4 {
    color: var(--list-text-primary);
    margin-bottom: 1rem;
    font-weight: 700;
    font-size: 1.5rem;
}

.empty-state p {
    color: var(--list-text-secondary);
    font-size: 1.05rem;
    margin-bottom: 1.5rem;
}

.empty-state a {
    color: var(--list-primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
}

.empty-state a:hover {
    color: var(--list-primary-dark);
    text-decoration: underline;
}

/* Scroll infinito */
.infinite-loader {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    color: var(--list-text-secondary);
    font-weight: 500;
}

.infinite-loader .spinner-border {
    width: 2.5rem;
    height: 2.5rem;
}

.infinite-loader.hidden {
    display: none;
}

.infinite-loader.error span {
    color: #dc3545;
}

.infinite-end {
    text-align: center;
    color: var(--list-text-secondary);
    font-weight: 600;
    margin-bottom: 2rem;
}

.infinite-end.hidden {
    display: none;
}

.infinite-scroll-trigger {
    width: 100%;
    height: 1px;
}

.page-item.active .page-link {
    background: linear-gradient(135deg, var(--list-primary-color) 0%, var(--list-primary-dark) 100%);
    border-color: var(--list-primary-color);
    color: white;
    font-weight: 600;
    box-shadow: var(--list-shadow-md);
}

.page-item.disabled .page-link {
    color: var(--list-text-muted);
    cursor: not-allowed;
    opacity: 0.5;
}

.page-item {
    margin: 0 0.125rem;
}


/* Animaciones */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

/* Header sticky */
header.sticky {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    box-shadow: 0 2px 20px rgba(0,0,0,0.1);
    background-color: white;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

body.header-sticky {
    padding-top: 80px;
}

/* Responsivo para tablets */
@media (max-width: 992px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }

    .products-controls {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .controls-right {
        width: auto;
        justify-content: flex-end;
    }

    .controls-right .btn-toggle-sidebar {
        order: 0;
    }

    .controls-right .btn-sidebar {
        order: 1;
    }

    .controls-right .dropdown {
        order: 2;
    }
}

/* Responsivo para móviles */
@media (max-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 1rem;
    }

    .products-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        padding: 1rem;
    }

    .results-info {
        display: none;
    }

    .controls-right {
        justify-content: flex-end;
        flex-direction: row;
        gap: 0.75rem;
    }

    .sort-dropdown {
        min-width: auto;
        flex: 1;
    }

    .breadcrumb-nav {
        font-size: 0.875rem;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .sidenav {
        width: 100%;
        max-width: 360px;
    }

    /* Categorías colapsables en móvil */
    .categoria-principal::after {
        content: '\f078';
        display: inline;
    }

    .categoria-principal.expanded::after {
        transform: rotate(180deg);
    }

    .subcategoria-container {
        max-height: 500px;
    }

    .subcategoria-container.collapsed {
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
    }

}

/* Pantallas muy pequeñas */
@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
}

/* Modo oscuro (opcional) */
@media (prefers-color-scheme: dark) {
    .list-page {
        --list-bg-light: #1e293b;
        --list-bg-white: #0f172a;
        --list-text-primary: #f1f5f9;
        --list-text-secondary: #cbd5e1;
        --list-text-muted: #64748b;
        --list-border-color: #334155;
    }
}

/* Mejoras de accesibilidad */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus visible para teclado */
.list-page *:focus-visible {
    outline: 2px solid var(--list-primary-color);
    outline-offset: 2px;
}

/* Transiciones suaves globales */
.list-page * {
    transition-property: background-color, border-color, color, fill, stroke;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

/* ===== SKELETON LOADERS ===== */
.skeleton {
    background: linear-gradient(90deg, var(--list-bg-light) 0%, #e0e7ef 50%, var(--list-bg-light) 100%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 8px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-card {
    height: 400px;
    border-radius: 24px;
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
    width: 100%;
}

.skeleton-text.short {
    width: 60%;
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--list-border-color);
    border-top-color: var(--list-primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== CHIPS DE FILTROS ACTIVOS ===== */
.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: var(--list-bg-white);
    border-radius: 12px;
    align-items: center;
}

.active-filters.empty {
    display: none;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, var(--list-primary-color) 0%, var(--list-primary-dark) 100%);
    color: white;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--list-shadow-sm);
    transition: all 0.2s ease;
}

.filter-chip:hover {
    transform: translateY(-2px);
    box-shadow: var(--list-shadow-md);
}

.filter-chip-label {
    font-weight: 400;
    opacity: 0.9;
}

.filter-chip-value {
    font-weight: 600;
}

.filter-chip-remove {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    text-decoration: none;
}

.filter-chip-remove:hover {
    background-color: rgba(255, 255, 255, 0.2);
    text-decoration: none;
}

.clear-all-filters {
    margin-left: auto;
    background-color: transparent;
    border: 2px solid var(--list-border-color);
    color: var(--list-text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-all-filters:hover {
    border-color: #ef4444;
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.05);
}

/* ===== SCROLL SUAVE ===== */
html {
    scroll-behavior: smooth;
}

/* ===== AJUSTES SUTILES PARA PRESENTACIÓN DE PRODUCTOS ===== */
.list-page .product-card {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.list-page .product-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.list-page .product-info {
    padding: 1rem;
}

.list-page .product-info h3 {
    font-size: 0.875rem;
    font-weight: 500;
    color: #475569;
    margin-bottom: 0.5rem;
}

.list-page .product-card:hover .product-info h3 {
    color: var(--list-primary-color);
}

.list-page .product-info .price .currency {
    font-size: 0.8rem;
    font-weight: 500;
}

.list-page .product-info .price .amount {
    font-size: 1.15rem;
    font-weight: 600;
}

/* Responsive para dispositivos móviles */
@media (max-width: 768px) {
    .list-page .product-info h3 {
        font-size: 0.8rem;
    }

    .list-page .product-info .price .currency {
        font-size: 0.75rem;
    }

    .list-page .product-info .price .amount {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .list-page .product-info h3 {
        font-size: 0.75rem;
        -webkit-line-clamp: 2;
    }

    .list-page .product-info .price .currency {
        font-size: 0.7rem;
    }

    .list-page .product-info .price .amount {
        font-size: 0.95rem;
    }
}

/* ===== ESTADOS DE CARGA DE IMÁGENES ===== */
.product-image img.loading {
    opacity: 1;
    filter: none;
    transition: all 0.3s ease;
}

.product-image img.loaded {
    opacity: 1;
    filter: none;
}

/* ===== INDICADORES DE RANGO DE PRECIO ===== */
.product-info .price[data-price-range="low"] .amount {
    color: #10b981;
}

.product-info .price[data-price-range="low"] .currency {
    color: #10b981;
}

.product-info .price[data-price-range="mid"] .amount {
    color: var(--list-primary-color);
}

.product-info .price[data-price-range="mid"] .currency {
    color: var(--list-primary-color);
}

.product-info .price[data-price-range="high"] .amount {
    color: #f59e0b;
}

.product-info .price[data-price-range="high"] .currency {
    color: #f59e0b;
}

/* ===== MEJORAS DE TRANSICIONES 3D ===== */
.product-card .primary-img {
    transform-style: preserve-3d;
    perspective: 1000px;
}

/* ===== EFECTOS DE FADE-IN ===== */
.product-card.fade-in {
    animation: productFadeIn 0.4s ease forwards;
}

@keyframes productFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
