/* =============================================
   HARDWARE CATALOG - Diseño con Sidebar + Grid
   Rediseño completo para mejor navegación
   ============================================= */

/* Variables */
:root {
    --sidebar-width: 280px;
    --sidebar-bg: #ffffff;
    --filter-border: #e5e7eb;
    --filter-hover: #f3f4f6;
    --accent-green: #10b981;
}

/* =============================================
   CATALOG HEADER - Título y Buscador integrado
   ============================================= */
.catalog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 20px 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.catalog-title {
    color: white;
}

.catalog-title h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.catalog-title h1 i {
    font-size: 1.3rem;
    opacity: 0.9;
}

.products-total {
    font-size: 14px;
    opacity: 0.85;
}

/* Buscador integrado */
.catalog-search {
    display: flex;
    gap: 8px;
    flex: 1;
    max-width: 450px;
}

.search-box {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-box > i {
    position: absolute;
    left: 14px;
    color: #9ca3af;
    font-size: 14px;
}

.search-box input {
    width: 100%;
    padding: 12px 40px 12px 40px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    background: white;
}

.search-box input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.3);
}

.search-box input::placeholder {
    color: #9ca3af;
}

.clear-search {
    position: absolute;
    right: 10px;
    background: #f3f4f6;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    font-size: 11px;
}

.clear-search:hover {
    background: #e5e7eb;
}

.catalog-search button[type="submit"] {
    padding: 12px 18px;
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.catalog-search button[type="submit"]:hover {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.5);
}

/* =============================================
   LAYOUT PRINCIPAL
   ============================================= */
.hardware-catalog-container {
    display: flex;
    gap: 30px;
    padding: 30px 20px;
    max-width: 1600px;
    margin: 0 auto;
    position: relative;
}

/* =============================================
   SIDEBAR DE FILTROS
   ============================================= */
.hardware-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    position: sticky;
    top: 20px;
    height: fit-content;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.hardware-sidebar::-webkit-scrollbar {
    width: 6px;
}

.hardware-sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.hardware-sidebar::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.hardware-sidebar::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Header del sidebar */
.sidebar-header {
    display: none;
}

/* Filtros Activos */
.active-filters-section {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
}

.active-filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 600;
    color: #1e40af;
}

.btn-clear-all {
    font-size: 12px;
    color: #3b82f6;
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
}

.btn-clear-all:hover {
    color: #1d4ed8;
}

.active-filters-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: white;
    border: 1px solid #93c5fd;
    border-radius: 20px;
    font-size: 13px;
    color: #1e40af;
}

.filter-tag button {
    background: none;
    border: none;
    cursor: pointer;
    color: #1e40af;
    opacity: 0.6;
    padding: 0;
    display: flex;
    align-items: center;
}

.filter-tag button:hover {
    opacity: 1;
}

/* Sección de Filtro */
.filter-section {
    background: var(--sidebar-bg);
    border: 1px solid var(--filter-border);
    border-radius: 12px;
    margin-bottom: 15px;
    overflow: hidden;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 18px;
    background: #f9fafb;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.filter-header:hover {
    background: #f3f4f6;
}

.filter-header h4 {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-header h4 i {
    color: var(--primary);
    font-size: 16px;
    width: 20px;
}

.toggle-icon {
    color: #9ca3af;
    font-size: 12px;
    transition: transform 0.3s;
}

.toggle-icon.rotated {
    transform: rotate(180deg);
}

.filter-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out;
}

.filter-content.expanded {
    max-height: 2000px; /* Suficiente para mostrar todo sin scroll */
    overflow: visible;
}

/* Lista de Categorías */
.category-list {
    list-style: none;
    padding: 10px;
    margin: 0;
}

.category-list li {
    margin-bottom: 2px;
}

.category-list li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-radius: 8px;
    color: #4b5563;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
}

.category-list li a:hover {
    background: var(--filter-hover);
    color: var(--primary);
}

.category-list li.active a {
    background: #eff6ff;
    color: var(--primary);
    font-weight: 600;
}

.category-list li a i {
    width: 20px;
    margin-right: 10px;
    text-align: center;
    font-size: 14px;
    flex-shrink: 0;
}

.category-list li a span {
    flex: 1;
}

