/* ================================================
   KNIPEX PRODUCT GRID STYLES
   ================================================ */

.knipex-grid-wrapper {
    margin: 40px 0;
    position: relative;
}

/* Header del grid */
.knipex-grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 3px solid #000000;
}

.knipex-grid-title {
    font-size: 32px;
    font-weight: 700;
    color: #000;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    position: relative;
}

.knipex-grid-title::before {
    content: '';
    position: absolute;
    left: 0;
    bottom: -20px;
    width: 60px;
    height: 3px;
    background: #e30613;
}

.knipex-grid-count {
    font-size: 16px;
    color: #666666;
    font-weight: 500;
}

.knipex-grid-count .count-number {
    font-size: 20px;
    font-weight: 700;
    color: #000000;
}

/* ================================================
   FILTROS - SIDEBAR LATERAL
   ================================================ */

/* Botón toggle para móviles */
.knipex-toggle-filters-mobile {
    display: none;
    background: #e30613;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.knipex-toggle-filters-mobile:hover {
    background: #c00510;
}

.knipex-toggle-filters-mobile .filter-icon {
    font-size: 16px;
}

/* Header con contador y botón filtros */
.knipex-grid-header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Layout wrapper con sidebar */
.knipex-content-wrapper {
    display: grid;
    gap: 30px;
    margin-top: 30px;
}

.knipex-content-wrapper.has-sidebar {
    grid-template-columns: 280px 1fr;
}

/* Sidebar */
.knipex-sidebar {
    position: relative;
}

.knipex-filters-wrapper {
    background: #f8f8f8;
    border-radius: 12px;
    border: 2px solid #e5e5e5;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Scrollbar personalizado */
.knipex-filters-wrapper::-webkit-scrollbar {
    width: 6px;
}

.knipex-filters-wrapper::-webkit-scrollbar-track {
    background: #e5e5e5;
    border-radius: 3px;
}

.knipex-filters-wrapper::-webkit-scrollbar-thumb {
    background: #999;
    border-radius: 3px;
}

.knipex-filters-wrapper::-webkit-scrollbar-thumb:hover {
    background: #e30613;
}

.knipex-filters-header {
    padding: 20px;
    border-bottom: 2px solid #e5e5e5;
    position: sticky;
    top: 0;
    background: #f8f8f8;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.knipex-filters-title {
    font-size: 18px;
    font-weight: 700;
    color: #000;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.knipex-filters-title .filter-icon {
    font-size: 20px;
}

.knipex-close-filters-mobile {
    display: none;
    background: transparent;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.knipex-close-filters-mobile:hover {
    color: #e30613;
}

/* Filtros activos */
.knipex-active-filters {
    padding: 15px;
    background: white;
    margin: 15px;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.knipex-active-filter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: #e30613;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.knipex-active-filter .filter-remove {
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    opacity: 0.8;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.knipex-active-filter .filter-remove:hover {
    opacity: 1;
}

/* Container de filtros */
.knipex-filters-container {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.knipex-filter-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.knipex-filter-label {
    font-size: 13px;
    font-weight: 700;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.knipex-filter-label .label-icon {
    font-size: 16px;
}

/* Select personalizado de categorías */
.knipex-select-wrapper {
    position: relative;
}

.knipex-filter-select {
    display: none;
}

.knipex-custom-select {
    position: relative;
    width: 100%;
}

.knipex-custom-select .selected-display {
    background: white;
    border: 2px solid #e5e5e5;
    border-radius: 8px;
    padding: 12px 35px 12px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    font-size: 13px;
    color: #333;
    line-height: 1.3;
}

.knipex-custom-select .selected-display::after {
    content: '▼';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    transition: transform 0.3s ease;
}

.knipex-custom-select.active .selected-display::after {
    transform: translateY(-50%) rotate(180deg);
}

.knipex-custom-select .selected-display:hover {
    border-color: #e30613;
}

.knipex-custom-select .options-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    width: 100%;
    background: white;
    border: 2px solid #e5e5e5;
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.knipex-custom-select.active .options-dropdown {
    display: block;
}

.knipex-custom-select .option-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

.knipex-custom-select .option-item:last-child {
    border-bottom: none;
}

.knipex-custom-select .option-item:hover {
    background: #f8f8f8;
}

.knipex-custom-select .option-item input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: #e30613;
    flex-shrink: 0;
}

.knipex-custom-select .option-item span {
    font-size: 13px;
    color: #333;
    line-height: 1.3;
}

/* Slider de precio */
.knipex-price-slider-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.price-values {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 700;
    color: #e30613;
}

.price-separator {
    color: #999;
    font-weight: 400;
}

.knipex-price-slider {
    position: relative;
    height: 6px;
    margin: 12px 0;
}

.slider-track {
    position: absolute;
    width: 100%;
    height: 6px;
    background: #e5e5e5;
    border-radius: 3px;
}

.slider-range {
    position: absolute;
    height: 6px;
    background: #e30613;
    border-radius: 3px;
}

.knipex-price-slider input[type="range"] {
    position: absolute;
    width: 100%;
    height: 6px;
    background: transparent;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
}

.knipex-price-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #e30613;
    border: 3px solid white;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    transition: transform 0.2s ease;
}

.knipex-price-slider input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.knipex-price-slider input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #e30613;
    border: 3px solid white;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    transition: transform 0.2s ease;
}

.knipex-price-slider input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.15);
}

