/* favorites.css - оптимизирован для мобильных устройств */

:root {
    --primary: #6c5ce7;
    --primary-dark: #6c5ce7;
    --secondary: #ef4444;
    --gray-light: #f8fafc;
    --gray: #e2e8f0;
    --gray-dark: #64748b;
    --text: #334155;
    --text-dark: #1e293b;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 6px 12px rgba(0, 0, 0, 0.12);
    --radius: 12px;
    --radius-sm: 14px;
    --transition: all 0.2s ease;
}

/* Сброс и базовые стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text);
    background-color: #f5f7fa;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ===== HEADER МОБИЛЬНЫЙ ===== */
.modern-header {
    background: white;
    border-bottom: 1px solid var(--gray);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    min-height: 56px;
}

/* Кнопка назад */
.back-btn {
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0;
    white-space: nowrap;
}

.back-btn:hover {
    color: var(--primary);
}

/* Логотип */
.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    font-weight: 700;
    font-size: 20px;
    color: var(--text-dark);
    gap: 8px;
}

.logo__icon {
    color: var(--primary);
    font-size: 22px;
}

.logo__text span {
    color: var(--primary);
}

/* Навигация */
.nav {
    display: none; /* Скрываем навигацию на мобильных */
}

/* Иконки действий */
.header__actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.fav-btn, .cart-btn {
    position: relative;
    background: transparent;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text);
    text-decoration: none;
    padding: 0;
}

.fav-btn:hover, .cart-btn:hover {
    background: var(--gray-light);
}

.fav-count, .cart-count {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.fav-count {
    background: var(--secondary);
}

/* ===== MAIN CONTENT ===== */
.favorites-main {
    padding: 20px 0 40px;
    min-height: calc(100vh - 200px);
}

/* Панель управления */
.favorites-bar {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.favorites-title {
    font-size: 22px;
    color: var(--text-dark);
    font-weight: 700;
    margin-bottom: 16px;
    text-align: center;
}

.favorites-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fav-total {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    color: var(--primary);
    background: var(--gray-light);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
}

.fav-total i {
    color: var(--danger);
}

/* Контролы */
.control {
    position: relative;
    width: 100%;
}

.control select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--gray);
    border-radius: var(--radius-sm);
    background: white;
    font-family: inherit;
    font-size: 15px;
    color: var(--text);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
}

.control::after {
    content: "▼";
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-dark);
    font-size: 12px;
    pointer-events: none;
}

/* Кнопка очистки */
.btn {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    border: none;
    font-family: inherit;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn--ghost {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    width: 100%;
}

.btn--ghost:hover {
    background: var(--danger);
    color: white;
}

.btn--load-more {
    background: var(--primary);
    color: white;
    border: none;
    text-decoration: none;
    display: inline-flex;
    padding: 14px 28px;
    font-size: 16px;
}

.btn--load-more:hover {
    background: var(--primary-dark);
}

/* ===== СЕТКА ТОВАРОВ - 2 В РЯДУ НА МОБИЛЬНЫХ ===== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* Всегда 2 колонки на мобильных */
    gap: 12px;
    margin-bottom: 30px;
}

@media (min-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 20px;
    }
}

/* Карточка товара */
.product-card {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

.product-card:hover {
    box-shadow: var(--shadow-lg);
}

.product-card.removing {
    animation: fadeOut 0.3s ease forwards !important;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(-20px);
    }
}

/* Бейдж скидки */
.product-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 6px;
    border-radius: 4px;
    z-index: 2;
    line-height: 1;
}

.product-badge.discount {
    background: var(--secondary);
}