.category-list li a .count {
    font-size: 12px;
    color: #9ca3af;
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

.category-list li.active a .count {
    background: var(--primary);
    color: white;
}

/* Subcategorías */
.subcategory-list {
    padding-left: 20px !important;
}

.subcategory-list li a {
    padding: 8px 12px;
    font-size: 13px;
}

/* Marcas */
.brand-search {
    padding: 10px 15px 0;
    position: relative;
}

.brand-search input {
    width: 100%;
    padding: 10px 35px 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
}

.brand-search input:focus {
    outline: none;
    border-color: var(--primary);
}

.brand-search i {
    position: absolute;
    right: 25px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 14px;
    margin-top: 5px;
}

.brand-list {
    list-style: none;
    padding: 10px 15px;
    margin: 0;
    max-height: none; /* Sin límite, mostrar todas */
}

/* Mostrar solo las primeras 8 marcas por defecto */
.brand-list:not(.show-all) .brand-item:nth-child(n+9) {
    display: none;
}

.btn-show-more-brands {
    display: block;
    width: calc(100% - 30px);
    margin: 5px 15px 15px;
    padding: 10px;
    background: #f3f4f6;
    border: 1px dashed #d1d5db;
    border-radius: 8px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.btn-show-more-brands:hover {
    background: #e5e7eb;
    border-color: var(--primary);
}

.btn-show-more-brands i {
    margin-left: 5px;
    transition: transform 0.3s;
}

.btn-show-more-brands.expanded i {
    transform: rotate(180deg);
}

.brand-item {
    margin-bottom: 4px;
}

.brand-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
    color: #4b5563;
}

.brand-checkbox:hover {
    background: var(--filter-hover);
}

.brand-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.brand-checkbox .checkmark {
    display: none;
}

.brand-checkbox .brand-name {
    flex: 1;
}

.brand-checkbox .count {
    font-size: 12px;
    color: #9ca3af;
}

.brand-checkbox.checked {
    background: #eff6ff;
    color: var(--primary);
    font-weight: 500;
}

/* Filtro de Precio */
.price-range-inputs {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 15px;
}

.price-input {
    flex: 1;
}

.price-input label {
    display: block;
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 5px;
    text-transform: uppercase;
}

.price-input input {
    width: 100%;
    padding: 10px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
}

.price-input input:focus {
    outline: none;
    border-color: var(--primary);
}

.price-separator {
    color: #9ca3af;
    font-size: 16px;
    padding-top: 20px;
}

.btn-apply-price {
    width: calc(100% - 30px);
    margin: 0 15px 15px;
    padding: 10px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-apply-price:hover {
    background: #5568d3;
}

/* Botón aplicar en móvil */
.mobile-apply-filters {
    display: none;
}

/* =============================================
   CONTENIDO PRINCIPAL
   ============================================= */
.hardware-main {
    flex: 1;
    min-width: 0;
}

/* Barra de resultados */
.results-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    padding: 15px 20px;
    background: white;
    border: 1px solid var(--filter-border);
    border-radius: 12px;
    margin-bottom: 20px;
}

.results-count {
    font-size: 15px;
    color: #6b7280;
}

.results-count strong {
    color: var(--primary);
    font-weight: 700;
}

.sort-options {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sort-options label {
    font-size: 14px;
    color: #6b7280;
}

.sort-options select {
    padding: 10px 35px 10px 15px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    color: #374151;
    background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 12px center;
    appearance: none;
    cursor: pointer;
}

.sort-options select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Grid de Productos */
.products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

/* Tarjeta de Producto */
.product-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    position: relative;
}

.product-card:hover {
    border-color: var(--primary);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    transform: translateY(-4px);
}

/* Badge de descuento */
.discount-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--accent-green);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    z-index: 10;
}

.product-image-container {
    position: relative;
    padding: 15px;
    background: #f9fafb;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.product-image-container .no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #d1d5db;
    font-size: 48px;
}

.product-quick-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    opacity: 0;
    transition: opacity 0.3s;
}

.product-card:hover .product-quick-actions {
    opacity: 1;
}

.btn-quick-view {
    padding: 10px;
    background: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    color: #6b7280;
    transition: all 0.2s;
}

.btn-quick-view:hover {
    background: var(--primary);
    color: white;
}