/* Filtro alfabético */
.knipex-alphabet-filter {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.letter-btn {
    aspect-ratio: 1;
    color: white;
    background-color: white !important;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    color: #313131 !important;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    position: relative;
}

.letter-btn:first-child {
    grid-column: 1 / -1;
    aspect-ratio: auto;
    padding: 8px;
}

.letter-btn:hover {
    border: 2px solid #ec5255;
    transform: translateY(-2px);
    box-shadow: 0 2px 2px rgba(137, 29, 10, 0.721);
}

.letter-btn.active {
    border: 2px solid #ec5255;
    transform: scale(1.05);
    box-shadow: 0 2px 2px rgba(137, 29, 10, 0.721);
}

.letter-btn.active:hover {
    transform: scale(1.05) translateY(-2px);
}

/* Animación al hacer clic */
.letter-btn:active {
    transform: scale(0.95);
}

/* Botones de acción */
.knipex-filter-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 10px;
    border-top: 2px solid #e5e5e5;
}

.knipex-apply-filters,
.knipex-clear-filters {
    width: 100%;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.knipex-apply-filters {
    background: #e30613;
    color: white;
    box-shadow: 0 4px 12px rgba(227, 6, 19, 0.3);
}

.knipex-apply-filters:hover {
    background: #c00510;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(227, 6, 19, 0.4);
}

.knipex-clear-filters {
    background: white;
    color: #666;
    border: 2px solid #e5e5e5;
}

.knipex-clear-filters:hover {
    border-color: #e30613;
    color: #e30613;
}

.knipex-apply-filters.loading {
    opacity: 0.7;
    pointer-events: none;
}

.knipex-apply-filters.loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 8px;
    border: 2px solid white;
    border-radius: 50%;
    border-top-color: transparent;
    animation: knipex-spin 0.6s linear infinite;
}

/* Main content area */
.knipex-main-content {
    min-width: 0;
}

/* ================================================
   GRID DE PRODUCTOS
   ================================================ */

.knipex-products-grid {
    display: grid;
    grid-template-columns: repeat(var(--columnas, 4), 1fr);
    gap: 25px;
    margin: 0;
}

/* Tarjeta de producto */
.knipex-product-card {
    background: white;
    border: 2px solid #e5e5e5;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    position: relative;
}

.knipex-product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 28px rgba(227, 6, 19, 0.2);
    border-color: #e30613;
}

/* Imagen del producto */
.knipex-product-image {
    position: relative;
    background: #fff;
    padding: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    overflow: hidden;
}

.knipex-product-image a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.knipex-product-image img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.knipex-product-card:hover .knipex-product-image img {
    transform: scale(1.05);
}

/* Show more button */
.knipex-load-more-wrapper {
    padding: 2%;
}

.knipex-load-more {
    width: 100%;
}