/* Изображение */
.product-card img {
    width: 100%;
    height: 160px;
    object-fit: contain;
    background: linear-gradient(180deg, #f8fafc, #eef2f7);
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
}
@media (min-width: 768px) {
    .product-card img {
        height: 200px;
        padding: 14px;
    }
}
.product-card img {
    width: 100%;
    height: 160px;
    object-fit: contain;
    background: #f1f5f9;   /* чуть темнее */
    padding: 10px;         /* ВАЖНО */
}



.product-link {
    text-decoration: none;
    color: inherit;
    display: block;
    overflow: hidden;
}

.product-link:hover h3 {
    color: var(--primary);
}

/* Основной контент карточки */
.product-main {
    padding: 12px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-card h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 40px;
}

.product-price {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.old-price {
    font-size: 13px;
    color: var(--gray-dark);
    text-decoration: line-through;
}

.product-price span:not(.old-price) {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.discount-price {
    color: var(--danger) !important;
}

/* Кнопки действий */
.favorite-actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.favorite-actions button {
    width: 100%;
    padding: 10px;
    border-radius: var(--radius-sm);
    border: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
}

.add-to-cart {
    background: var(--primary);
    color: white;
}

.add-to-cart:hover {
    background: var(--primary-dark);
}

.add-to-cart.clicked {
    background: var(--secondary);
    transform: scale(0.98);
}

.remove-btn {
    background: white;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.remove-btn:hover {
    background: var(--danger);
    color: white;
}

/* ===== СКЕЛЕТОНЫ ===== */
.skel-card {
    background: white;
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
    animation: pulse 1.5s ease-in-out infinite;
    height: 320px;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.skel-img {
    background: var(--gray);
    height: 160px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

.skel-line {
    background: var(--gray);
    height: 12px;
    border-radius: 6px;
    margin-bottom: 8px;
}

/* ===== ПУСТОЙ СОСТОЯНИЕ ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-top: 20px;
}

.empty-state i {
    font-size: 48px;
    color: var(--gray);
    margin-bottom: 20px;
    display: block;
}

.empty-state p {
    font-size: 16px;
    color: var(--text);
    margin-bottom: 24px;
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: var(--primary);
    color: white;
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s;
    font-weight: 600;
    text-align: center;
    font-size: 15px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ===== FOOTER ===== */
.footer {
    background: var(--text-dark);
    color: white;
    padding: 40px 0 20px;
    margin-top: auto;
}

.footer__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

@media (min-width: 768px) {
    .footer__grid {
        grid-template-columns: 1fr 1fr;
    }
}

.footer__logo {
    margin-bottom: 16px;
    color: white !important;
}

.footer__logo .logo__icon {
    color: var(--primary);
}

.footer__logo .logo__text span {
    color: var(--primary);
}

.footer__about {
    color: #cbd5e1;
    margin-bottom: 20px;
    line-height: 1.6;
    font-size: 15px;
}

.footer__social {
    display: flex;
    gap: 12px;
}

.footer__social a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: white;
    text-decoration: none;
    transition: var(--transition);
    font-size: 14px;
}

.footer__social a:hover {
    background: var(--primary);
}

.footer__title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    color: white;
}

.footer__contacts {
    color: #cbd5e1;
    font-style: normal;
    line-height: 1.8;
    font-size: 15px;
}

.footer__contacts i {
    color: var(--primary);
    margin-right: 10px;
    width: 16px;
}

.footer__contacts a {
    color: #cbd5e1;
    text-decoration: none;
    transition: var(--transition);
}

.footer__contacts a:hover {
    color: white;
    text-decoration: underline;
}

.footer__bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
    text-align: center;
    color: #94a3b8;
    font-size: 14px;
}

.legal-links {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.legal-links a {
    color: #94a3b8;
    text-decoration: none;
    transition: var(--transition);
    font-size: 13px;
}

.legal-links a:hover {
    color: white;
    text-decoration: underline;
}

/* ===== АДАПТИВ ДЛЯ ПЛАНШЕТОВ И ПК ===== */
@media (min-width: 768px) {
    .container {
        padding: 0 24px;
    }
    
    .header__inner {
        padding: 16px 0;
        min-height: 64px;
    }
    
    .logo {
        font-size: 22px;
    }
    
    .nav {
        display: block;
    }
    
    .nav__list {
        display: flex;
        list-style: none;
        gap: 24px;
    }
    
    .nav__link {
        text-decoration: none;
        color: var(--text);
        font-weight: 600;
        font-size: 15px;
        transition: var(--transition);
    }
    
    .nav__link:hover {
        color: var(--primary);
    }
    
    .fav-btn, .cart-btn {
        width: 44px;
        height: 44px;
    }
    
    .favorites-main {
        padding: 30px 0 60px;
    }
    
    .favorites-bar {
        padding: 20px;
        margin-bottom: 24px;
    }
    
    .favorites-title {
        font-size: 26px;
        margin-bottom: 0;
        text-align: left;
    }
    
    .favorites-controls {
        flex-direction: row;
        align-items: center;
        justify-content: flex-end;
        gap: 16px;
    }
    
    .fav-total {
        order: 2;
    }
    
    .control {
        order: 1;
        width: auto;
        min-width: 180px;
    }
    
    .btn--ghost {
        order: 3;
        width: auto;
    }
    
    .products-grid {
        gap: 20px;
    }
    
    .product-card img {
        height: 200px;
    }
    
    .product-card h3 {
        font-size: 15px;
        height: 42px;
    }
    
    .favorite-actions {
        flex-direction: row;
        gap: 8px;
    }
    
    .favorite-actions button {
        font-size: 14px;
        min-height: 44px;
    }
    
    .toast {
        left: auto;
        right: 24px;
        bottom: 24px;
        max-width: 300px;
        text-align: left;
    }
}

@media (min-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 24px;
    }
    
    .product-card img {
        height: 200px;
    }
}

/* Анимация появления карточек с задержкой */
.product-card {
    animation-delay: var(--fav-delay, 0s);
}

/* Улучшение производительности на мобильных */
@media (max-width: 767px) {
    * {
        -webkit-tap-highlight-color: transparent;
    }
    
    .product-card {
        transform: translateZ(0);
        backface-visibility: hidden;
    }
    
    .product-card:hover {
        transform: none;
    }
}