.product-info {
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-brand {
    font-size: 11px;
    text-transform: uppercase;
    color: #9ca3af;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.product-title {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 8px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 40px;
}

.product-model {
    font-size: 12px;
    color: #6b7280;
    margin: 0 0 12px 0;
}

.product-pricing {
    margin-top: auto;
    margin-bottom: 15px;
}

.price-original {
    font-size: 13px;
    color: #9ca3af;
    text-decoration: line-through;
    display: block;
    margin-bottom: 2px;
}

.price-current {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    display: block;
}

.price-iva {
    font-size: 11px;
    color: #9ca3af;
}

.product-actions {
    display: flex;
    gap: 8px;
}

.btn-add-quote {
    flex: 1;
    padding: 10px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-add-quote:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

.btn-view-details {
    padding: 10px 14px;
    background: #f3f4f6;
    color: #6b7280;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.btn-view-details:hover {
    background: #e5e7eb;
    color: #374151;
}

/* Paginación */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 40px;
    flex-wrap: wrap;
}

.page-numbers {
    display: flex;
    gap: 5px;
}

.page-link {
    padding: 10px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    color: #6b7280;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.page-link:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.page-link.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.page-ellipsis {
    padding: 10px 8px;
    color: #9ca3af;
}

/* Sin resultados */
.no-results {
    text-align: center;
    padding: 80px 20px;
    background: white;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

.no-results i {
    font-size: 64px;
    color: #d1d5db;
    margin-bottom: 20px;
}

.no-results h3 {
    font-size: 20px;
    color: #374151;
    margin: 0 0 10px 0;
}

.no-results p {
    color: #6b7280;
    margin: 0 0 20px 0;
}

.btn-reset-filters {
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-reset-filters:hover {
    background: #5568d3;
}

/* Botón scroll to top */
.scroll-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: 100;
}

.scroll-top.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-top:hover {
    background: #5568d3;
    transform: translateY(-3px);
}

/* =============================================
   MOBILE - Botón de filtros y drawer
   ============================================= */
.mobile-filter-toggle {
    display: none;
    position: sticky;
    top: 10px;
    z-index: 50;
    width: calc(100% - 40px);
    margin: 0 20px 20px;
    padding: 12px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.mobile-filter-toggle .filter-count {
    background: white;
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 1400px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1100px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .hardware-sidebar {
        width: 250px;
    }
}

@media (max-width: 900px) {
    .hardware-catalog-container {
        flex-direction: column;
        padding: 15px;
    }

    .mobile-filter-toggle {
        display: flex;
    }

    .hardware-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        max-height: 100vh;
        background: white;
        z-index: 1000;
        transition: left 0.3s ease;
        padding: 0;
        box-shadow: 5px 0 20px rgba(0, 0, 0, 0.1);
        overflow-y: auto;
    }

    .hardware-sidebar.open {
        left: 0;
    }

    .sidebar-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 20px;
        border-bottom: 1px solid #e5e7eb;
        position: sticky;
        top: 0;
        background: white;
        z-index: 10;
    }

    .sidebar-header h3 {
        font-size: 18px;
        margin: 0;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .close-sidebar {
        padding: 8px 12px;
        background: #f3f4f6;
        border: none;
        border-radius: 6px;
        cursor: pointer;
        font-size: 18px;
        color: #6b7280;
    }

    .close-sidebar:hover {
        background: #e5e7eb;
    }

    .active-filters-section {
        margin: 15px;
        border-radius: 8px;
    }

    .filter-section {
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        margin-bottom: -1px;
    }

    .mobile-apply-filters {
        display: block;
        padding: 15px;
        position: sticky;
        bottom: 0;
        background: white;
        border-top: 1px solid #e5e7eb;
    }

    .mobile-apply-filters button {
        width: 100%;
        padding: 14px;
        background: var(--primary);
        color: white;
        border: none;
        border-radius: 10px;
        font-size: 15px;
        font-weight: 600;
        cursor: pointer;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .product-image-container {
        height: 150px;
    }

    .product-title {
        font-size: 13px;
        min-height: 36px;
    }

    .price-current {
        font-size: 18px;
    }

    .results-bar {
        padding: 12px 15px;
        flex-direction: column;
        align-items: flex-start;
    }

    .sort-options {
        width: 100%;
    }

    .sort-options select {
        flex: 1;
    }

    /* Header responsive */
    .catalog-header {
        flex-direction: column;
        align-items: stretch;
        padding: 15px;
        gap: 15px;
        text-align: center;
    }

    .catalog-title h1 {
        font-size: 1.2rem;
        justify-content: center;
    }

    .catalog-search {
        max-width: 100%;
    }

    .search-box input {
        padding: 10px 35px 10px 35px;
        font-size: 13px;
    }

    .catalog-search button[type="submit"] {
        padding: 10px 14px;
    }
}

@media (max-width: 600px) {
    .products-grid {
        grid-template-columns: 1fr;
    }

    .product-card {
        flex-direction: row;
    }

    .product-image-container {
        width: 120px;
        height: 120px;
        flex-shrink: 0;
        border-radius: 12px 0 0 12px;
    }

    .discount-badge {
        top: 5px;
        left: 5px;
        font-size: 10px;
        padding: 3px 8px;
    }

    .product-info {
        padding: 12px;
    }

    .product-title {
        min-height: auto;
        -webkit-line-clamp: 1;
    }

    .product-model {
        margin-bottom: 8px;
    }

    .product-pricing {
        margin-bottom: 10px;
    }

    .product-actions {
        flex-direction: column;
        gap: 6px;
    }

    .btn-add-quote,
    .btn-view-details {
        padding: 8px;
        font-size: 12px;
        justify-content: center;
    }

    .pagination {
        gap: 5px;
    }

    .page-link {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
