/* Полная стилизация карточки товара и сайдбара для страницы категории */
.custom-product-card a{
text-decoration: none;
}

/* Скрытие отфильтрованных карточек */
.product-layout.hide {
display: none !important;
}

/* Стили для общей структуры страницы */
.custom-page-layout {
    display: flex;
    flex-direction: row;
    gap: 1.5rem;
    width: 100%;
    box-sizing: border-box;
}

.custom-sidebar {
    flex: 0 0 20%;
    max-width: 20%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 1rem;
    align-self: flex-start;
}

.custom-main-content {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Стили для контейнера продукта */
.Category-content.product-wrap {
    width: 100%;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

/* Стили для сетки карточек товаров */
.custom-products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 карточки на десктопе */
    gap: 1rem;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    align-items: stretch; /* Выравнивание карточек по высоте */
}

/* Адаптивность для планшетов */
@media (max-width: 1199px) and (min-width: 991px) {
    /* На планшетах сайдбар остается слева */
    .custom-sidebar .sidebar-menu {
        padding: 1.2rem;
        margin-bottom: 1.5rem;
    }

    .custom-sidebar .sidebar-menu__title {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }

    .custom-sidebar .sidebar-menu__link {
        padding: 0.8rem 1rem;
        font-size: 1.2rem;
    }
    
    .custom-products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
}

@media (max-width: 991px) {
    .custom-sidebar {
        position: fixed;
        top: 60px; /* Отступ от header */
        left: 0;
        width: 100%;
        max-width: 100%; /* Максимальная ширина 100% */
        height: 100%;
        background: #ffffff;
        border-radius: 0;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        padding: 1.5rem;
        margin: 0;
        z-index: 1000;
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .custom-sidebar.expanded {
        transform: translateX(0);
    }
    
    .custom-sidebar.expanded .sidebar-close-btn {
        display: block;
    }
    
    /* Убедимся, что сайдбар не перекрывает основной контент */
    .custom-main-content {
        position: relative;
        z-index: 1;
    }
}

@media (max-width: 768px) {
    /* На мобильных устройствах сайдбар становится раскрывающимся меню */
    .custom-page-layout {
        flex-direction: column;
    }

    .custom-main-content {
        width: 100%;
        display: flex;
        flex-direction: column;
    }

    .custom-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .custom-page-layout {
        gap: 1.2rem;
        padding: 0.8rem;
    }


    .custom-product-card .price-new {
        font-size: 1.6rem;
    }

    .custom-product-card .product-name {
        font-size: 1.45rem;
    }

    .custom-main-content .category-content {
        width: 100%;
        display: flex;
        flex-direction: column;
        flex: 1;
    }

    .custom-main-content .custom-products-grid {
        width: 100%;
        display: grid;
        flex: 1;
    }

    .product_tag {
        gap: 0.5rem;
        margin: 1rem 0;
        font-size: 0.85rem;
    }

    .blog_tag_item {
        padding: 0.35rem 0.85rem;
        font-size: 0.8rem;
        margin: 0px;
    }
}

@media (max-width: 991px) {
    .custom-products-grid {
        grid-template-columns: repeat(3, 1fr); 
    }
}

@media (max-width: 575px) {
    .custom-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.8rem;
    }

    .custom-page-layout {
        padding: 0.5rem;
        gap: 0.8rem;
    }

    .product_tag {
        justify-content: center;
    }

    /* Убедимся, что карточки занимают всю ширину на мобильных */
    .custom-product-card {
        width: 100%;
        max-width: 100%;
    }

    /* Убедимся, что контент внутри main-content отображается правильно на мобильных */
    .custom-main-content .category-content {
        width: 100%;
        display: flex;
        flex-direction: column;
        flex: 1;
    }

    .custom-main-content .custom-products-grid {
        width: 100%;
        display: grid;
        flex: 1;
    }

    .custom-product-card .price-new {
        font-size: 1.4rem;
    }

    .custom-product-card .product-name {
        font-size: 1.2rem;
    }

    .custom-product-card .product-content {
        font-size: 1rem;
    }

    .custom-product-card .add-cart87 {
        padding: 0.55rem 0.75rem;
        font-size: 0.9rem;
    }

    .custom-product-card .add-cart87 svg {
        width: 1.4em;
        height: 1.4em;
    }

    .custom-sidebar .sidebar-menu {
        padding: 1rem;
        margin-bottom: 1.2rem;
    }

    .custom-sidebar .sidebar-menu__title {
        font-size: 1rem;
        margin-bottom: 0.8rem;
    }

    .custom-sidebar .sidebar-menu__link {
        padding: 0.7rem 0.9rem;
        font-size: 1.1rem;
    }
}

/* Основные стили для карточки товара */
.custom-product-card {
    width: auto;
    box-shadow: 1px 2px 4px rgb(0 0 0 / 10%);
    display: flex;
    border-radius: 12px;
    flex-direction: column;
    transition: 0.2s;
    position: relative;
    background: #fff;
    overflow: hidden;
}

.custom-product-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Стили для оверлея ссылки на всю карточку */
.custom-product-card .product-link-overlay {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    text-decoration: none;
    color: inherit;
    z-index: 1;
}

/* Стили для основного контейнера карточки */
.custom-product-card .product-layout.product-grid {
    height: 100%;
    display: flex;
    flex-direction: column;
    width: 100%;
    position: relative;
}

/* Стили для контейнера изображения */
.custom-product-card .product-thumb {
    width: auto;
    min-height: 350px;
    box-shadow: 1px 2px 4px rgb(0 0 0 / 10%);
    display: flex;
    border-radius: 12px;
    flex-direction: column;
    transition: 0.2s;
    position: relative;
    background: #fff;
    padding: 10px;
    overflow: hidden;
}

/* Стили для верхней части карточки (изображение) */
.custom-product-card .card__top {
    width: 100%;
    text-align: center;
    position: relative;
    overflow: hidden;
    flex-shrink: 0; /* Предотвращаем сжатие верхней части */
    display: flex;
    justify-content: center;
    align-items: start;
    margin: 0;
    padding: 0;
}

/* Стили для изображения товара */
.card__top {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
}

.card__top img {
    max-width: 100%;
    width: 100%;
    height: auto;
    object-fit: cover;
    margin: 0;
    padding: 0;
}

/* Стили для скидки */
.custom-product-card .sale {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #d9534f;
    font-size: 13px;
    text-align: center;
    color: #fff;
    font-weight: 700;
    width: 75px;
    height: 43px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 3px;
    z-index: 2;
    border-radius: 4px;
}

/* Стили для нижней части карточки */
.custom-product-card .card__bottom {
    display: flex;
    flex-direction: column;
    padding: 10px;
    flex: 1 1 auto; /* Позволим нижней части занимать оставшееся пространство */
}

/* Стили для контента названия и информации о товаре */
.custom-product-card .product-title-content {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto; /* Позволим элементу расти и заполнять доступное пространство */
    gap: 0.5rem;
    width: 100%;
    margin: 0;
    min-height: 0;
}

/* Стили для статуса товара */
.custom-product-card .stock {
    font-size: 13px;
    font-weight: 500;
    flex-shrink: 0; /* Предотвращаем сжатие статуса */
}

/* Стили для цены и скидки */
.custom-product-card .buy-box {
    display: inline-block;
    margin-top: 10px;
    flex-shrink: 0; /* Предотвращаем сжатие блока цены */
}

.custom-product-card .price {
    transition: all .3s;
    overflow: hidden;
    flex-shrink: 0; /* Предотвращаем сжатие блока цены */
}

.custom-product-card .price-new {
    font-size: 1.8rem;
    font-weight: 700;
    color: #0071b8;
    line-height: normal;
    flex-shrink: 0; /* Предотвращаем сжатие цены */
}

.custom-product-card .price-old {
    color: #969ea4;
    text-decoration: line-through;
    display: inline-block;
    font-size: 13px;
    height: 100%;
    line-height: 23px;
    margin-right: 10px;
    flex-shrink: 0; /* Предотвращаем сжатие старой цены */
}

.custom-product-card .product-price-old {
    padding-bottom: 8px;
    text-align: center;
    width: 100%;
    flex-shrink: 0; /* Предотвращаем сжатие блока старой цены */
}

/* Стили для названия товара */
.custom-product-card .product-name {
    display: block;
    text-transform: none;
    color: #000;
    overflow: hidden;
    font-weight: 800;
    text-align: left;
    margin: 10px 0;
    font-size: 1.5rem;
    line-height: 1.4;
    height: auto;
    padding-bottom: 0;
    flex-shrink: 0; /* Предотвращаем сжатие названия */
}

.custom-product-card .product-name:hover,
.custom-product-card .product-name:focus {
    text-decoration: none;
    color: #4786c1;
}

/* Стили для описания товара */
.custom-product-card .product-content {
    margin: 5px 0;
    font-size: 14px;
    line-height: 1.4;
    color: #6c757d;
    flex: 0 1 auto; /* Позволим элементу расти и сжиматься */
    min-height: auto; /* Ограничиваем максимальную высоту */
    display: block;
}

/* Стили для контейнера кнопки */
.custom-product-card .button-card-sale {
    width: 100%;
    display: block;
    flex-shrink: 0;
    position: relative;
    flex: 0 0 auto; /* Зафиксируем высоту контейнера кнопки */
    margin-top: auto;
}

/* Стили для ссылки-обертки кнопки */
.custom-product-card .button-card-sale a {
    width: 100%;
    display: block;
    text-decoration: none;
}

/* Стили для кнопки */
.custom-product-card .add-cart87 {
    flex: 1;
    min-width: 0;
    padding: 1rem 1.1rem;
    font-size: 1rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: none;
    border-radius: 8px;
    background-color: #233D63;
    color: #fff;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    width: 100%;
    cursor: pointer;
    margin: 0;
    max-width: 100%;
}

.custom-product-card .add-cart87:hover {
    background-color: #1a2d4a;
    transform: translateY(-1px);
}

.custom-product-card .add-cart87 svg {
    width: 1.8em;
    height: 1.8em;
    flex-shrink: 0;
}

.custom-product-card .add-cart87:hover svg {
    transform: scale(1.1);
}

/* Стили для тултипа кнопки */
.custom-product-card .add-cart-tooltip {
    font-size: 13px;
    color: #2d3436;
    padding: 3px 10px;
    border-radius: 5px;
    position: absolute;
    left: -50px;
    top: -40px;
    white-space: nowrap;
    z-index: 1;
    background: #fff;
    box-shadow: 0 6px 13px 0 rgba(165, 163, 163, 0.57);
    display: none;
}

.custom-product-card .add-cart-tooltip.visible {
    display: block;
}

/* Стили для сайдбара */
.custom-sidebar .sidebar-menu {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    padding: 1.5rem;
    width: 100%;
}

.custom-sidebar .sidebar-menu__title {
    font-size: 1.2rem;
    color: #233D63;
    font-weight: 600;
    margin-bottom: 1.2rem;
    padding-bottom: 0.8rem;
    border-bottom: 2px solid #f0f2f5;
}

.custom-sidebar .sidebar-menu__list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.custom-sidebar .sidebar-menu__item {
    margin-bottom: 0.4rem;
}

.custom-sidebar .sidebar-menu__link {
    display: block;
    padding: 0.9rem 1.2rem;
    color: #4a5568;
    text-decoration: none;
    border-radius: 8px;
    font-size: 1.3rem;
    transition: all 0.25s ease;
    position: relative;
    background: #f8fafc;
    border: 1px solid transparent;
}

.custom-sidebar .sidebar-menu__link:hover {
    background: #edf2f7;
    color: #233D63;
    transform: translateX(5px);
    border-color: #e2e8f0;
}

.custom-sidebar .sidebar-menu__link.active {
    background: #233D63;
    color: #fff;
    font-weight: 500;
    border-color: #233D63;
    box-shadow: 0 2px 4px rgba(35, 61, 99, 0.1);
}

.custom-sidebar .sidebar-menu__link.active:hover {
    background: #1a2d4a;
    transform: none;
}

.custom-sidebar .sidebar-menu__link.active::before {
    content: '';
    position: absolute;
    left: -1.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 70%;
    background: #233D63;
    border-radius: 0 2px 2px 0;
}

/* Стили для тегов */
.product_tag {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem;
    margin: 1.5rem 0;
    font-size: 1.3rem;
    color: #000000;
}

.product_tag::before {
    content: "Фильтры:";
    margin-right: 0.5rem;
    font-weight: 500;
}

.blog_tag_item {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 1rem;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    color: #000000;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
}

.blog_tag_item:hover {
    background-color: #e9ecef;
    color: #233D63;
}

.blog_tag_item.active {
    background-color: #233D63;
    color: #ffffff;
    border-color: #233D63;
}

/* Кнопка для раскрытия/скрытия меню на мобильных */
.mobile-sidebar-toggle {
    display: none;
    width: 100%;
    padding: 1rem;
    background: #233D63;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
    margin-bottom: 1rem;
    text-align: center;
    z-index: 999;
    position: relative;
}

@media (max-width: 991px) {
    .mobile-sidebar-toggle {
        display: block;
    }
}

/* Стили для кнопки закрытия сайдбара */
.sidebar-close-btn {
    position: absolute;
    top: 1.5rem;
    right: 3rem;
    background: #ffffff;
    color: #233D63;
    border: 2px solid #233D63;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 1001;
    display: none;
}

@media (max-width: 991px) {
    .sidebar-close-btn {
        display: block;
    }
}

@media (max-width: 480px) {
    .custom-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }

    .blog_tag_item {
        font-size: 0.75rem;
        padding: 0.3rem 0.7rem;
    }

    .custom-products-grid {
        padding: 1rem 0;
    }
}