/* ===============================================
   MODERN PRODUCT GRID SYSTEM
   =============================================== */

/* Контейнер сетки товаров */
.products-grid-container {
    max-width: 100%;
}

/* Flexbox сетка для лучшей совместимости */
.products-grid {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -0.5rem;
}

/* Стили для элементов товаров в flexbox сетке */
.products-grid .product-item {
    flex: 0 0 100%;
    max-width: 100%;
    padding: 0 0.5rem;
    margin-bottom: 1rem;
}

/* Адаптивные размеры для разных экранов */
@media (min-width: 576px) {
    .products-grid .product-item {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

@media (min-width: 768px) {
    .products-grid .product-item {
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
    }
}

@media (min-width: 992px) {
    .products-grid .product-item {
        flex: 0 0 25%;
        max-width: 25%;
    }
}

@media (min-width: 1200px) {
    .products-grid .product-item {
        flex: 0 0 25%;
        max-width: 25%;
    }
}


/* ===============================================
   PRODUCT CARD STYLING
   =============================================== */

.product-card {
    position: relative;
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    transition: all 0.3s ease;
    background: #fff;
    overflow: visible !important;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15) !important;
    border-color: #d0d0d0 !important;
    z-index: 10;
}

/* Атрибуты появляются поверх других карточек */
.product-card:hover .product-attributes {
    display: block !important;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Контейнер изображения */
.product-img-container {
    position: relative;
    overflow: hidden;
}

.product-img {
    object-fit: contain;
    padding: 20px;
    transition: transform 0.2s ease;
    border-radius: 8px;
}

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

/* Бейджи товаров */
.product-badge {
    position: static; /* Убираем абсолютное позиционирование */
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Контейнер для бейджей */
.badges-container {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    flex-direction: row;
    gap: 5px;
    z-index: 5;
    flex-wrap: wrap;
    max-width: calc(100% - 20px);
}

/* Убираем старые nth-child правила */
/* .product-badge:nth-child(2) {
    left: calc(8px + 55px);
}

.product-badge:nth-child(3) {
    left: calc(8px + 110px);
} */

.badge-new {
    background: #28a745;
    color: white;
}

.badge-hot {
    background: #ff6b35;
    color: white;
}

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

/* Быстрые действия */
.quick-actions {
    position: absolute;
    top: 50%;

    opacity: 0;
    transition: all 0.2s ease;
}

.product-card:hover .quick-actions {
    opacity: 1;
}

.quick-actions .btn {
    background: rgba(255, 255, 255, 0.664) !important;
    border-radius: 8px;
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
}

.quick-actions .btn:hover {
    background: rgb(43 67 146) !important;
    color: #fff;
}

/* Контент карточки */
.card-body {
    padding: 16px;
}

/* Цена */
.current-price {
    color: #000;
    font-size: 1.4rem;
    font-weight: 700;
}

.old-price {
    font-size: 0.9rem;
    color: #999;
}

/* Название товара */
.product-title {
    font-size: 0.9rem;
    line-height: 1.3;
    margin-bottom: 8px;
    min-height: 2.2rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    color: #333;
}

.product-name-link:hover {
    color: #0052a3 !important;
}

/* Рейтинг и статус */
.product-rating-status {
    margin-bottom: 12px;
}

.product-rating-status .bi-star {
    font-size: 0.75rem;
    margin-right: 1px;
    color: #ddd;
}

.rating-count {
    font-size: 0.75rem;
    color: #666;
}

.stock-status {
    font-size: 0.75rem;
}

/* Кнопки действий */
.product-actions {
    margin-top: auto;
}

.add-to-cart-btn:hover {
    background: #3f5bb8 !important;
    border-color: #3f5bb8 !important;
}

.action-btn {
    font-size: 0.8rem;
    padding: 6px 8px;
    border-radius: 4px;
    border-color: #ddd;
    color: #666;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.action-btn:hover {
    background-color: #f8f9fa;
    border-color: #ccc;
    color: #333;
}

/* ===============================================
   VIEW CONTROLS
   =============================================== */

.view-controls .view-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.view-controls .view-btn.active {
    background-color: #2b4392;
    border-color: #2b4392;
    color: white;
}

/* Показ/скрытие элементов в зависимости от режима */
.products-grid[data-view="grid"] .d-list-only {
    display: none !important;
}

/* Направление flex для card-body в зависимости от режима */
.products-grid[data-view="grid"] .card-body {
    flex-direction: column !important;
}

/* ===============================================
   EMPTY STATE
   =============================================== */

.empty-state i {
    opacity: 0.5;
}

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

@media (max-width: 575.98px) {

    .card-body {
        padding: 12px !important;
    }

    .current-price {
        font-size: 1.2rem !important;
    }

    .product-title {
        min-height: 1.8rem !important;
    }

    .quick-actions {
        display: none !important;
    }


    .quick-actions .btn {
        font-size: 0.9rem !important;
        padding: 4px 8px !important;
    }

    .action-btn {
        width: 28px !important;
        height: 28px !important;
        font-size: 0.7rem !important;
    }
}



/* Accessibility и производительность */
@media (prefers-reduced-motion: reduce) {

    .product-card,
    .quick-view-overlay {
        transition: none !important;
    }

    .product-card:hover {
        transform: none !important;
    }
}

/* ===============================================
   PRODUCT ATTRIBUTES STYLING
   =============================================== */

.attribute-group {
    margin-bottom: 12px;
}

.attribute-label {
    font-size: 0.85rem;
    color: #a3a3a3;
    margin-bottom: 6px;
    font-weight: 500;
}

.attribute-options {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.product-attributes {
    position: absolute;
    left: 0;
    right: 0;
    top: 98%;
    z-index: 100;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0 0 8px 8px;
    padding: 15px;
    margin-top: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
    display: block;
}

.product-card:hover .product-attributes {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 768px) {
    .product-attributes {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        margin-top: 10px;
        opacity: 1;
        pointer-events: auto;
    }
}