.catalog-main {
    margin-top: 70px;
    padding: 2rem;
    min-height: calc(100vh - 70px);
    background-color: #f6faff;
    /* background: linear-gradient(135deg, #01043a, #07078d, #0000a3 ); */
    background: linear-gradient(135deg, #fff, #4f6f8f, #36485a);
    box-shadow: inset 0 2px 15px rgba(0, 0, 0, 0.03);
}

.catalog-container {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2rem;
}

.filters {
    background: var(--light-bg);
    filter: brightness(1.03);
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: sticky;
    top: 90px;
    max-height: calc(100vh - 120px); 
    overflow-y: auto;
    -ms-overflow-style: none; 
    scrollbar-width: none; 
    border-left: 3px solid var(--secondary-color);
}

.filters::-webkit-scrollbar {
    display: none;
}

.filter-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
}

.filter-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.filter-section h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.filter-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--text-color);
    padding: 0.35rem 0.5rem;
    border-radius: 8px;
    border: 1px solid transparent;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.filter-group label:hover {
    background: rgba(52,152,219,0.06);
}

.filter-group label:has(input:checked) {
    background: rgba(52,152,219,0.12);
    border-color: rgba(52,152,219,0.25);
    color: var(--primary-color);
    font-weight: 600;
}

.filter-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--secondary-color);
}

.filter-group input[type="checkbox"][name="category"],
.filter-group input[type="checkbox"][name="manufacturer"] {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    background: #fff;
    display: inline-grid;
    place-content: center;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.filter-group input[type="checkbox"][name="category"]::after,
.filter-group input[type="checkbox"][name="manufacturer"]::after {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--secondary-color);
    transform: scale(0);
    transition: transform 0.2s ease;
}

.filter-group input[type="checkbox"][name="category"]:checked,
.filter-group input[type="checkbox"][name="manufacturer"]:checked {
    border-color: var(--secondary-color);
    background-color: #ecf5fd;
    box-shadow: 0 0 0 3px rgba(52,152,219,0.15);
}

.filter-group input[type="checkbox"][name="category"]:checked::after,
.filter-group input[type="checkbox"][name="manufacturer"]:checked::after {
    transform: scale(1);
}

.filter-group input[type="checkbox"][name="category"]:focus-visible,
.filter-group input[type="checkbox"][name="manufacturer"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(52,152,219,0.2);
}

.filter-group input[type="checkbox"][name="viscosity"] {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #cbd5e1;
    background: #fff;
    display: inline-grid;
    place-content: center;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    transform: rotate(45deg);
    border-radius: 4px;
}

.filter-group input[type="checkbox"][name="viscosity"]::after {
    content: '';
    width: 10px;
    height: 10px;
    background: var(--secondary-color);
    transform: scale(0);
    transition: transform 0.2s ease;
}

.filter-group input[type="checkbox"][name="viscosity"]:checked {
    border-color: var(--secondary-color);
    background-color: #ecf5fd;
    box-shadow: 0 0 0 3px rgba(52,152,219,0.15);
}

.filter-group input[type="checkbox"][name="viscosity"]:checked::after {
    transform: scale(1);
}

.filter-group input[type="checkbox"][name="viscosity"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(52,152,219,0.2);
}

.price-range-container {
    padding: 0.5rem 0;
}

.price-inputs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.price-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    appearance: textfield;
    -moz-appearance: textfield; 
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.price-input:hover { border-color: #ccc; }
.price-input:focus { outline: none; border-color: var(--secondary-color); box-shadow: 0 0 0 3px rgba(52,152,219,0.15); }

.price-input::-webkit-outer-spin-button,
.price-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.slider {
    height: 5px;
    position: relative;
    background: #ddd;
    border-radius: 5px;
}

.slider .progress {
    height: 100%;
    left: 0%;
    right: 0%;
    position: absolute;
    border-radius: 5px;
    background: var(--secondary-color);
}

.range-input {
    position: relative;
}

.range-input input {
    position: absolute;
    width: 100%;
    height: 5px;
    top: -5px;
    background: none;
    pointer-events: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    height: 17px;
    width: 17px;
    border-radius: 50%;
    background: var(--secondary-color);
    pointer-events: auto;
    -webkit-appearance: none;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.05);
}

