/* --- Сайдбар (Фильтры) - Оставляем как было --- */
.catalog-container {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.filters-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: rgba(30, 25, 50, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(108, 92, 231, 0.2);
    border-radius: 12px;
    padding: 25px; /* Чуть больше отступ */
    position: sticky;
    top: 20px;
}

.filters-sidebar h3 {
    margin-bottom: 20px;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

.filter-group {
    margin-bottom: 20px;
}

.filter-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.95em;
    color: #bdc3c7;
}

.filters-sidebar select,
.filters-sidebar input[type="number"], 
.filters-sidebar input[type="text"] {
    width: 100%;
    padding: 12px;
    background: rgba(15, 12, 41, 0.6); /* Чуть темнее фон полей */
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    outline: none;
    transition: 0.3s;
}

.filters-sidebar select:focus,
.filters-sidebar input:focus {
    border-color: #6c5ce7;
    box-shadow: 0 0 8px rgba(108, 92, 231, 0.4);
}

.apply-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(45deg, #6c5ce7, #a29bfe);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 10px;
}

.apply-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}

.reset-btn {
    display: block;
    text-align: center;
    margin-top: 15px;
    font-size: 0.9em;
    color: #a4b0be;
    text-decoration: none;
    transition: color 0.3s;
}

.reset-btn:hover {
    color: #ff7675;
}

/* --- СЕТКА ТОВАРОВ И КАРТОЧКИ --- */
.catalog-content {
    flex-grow: 1;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); /* Чуть шире карточки */
    gap: 30px;
}

/* Ссылка-обертка карточки */
.product-link {
    text-decoration: none !important; /* Убираем подчеркивание */
    color: inherit; /* Убираем синий цвет ссылок */
    display: block;
    height: 100%;
}

.product-card {
    background: rgba(45, 40, 65, 0.7);
    border: 1px solid rgba(108, 92, 231, 0.1);
    border-radius: 16px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s;
    display: flex;
    flex-direction: column;
    height: 100%;
    backdrop-filter: blur(5px);
    
    /* ДОБАВЛЕНО: удерживает абсолютные элементы (например крестик) внутри карточки */
    position: relative; 
}

.product-card:hover {
    transform: translateY(-7px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    border-color: rgba(108, 92, 231, 0.6);
}

.product-image {
    height: 220px; /* Картинка чуть выше */
    background: #1e1b2e;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.product-image img {
    height: 100%;
    width: 100%;
    object-fit: cover; /* Чтобы фото заполняло область красиво */
    transition: transform 0.5s ease;
}

.product-card:hover .product-image img {
    transform: scale(1.05); /* Легкое увеличение при наведении */
}

/* Контейнер для текста внутри карточки */
.product-info {
    padding: 20px; /* Увеличили отступы от краев */
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.product-title {
    font-size: 1.25em;
    font-weight: 600;
    margin-bottom: 8px;
    color: #ffffff !important; /* Принудительно белый цвет */
    line-height: 1.4;
}

.product-meta {
    font-size: 0.9em;
    color: #bdc3c7; /* Светло-серый для категории */
    margin-bottom: 15px;
}

.product-footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    
    /* ВОТ ЭТО ИСПРАВИТ ПРИЛИПАНИЕ К КРАЯМ: */
    padding: 15px 20px; 
}

.price {
    font-size: 1.4em;
    font-weight: bold;
    color: #6c5ce7; /* Фиолетовый акцент для цены */
    text-shadow: 0 0 10px rgba(108, 92, 231, 0.2);
}

/* --- Поиск сверху --- */
.search-bar-container {
    margin-bottom: 30px;
}

/* Адаптивность */
@media (max-width: 900px) {
    .catalog-container {
        flex-direction: column;
    }
    .filters-sidebar {
        width: 100%;
        position: relative;
        top: 0;
    }
}

/* --- СТИЛИ ДЛЯ ПОИСКА (ОБНОВЛЕННЫЕ) --- */
.search-bar-container {
    margin-bottom: 30px;
}

.search-form {
    display: flex;
    gap: 15px; /* Расстояние между полем и кнопкой */
    align-items: center;
}

.search-input-main {
    flex-grow: 1; /* Растягивает поле на всю доступную ширину */
    padding: 15px 25px;
    border-radius: 30px;
    border: 1px solid rgba(108, 92, 231, 0.5); /* Фиолетовая рамка */
    background: rgba(15, 12, 41, 0.8);
    color: white;
    font-size: 1.1em;
    outline: none;
    transition: box-shadow 0.3s, border-color 0.3s;
}

.search-input-main:focus {
    border-color: #6c5ce7;
    box-shadow: 0 0 15px rgba(108, 92, 231, 0.4);
    background: rgba(15, 12, 41, 0.95);
}

.search-btn-main {
    padding: 15px 40px;
    border-radius: 30px;
    border: none;
    background: #6c5ce7;
    color: white;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, background 0.3s;
    white-space: nowrap; /* Чтобы текст не переносился */
}

.search-btn-main:hover {
    background: #5d4fd3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(108, 92, 231, 0.4);
}

/* На мобильных переносим кнопку под поиск */
@media (max-width: 600px) {
    .search-form {
        flex-direction: column;
    }
    .search-input-main, .search-btn-main {
        width: 100%;
    }
}

/* Кнопка "В корзину" в карточке */
.add-btn-icon {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    border: none;
    border-radius: 50%; /* Круглая кнопка */
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 4px 10px rgba(108, 92, 231, 0.4);
}

.add-btn-icon svg {
    width: 20px;
    height: 20px;
    fill: white;
    transition: transform 0.3s;
}

.add-btn-icon:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 6px 15px rgba(108, 92, 231, 0.6);
}

