/* === categories.css — популярні підкаталоги в стилі shop.php === */

.popular-categories {
    margin: 60px 0;
}

.popular-categories .wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* === Фон як в shop.php === */
.category-flex {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 40px 0;
    margin: 0;
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
}

.category-flex-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 25px;
}

/* === Картки категорій в стилі shop.php === */
.category-item {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    padding: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    border: 1px solid #f0f0f0;
}

.category-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #f26522, #ff7e3d);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.category-item:hover::before {
    transform: scaleX(1);
}

.category-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 35px rgba(0,0,0,0.15);
    border-color: #f26522;
}

.category-item img {
    width: 100%;
    height: 280px;
    object-fit: contain;
    border-radius: 8px;
    margin-bottom: 15px;
    background: #f8f9fa;
    transition: transform 0.3s ease;
}

.category-item:hover img {
    transform: scale(1.05);
}

.category-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    line-height: 1.4;
    color: #333;
    text-align: center;
    flex-grow: 1;
}

.category-title a {
    color: inherit;
    text-decoration: none;
}

.category-title a:hover {
    color: #f26522;
}

/* === Порожні слоти === */
.empty-slot {
    /* Порожні слоти займають місце в grid, але залишаються невидимими */
}

/* === Адаптивність === */
@media (max-width: 992px) {
    .category-flex-inner {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
        padding: 0 15px;
    }
    
    .category-item img {
        height: 240px;
    }
}

@media (max-width: 768px) {
    .popular-categories .wrapper {
        padding: 0 15px;
    }
    
    .category-flex-inner {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
        padding: 0 10px;
        /* Для мобільних: показуємо тільки заповнені елементи */
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .category-item {
        padding: 15px;
        width: calc(50% - 7.5px); /* 50% мінус половина gap */
        flex: 0 0 calc(50% - 7.5px);
    }
    
    .empty-slot {
        display: none; /* Ховаємо порожні слоти на мобільних */
    }
    
    .category-item img {
        height: 180px;
        margin-bottom: 12px;
    }
    
    .category-title {
        font-size: 14px;
        margin-bottom: 12px;
    }
}

@media (max-width: 480px) {
    .category-flex-inner {
        padding: 0 10px;
        gap: 10px;
        /* Для маленьких мобільних також використовуємо flex */
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .category-item {
        padding: 12px;
        width: calc(50% - 5px); /* 50% мінус половина gap */
        flex: 0 0 calc(50% - 5px);
    }
    
    .empty-slot {
        display: none; /* Ховаємо порожні слоти */
    }
    
    .category-item img {
        height: 160px;
    }
    
    .category-title {
        font-size: 13px;
        line-height: 1.3;
    }
}