input[type="range"]::-moz-range-thumb {
    height: 17px;
    width: 17px;
    border: none;
    border-radius: 50%;
    background: var(--secondary-color);
    pointer-events: auto;
    -moz-appearance: none;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.05);
}

.apply-filters,
.reset-filters {
    width: 100%;
    padding: 0.8rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s ease;
}

.apply-filters {
    background-color: var(--secondary-color);
    color: var(--white);
    margin-bottom: 0.5rem;
}

.apply-filters:hover {
    background-color: var(--secondary-600);
}

.reset-filters {
    background-color: #f1f1f1;
    color: var(--text-color);
}

.reset-filters:hover {
    background-color: #e1e1e1;
}

.catalog-content {
    background-color: var(--light-bg);
    filter: brightness(1.03);
    /* background: #fafafa; */
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.catalog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.catalog-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.sort-select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: var(--white);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sort-select:hover { border-color: #ccc; }
.sort-select:focus { outline: none; border-color: var(--secondary-color); box-shadow: 0 0 0 3px rgba(52,152,219,0.15); }

.view-options {
    display: flex;
    gap: 0.5rem;
}

.view-options button {
    padding: 0.5rem;
    border: 1px solid #ddd;
    background: none;
    border-radius: 5px;
    cursor: pointer;
    color: var(--text-color);
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.1s ease;
}

.view-options button.active {
    background-color: var(--secondary-color);
    color: var(--white);
    border-color: var(--secondary-color);
}

.view-options button:hover:not(.active) {
    background: rgba(52,152,219,0.06);
    border-color: #ccc;
}
.view-options button:active { transform: scale(0.98); }

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Режим списка */
.products-grid.view-list {
    grid-template-columns: 1fr;
}

/* Явно прописываем режим сетки (для дальнейших мобильных переопределений) */
.products-grid.view-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.products-grid.view-list .product-card {
    flex-direction: row;
    align-items: stretch;
}

.products-grid.view-list .product-image {
    width: 260px;
    height: 220px;
    flex: 0 0 260px;
}

.products-grid.view-list .product-info {
    padding: 1rem 1.25rem;
}

@media (min-width: 1600px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 2rem;
    }
}

@media (max-width: 1200px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 1.25rem;
    }
}

@media (max-width: 900px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 1rem;
    }
}

@media (max-width: 600px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1rem;
    }
}

/* Адаптив: различаем режимы на телефонах */
@media (max-width: 600px) {
    /* Сетка: две колонки на телефоне */
    .products-grid.view-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .products-grid.view-grid .product-image {
        height: 160px;
    }

    /* Список: горизонтальный ряд, картинка компактнее слева */
    .products-grid.view-list .product-card {
        flex-direction: row;
        align-items: stretch;
    }
    .products-grid.view-list {
        grid-template-columns: 1fr !important;
    }
    .products-grid.view-list .product-image {
        width: 40%;
        flex: 0 0 40%;
        height: 140px;
    }
    .products-grid.view-list .product-info {
        padding: 0.75rem;
    }
}