.add-btn-icon:hover svg {
    transform: scale(1.1);
}

.add-btn-icon:active {
    transform: scale(0.95);
}

/* --- Кнопка избранного в каталоге --- */
.fav-btn {
    position: static !important; /* Убирает "улетание" вправо */
    margin-right: 10px; /* Отступ от кнопки корзины */
    background: rgba(15, 12, 41, 0.6);
    border: 1px solid rgba(108, 92, 231, 0.3);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
    font-size: 1.2em;
}

.fav-btn.active {
    color: #ff4757;
    background: #fff;
    border-color: #ff4757;
    box-shadow: 0 0 10px rgba(255, 71, 87, 0.4);
}

.fav-btn:hover {
    transform: scale(1.1);
    border-color: #6c5ce7;
}


/* --- СТИЛИ ДЛЯ ИЗБРАННОГО (favorites.php) --- */
/* --- СТИЛИ ДЛЯ КРЕСТИКА В ИЗБРАННОМ --- */
.remove-fav {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #ff4757; /* Яркий сплошной красный фон */
    color: #ffffff; /* Белый крестик */
    border: 2px solid #ffffff; /* Белая обводка для контраста на темном */
    border-radius: 50%;
    width: 38px;
    height: 38px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6); /* Мощная тень, отрывает кнопку от картинки */
    opacity: 0.95; /* Легкая прозрачность для стиля */
    font-size: 1.1em;
}

.remove-fav:hover { 
    background: #ff6b6b; /* Чуть светлее при наведении */
    color: white; 
    transform: scale(1.15); /* Увеличиваем сильнее */
    opacity: 1;
    box-shadow: 0 6px 16px rgba(255, 71, 87, 0.6); /* Красная тень при наведении */
}

.empty-state-link {
    color: #a29bfe;
    text-decoration: none;
    font-weight: 600;
    display: inline-block;
    margin-top: 15px;
    transition: 0.3s;
}

.empty-state-link:hover {
    color: #6c5ce7;
    text-decoration: underline;
}






/* --- Стили Пагинации --- */
.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 40px;
    flex-wrap: wrap;
}
.page-link {
    padding: 10px 16px;
    background: rgba(30, 25, 50, 0.8);
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    border: 1px solid rgba(108, 92, 231, 0.3);
    transition: 0.3s;
    font-weight: bold;
}
.page-link:hover, .page-link.active {
    background: #6c5ce7;
    border-color: #a29bfe;
    box-shadow: 0 0 10px rgba(108, 92, 231, 0.5);
}

/* --- АДАПТИВ КАТАЛОГА (2 товара в ряд на мобилках) --- */
@media (max-width: 900px) {
    .filters-sidebar {
        width: 100%;
        margin-bottom: 20px;
        position: static;
    }
}

@media (max-width: 768px) {
    .product-grid {
        /* Принудительно 2 колонки */
        grid-template-columns: repeat(2, 1fr);
        gap: 15px; 
    }
    
    .product-image {
        height: 160px; /* Уменьшаем фото для экономии места */
    }
    
    .product-info {
        padding: 12px;
    }
    
    .product-title {
        font-size: 1em; /* Уменьшаем шрифт заголовка */
        line-height: 1.3;
        margin-bottom: 5px;
    }
    
    .product-meta {
        font-size: 0.75em;
        margin-bottom: 8px;
    }
    
    .product-footer {
        flex-direction: column; /* Цена сверху, кнопки снизу */
        align-items: flex-start;
        padding: 12px;
        gap: 10px;
    }
    
    .price {
        font-size: 1.2em;
    }

    /* Растягиваем контейнер с кнопками вправо */
    .product-footer > div:last-child {
        width: 100%;
        justify-content: flex-end;
    }

    /* Уменьшаем кнопки, чтобы влезли в узкую карточку */
    .add-btn-icon {
        width: 38px;
        height: 38px;
    }
    
    .add-btn-icon svg {
        width: 16px;
        height: 16px;
    }
    
    .fav-btn {
        width: 38px;
        height: 38px;
        font-size: 1em;
    }
}

/* Для совсем узких экранов (старые смартфоны) */
@media (max-width: 400px) {
    .product-grid {
        gap: 10px;
    }
    .product-image {
        height: 130px;
    }
    .product-title {
        font-size: 0.9em;
    }
    .price {
        font-size: 1.1em;
    }
    .product-footer {
        padding: 10px;
    }
    .add-btn-icon, .fav-btn {
        width: 32px;
        height: 32px;
    }
}

