.catalog-page {
    padding: 40px 0;
}

.catalog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.catalog-title {
    font-size: 2rem;
    color: var(--secondary-color);
}

.catalog-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.view-options {
    display: flex;
    border: 1px solid var(--light-gray);
    border-radius: 5px;
    overflow: hidden;
}

.view-option {
    padding: 8px 12px;
    background: white;
    border: none;
    cursor: pointer;
    transition: background 0.3s;
}

.view-option.active {
    background: var(--primary-color);
    color: white;
}

.filter-toggle {
    display: none;
    padding: 8px 15px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.catalog-content {
    display: grid;
    grid-template-columns: 430px 1fr;
    gap: 30px;
}

.catalog-filters {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    height: fit-content;
}

.filter-group {
    margin-bottom: 25px;
}

.filter-title {
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--light-gray);
}

.filter-list {
    list-style: none;
    line-height: 1.2;
}

.filter-item {
    margin-bottom: 3px;
    transition: background-color 0.2s;
    padding: 3px 0;
}

.filter-item label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}

.filter-item input {
    margin-right: 10px;
}

.filter-buttons {
    display: flex;
    gap: 10px;
}

.filter-buttons button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.apply-filters {
    background: var(--primary-color);
    color: white;
}

.reset-filters {
    background: var(--light-gray);
}

/* Основной контейнер для каталога */
.catalog-main {
    display: flex;
    flex-direction: column;
    min-height: 600px;
}

/* ИСПРАВЛЕНИЕ: Карточки всегда прижаты кверху */
.catalog-products {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 вертикальных ряда */
    gap: 25px;
    flex-grow: 1;
    align-items: start; /* ВАЖНО: прижимаем к началу */
    justify-items: start; /* Прижимаем к началу по горизонтали */
}

.catalog-grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    align-items: start;
}

.catalog-list-view {
    display: none;
    flex-direction: column;
    gap: 20px;
}

.catalog-grid-view.active {
    display: grid;
}

.catalog-list-view.active {
    display: flex;
}

/* ИСПРАВЛЕНИЕ: Фиксированная высота и прижатие кверху */
.product-card {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s, box-shadow 0.3s;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    height: 350px; /* Фиксированная высота */
    border: 1px solid var(--light-gray);
    cursor: pointer;
    /* ВАЖНО: убираем растягивание */
    align-self: start; /* Не растягивается по высоте ряда */
    justify-self: start; /* Не растягивается по ширине */
    width: 100%; /* Занимает всю ширину ячейки */
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    border-color: var(--light-gray);
}

.product-image {
    height: 220px;
    flex-shrink: 0;
    overflow: hidden;
}

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

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

.product-info {
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    flex-grow: 1;
    min-height: 80px;
    gap: 8px;
}

.product-category {
    font-size: 0.9rem;
    color: var(--gray-color);
    font-weight: 500;
    line-height: 1.2;
    margin-bottom: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    margin-top: 0;
}

.product-name {
    display: none;
}

.product-description {
    display: none;
}

.product-article {
    font-size: 0.8rem;
    color: var(--gray-color);
    font-style: italic;
    margin-bottom: 0;
    margin-top: auto; /* Прижимаем к низу */
}

.product-list-item {
    display: flex;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    text-decoration: none;
    color: inherit;
    height: 250px;
    align-items: start;
}

.product-list-image {
    width: 250px;
    flex-shrink: 0;
}