.product-card {
    background: var(--white);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid rgba(15,23,42,0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 24px rgba(15,23,42,0.14);
    border-color: rgba(52,152,219,0.35);
}

.product-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.product-image {
    position: relative;
    height: 220px;
    background: linear-gradient(135deg, #fafbfc 0%, #f8f9fa 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

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

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

.product-badge {
    position: absolute;
    top: 1rem;
    left: 1rem;
    padding: 0.5rem 1rem;
    background-color: var(--secondary-color);
    color: var(--white);
    border-radius: 20px;
    font-size: 0.8rem;
}

.product-badge.sale {
    background-color: var(--accent-color);
}

.product-info {
    padding: 1.25rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-info h3 {
    margin-bottom: 0.75rem;
    color: var(--primary-color);
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-info h3 {
    position: relative;
    padding-bottom: 6px;
}
.product-info h3::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: 0;
    background: var(--secondary-color);
    transition: width 0.25s ease;
}
.product-card:hover .product-info h3::after {
    width: 42%;
}

.product-category,
.product-specs {
    color: #64748b;
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.product-price {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(15,23,42,0.06);
}

.price {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: -0.025em;
}

.add-to-cart {
    padding: 0.5rem;
    border: none;
    background-color: var(--secondary-color);
    color: var(--white);
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.add-to-cart:hover {
    background-color: var(--secondary-600);
}

/* Пагинация */
.pagination {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 2rem;
}

.pagination button {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    background: var(--white);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    line-height: 1;
}

.pagination button.active {
    background-color: var(--secondary-color);
    color: var(--white);
    border-color: var(--secondary-color);
    font-weight: 600;
}

.pagination button:hover:not(.active) {
    background-color: #f1f1f1;
    border-color: #ccc;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15,23,42,0.08);
}

.pagination button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    background-color: #f8f8f8;
}

.pagination-ellipsis {
    padding: 0.5rem 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.45s ease, transform 0.45s ease;
}
.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}
.products-grid .product-card:not(.fade-in) {
    animation: cardIn 0.35s ease both;
}

.product-id {
    display: inline-block;
    background: rgba(52,152,219,0.08);
    color: #475569;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.025em;
}

.product-image.loading {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}

.product-image.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    border: 2px solid #e2e8f0;
    border-top-color: var(--secondary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.product-image img {
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.loading-message {
    text-align: center;
    color: var(--primary-color);
    padding: 1rem;
    position: relative;
}

.loading-message::after {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    margin-left: 8px;
    border: 2px solid #ddd;
    border-top-color: var(--secondary-color);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: -3px;
}

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

@media (max-width: 1024px) {
    .catalog-container {
        grid-template-columns: 240px 1fr;
    }
}

@media (max-width: 768px) {
    .catalog-main {
        margin-top: 60px;
        padding: 1rem;
    }

    .catalog-container {
        grid-template-columns: 1fr;
    }

    .filters {
        position: static;
        margin-bottom: 1rem;
        padding: 1rem;
    }

    .filter-section {
        margin-bottom: 1rem;
        padding-bottom: 1rem;
    }

    .filter-group {
        gap: 0.5rem;
    }

    .filter-group label {
        font-size: 0.9rem;
    }

    .price-inputs {
        flex-direction: column;
        gap: 0.5rem;
    }

    .catalog-content {
        padding: 1rem;
    }

    .catalog-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .catalog-controls {
        flex-direction: column;
        gap: 0.5rem;
    }

    .sort-select,
    .view-options {
        width: 100%;
    }

    .view-options {
        justify-content: center;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1rem;
    }

    .product-card {
        margin-bottom: 0;
    }

    .product-image {
        height: 180px;
    }

    .product-info h3 {
        font-size: 1rem;
    }

    .product-category,
    .product-specs {
        font-size: 0.8rem;
    }

    .price {
        font-size: 1.1rem;
    }

    .pagination {
        margin-top: 1rem;
    }

    .pagination-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .catalog-main {
        padding: 0.5rem;
    }

    .filters,
    .catalog-content {
        padding: 0.8rem;
    }

    .products-grid {
        grid-template-columns: 1fr;
    }

    .product-image {
        height: 200px;
    }

    .apply-filters,
    .reset-filters {
        padding: 0.6rem;
        font-size: 0.9rem;
    }

    .catalog-header h2 {
        font-size: 1.3rem;
    }

    .sort-select {
        font-size: 0.9rem;
    }

    .view-options button {
        padding: 0.4rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 768px) {
    .products-grid.list-view .product-card {
        grid-template-columns: 1fr;
    }

    .products-grid.list-view .product-image {
        height: 200px;
    }

    .products-grid.list-view .product-info {
        padding: 0.8rem;
    }
}

@media (hover: none) {
    .product-card:hover {
        transform: none;
    }

    .add-to-cart:active {
        background-color: var(--secondary-600);
    }

    .pagination-btn:active {
        background-color: #f1f1f1;
    }

    .apply-filters:active {
        background-color: var(--secondary-600);
    }

    .reset-filters:active {
        background-color: #e1e1e1;
    }
} 