/* Сетка товаров */
.custom-products-grid {
    display: grid;
    gap: 20px;
    margin-bottom: 30px;
    width: 100%;
    max-width: 100%;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    grid-auto-rows: 1fr;
}

/* Карточка товара */
.product-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 15px;
    border-radius: 24px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    width: 100%;
    box-sizing: border-box;
    height: 100%;
    min-width: 0; /* Предотвращает выход контента за пределы flex-контейнера */
}

/* Кнопка избранного */
.wishlist-button {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #fff;
    border: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: all 0.3s ease;
}

.wishlist-button svg {
    width: 20px;
    height: 20px;
    fill: #ccc;
    transition: fill 0.3s ease;
}

.wishlist-button:hover svg {
    fill: #ff4081;
}

.wishlist-button.active svg {
    fill: #ff4081;
}

/* Изображение товара */
.product-image {
    position: relative;
    width: 100%;
    padding-top: 100%;
    margin-bottom: 15px;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    flex-shrink: 0; /* Предотвращает сжатие изображения */
}

.product-image a {
    display: block;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

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

/* Информация о товаре */
.product-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0; /* Предотвращает выход контента за пределы flex-контейнера */
}

/* Верхняя часть информации */
.product-info-top {
    flex-shrink: 0;
    min-width: 0; /* Предотвращает выход контента за пределы flex-контейнера */
}

/* Метаданные товара (наличие) */
.product-meta {
    margin-bottom: 8px;
}

.stock {
    display: block;
    font-size: 14px;
    color: #998067;
}

.sku {
    color: #998067;
}

/* Название товара */
.product-title {
    margin: 0;
    font-size: 16px;
    line-height: 1.4;
    color: #333;
    font-weight: 400;
    /* Ограничиваем высоту названия */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-wrap: break-word; /* Добавляем перенос длинных слов */
    max-width: 100%; /* Ограничиваем максимальную ширину */
}

.product-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

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

/* Нижняя часть информации */
.product-info-bottom {
    margin-top: auto;
    flex-shrink: 0;
    min-width: 0; /* Предотвращает выход контента за пределы flex-контейнера */
}

/* Цены */
.product-price {
    font-size: 22px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    white-space: nowrap; /* Предотвращает перенос цены */
}

/* Блок действий */
.product-actions {
    display: flex;
    flex-direction: row;
    gap: 10px;
    min-width: 0; /* Предотвращает выход контента за пределы flex-контейнера */
}

/* Поле ввода количества */
.quantity-wrapper {
    width: 40%;
    height: 45px;
    border: 1px solid #FFD5BA;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    flex-shrink: 0; /* Предотвращает сжатие поля ввода */
}

.quantity {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 16px;
    color: #333;
    padding: 0 5px;
    -moz-appearance: textfield;
    box-sizing: border-box;
}

.quantity:focus {
    outline: none;
}

.quantity::-webkit-outer-spin-button,
.quantity::-webkit-inner-spin-button {
    opacity: 1;
    height: 45px;
    cursor: pointer;
}

/* Кнопка добавления в корзину */
.add-to-cart-button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    min-width: 45px;
    min-height: 45px;
}

.add-to-cart-button:hover {
    background-color: #45a049;
}

.add-to-cart-button svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
}

.add-to-cart-button.loading {
    opacity: 0.7;
    cursor: wait;
}

.add-to-cart-button.loading svg {
    animation: spin 1s infinite linear;
}

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

/* Адаптивность */
@media (max-width: 1200px) {
    .custom-products-grid {
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .custom-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
    
    .product-card {
        padding: 12px;
    }
    
    .product-title {
        font-size: 14px;
    }
    
    .product-price {
        font-size: 20px;
        margin-bottom: 10px;
    }
    
    .quantity-wrapper,
    .add-to-cart-button {
        height: 40px;
    }
    
    .add-to-cart-button {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .custom-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }

    .product-card {
        padding: 10px;
    }

    .product-title {
        font-size: 13px;
        line-height: 1.3;
    }
    
    .product-meta {
        font-size: 12px;
    }
    
    .product-price {
        font-size: 18px;
        margin-bottom: 8px;
    }
    
    .product-actions {
        gap: 6px;
    }
    
    .quantity {
        font-size: 14px;
    }
    
    .add-to-cart-button {
        min-width: 40px;
        min-height: 40px;
        padding: 8px;
    }

    .add-to-cart-button svg {
        width: 20px;
        height: 20px;
    }
} 