.product-list-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-list-info {
    padding: 25px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* Стили для пагинации */
.pagination-container {
    display: flex;
    justify-content: center;
    margin-top: 40px;
    width: 100%;
}

.pagination {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    justify-content: center;
}

.pagination-item {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--light-gray);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.pagination-item:hover, .pagination-item.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination-ellipsis {
    cursor: default;
    background: transparent !important;
    color: var(--gray-color) !important;
    border-color: var(--light-gray) !important;
}

.pagination-ellipsis:hover {
    background: transparent !important;
    color: var(--gray-color) !important;
    border-color: var(--light-gray) !important;
}

/* Стиль для неопределенного состояния чекбокса */
input[type="checkbox"]:indeterminate {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

input[type="checkbox"].indeterminate {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.filter-item:hover {
    background-color: var(--light-color);
}

.filter-item input[type="checkbox"] {
    margin-right: 10px;
}

.filter-item[style*="margin-left"] {
    border-left: none;
    padding-left: 15px;
}

.filter-item label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 4px 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.filter-item label:hover {
    background-color: var(--light-color);
}

.filter-item input[type="checkbox"] {
    margin-right: 10px;
    flex-shrink: 0;
}

.filter-item span {
    flex-grow: 1;
}

.filter-item[style*="padding-left"] {
    border-left: none;
    margin-left: 10px;
    padding-left: 15px;
}

input[type="checkbox"]:indeterminate {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Crect x='3' y='7' width='10' height='2' fill='white'/%3E%3C/svg%3E");
}

input[type="checkbox"].indeterminate {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Crect x='3' y='7' width='10' height='2' fill='white'/%3E%3C/svg%3E");
}

/* ИСПРАВЛЕНИЕ: Убираем автоматическое растягивание рядов */
.catalog-products {
    grid-auto-rows: min-content; /* Ряды занимают только необходимую высоту */
}

/* Стили для списка товаров (list view) */
.catalog-list-view .product-list-info .product-category {
    font-size: 0.9rem;
    color: var(--gray-color);
    margin-bottom: 5px;
}

.catalog-list-view .product-list-info .product-name {
    display: block;
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--dark-color);
}

.catalog-list-view .product-list-info .product-description {
    display: block;
    font-size: 0.95rem;
    color: var(--gray-color);
    margin-bottom: 15px;
    line-height: 1.5;
}

.catalog-list-view .product-list-info .product-article {
    font-size: 0.85rem;
    color: var(--gray-color);
    font-style: italic;
    margin-top: auto;
}

/* Стили для пустого состояния */
.catalog-products:empty::before {
    content: "Загрузка товаров...";
    display: block;
    text-align: center;
    padding: 40px;
    grid-column: 1 / -1;
    color: var(--gray-color);
}

.catalog-products .no-products-message {
    text-align: center;
    padding: 40px;
    grid-column: 1 / -1;
    color: var(--gray-color);
}

.catalog-products .empty-state {
    text-align: center;
    padding: 60px 40px;
    grid-column: 1 / -1;
}

.empty-state i {
    font-size: 3rem;
    color: var(--light-gray);
    margin-bottom: 20px;
}

.empty-state h3 {
    color: var(--gray-color);
    margin-bottom: 10px;
}

.empty-state p {
    color: var(--gray-color);
}

/* Адаптивность для каталога */
@media (max-width: 1200px) {
    .catalog-content {
        grid-template-columns: 350px 1fr;
    }
}

@media (max-width: 992px) {
    .catalog-content {
        grid-template-columns: 280px 1fr;
    }

    .product-list-image {
        width: 200px;
    }

    .product-card {
        height: 320px;
    }

    .product-image {
        height: 200px;
    }
}

@media (max-width: 768px) {
    .catalog-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .catalog-controls {
        width: 100%;
        justify-content: space-between;
    }

    .filter-toggle {
        display: block;
    }

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

    .catalog-filters {
        display: none;
        position: static;
        transform: none;
    }

    .catalog-filters.active {
        display: block;
    }

    .product-list-item {
        flex-direction: column;
        height: auto;
    }

    .product-list-image {
        width: 100%;
        height: 200px;
    }

    .product-image {
        height: 200px;
    }

    .product-info {
        padding: 12px;
    }

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

    .product-card {
        height: 300px;
    }
}

@media (max-width: 576px) {
    .view-options {
        display: none;
    }

    .product-image {
        height: 180px;
    }

    .product-card {
        height: 280px;
    }

    .pagination-item {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }

    .catalog-products {
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .pagination-item {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }

    .pagination {
        gap: 3px;
    }

    .product-card {
        height: 260px;
    }

    .product-image {
        height: 160px;
    }
}

/* ДОПОЛНИТЕЛЬНОЕ ИСПРАВЛЕНИЕ: Контейнер для сообщений */
.no-products-container {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    margin: 20px 0;
    align-self: start; /* Прижимаем сообщение кверху */
}

/* Убираем растягивание для всех элементов внутри grid */
.catalog-products > * {
    align-self: start;
}