/* Badges */
.knipex-badge-sale,
.knipex-badge-out {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.knipex-badge-sale {
    background: #e30613;
    color: white;
}

.knipex-badge-out {
    background: #999;
    color: white;
}

/* Información del producto */
.knipex-product-info {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* SKU */
.knipex-product-sku {
    font-size: 12px;
    color: #999;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.knipex-product-sku span {
    color: #666;
    font-weight: 600;
}

/* Título */
.knipex-product-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0 0 12px 0;
    line-height: 1.4;
    min-height: 44px;
    flex-grow: 1;
}

.knipex-product-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.knipex-product-title a:hover {
    color: #e30613;
}

/* Rating */
.knipex-product-rating {
    margin-bottom: 10px;
}

.knipex-product-rating .star-rating {
    font-size: 14px;
}

/* Precio */
.knipex-product-price {
    font-size: 22px;
    font-weight: 700;
    color: #e30613;
    margin-bottom: 15px;
}

.knipex-product-price del {
    color: #999;
    font-size: 16px;
    margin-right: 8px;
    font-weight: 400;
}

.knipex-product-price ins {
    text-decoration: none;
}

/* Stock */
.knipex-product-stock {
    margin-bottom: 15px;
    font-size: 14px;
    font-weight: 600;
}

.knipex-product-stock .in-stock {
    color: #28a745;
}

.knipex-product-stock .out-of-stock {
    color: #dc3545;
}

/* Botón de acción */
.knipex-product-action {
    margin-top: auto;
}

.knipex-add-to-cart,
.knipex-view-product {
    display: block;
    text-decoration: none !important;
    width: 100%;
    background: #e30613;
    color: white;
    padding: 14px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    text-align: center;
    border: none;
    cursor: pointer;
}

.knipex-add-to-cart:hover,
.knipex-view-product:hover {
    background: #c00510;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(227, 6, 19, 0.4);
}

.knipex-add-to-cart.loading {
    opacity: 0.6;
    pointer-events: none;
}

.knipex-add-to-cart.loading::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 8px;
    border: 2px solid white;
    border-radius: 50%;
    border-top-color: transparent;
    animation: knipex-spin 0.6s linear infinite;
}

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

/* Mensaje de no productos */
.knipex-no-products {
    text-align: center;
    padding: 80px 20px;
    color: #999;
    font-size: 18px;
    background: #f8f8f8;
    border-radius: 12px;
    grid-column: 1 / -1;
}

/* ================================================
   RESPONSIVE
   ================================================ */

/* Desktop grande */
@media (min-width: 1400px) {
    .knipex-products-grid[style*="--columnas: 6"] {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* Desktop */
@media (max-width: 1200px) {
    .knipex-products-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 20px;
    }
    
    .knipex-grid-title {
        font-size: 28px;
    }

    .knipex-content-wrapper.has-sidebar {
        grid-template-columns: 260px 1fr;
    }

    .knipex-sidebar {
        width: 260px;
    }
}

/* Tablets */
@media (max-width: 768px) {
    .knipex-products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px;
    }
    
    .knipex-grid-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .knipex-grid-header-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .knipex-grid-title {
        font-size: 24px;
    }
    
    .knipex-product-image {
        min-height: 200px;
        padding: 15px;
    }
    
    .knipex-product-info {
        padding: 15px;
    }
    
    .knipex-product-title {
        font-size: 14px;
        min-height: 38px;
    }
    
    .knipex-product-price {
        font-size: 18px;
    }

    /* Sidebar móvil */
    .knipex-toggle-filters-mobile {
        display: flex;
    }

    .knipex-content-wrapper.has-sidebar {
        grid-template-columns: 1fr;
    }

    .knipex-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        z-index: 9999;
        transition: left 0.3s ease;
        box-shadow: 2px 0 20px rgba(0,0,0,0.3);
    }

    .knipex-sidebar.active {
        left: 0;
    }

    .knipex-filters-wrapper {
        border-radius: 0;
        max-height: 100vh;
        height: 100vh;
        top: 0;
    }

    .knipex-close-filters-mobile {
        display: flex;
    }

    /* Overlay para cerrar sidebar */
    .knipex-sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 9998;
    }

    .knipex-sidebar-overlay.active {
        display: block;
    }

    .knipex-alphabet-filter {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* Móviles */
@media (max-width: 480px) {
    .knipex-products-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
    
    .knipex-grid-title {
        font-size: 20px;
    }
    
    .knipex-product-card {
        border-width: 1px;
    }

    .knipex-sidebar {
        width: 90%;
    }

    .knipex-alphabet-filter {
        grid-template-columns: repeat(5, 1fr);
        gap: 3px;
    }

    .letter-btn {
        font-size: 11px;
    }

    .knipex-filters-container {
        padding: 15px;
    }

    .knipex-active-filters {
        margin: 10px;
        padding: 10px;
    }

    .knipex-active-filter {
        font-size: 11px;
        padding: 6px 10px;
    }
}