:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --background: #f8fafc;
    --text: #1e293b;
    --card-bg: #ffffff;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --radius: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui;
    text-decoration: none;
}

body {
    background: var(--background);
    min-height: 100vh;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    font-size: 14px;
}

img {
    -webkit-user-drag: none;
    -moz-user-select: none;
    -webkit-user-select: none;
    user-select: none;
    pointer-events: none;
}

/* Header Styles */
.header {
    background: var(--card-bg);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.5rem;
}

.header-container {
    width: 100%;
    margin: 0 auto;
}

/* Top Row */
.header-top {
    display: grid;
    grid-template-columns: 40px 1fr 40px;
    align-items: center;
    justify-items: center;
    padding: 0.5rem 0;
}

.logo-link {
    grid-column: 2;
    justify-self: center;
}


.menu-toggle {
    background: none;
    border: none;
    padding: 0.5rem;
    color: var(--text);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
}

.header-actions {
    justify-self: end;
}

.site-logo {
    height: 36px;
    width: auto;
    transition: transform 0.3s;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.cart-btn,
.auth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    position: relative;
    transition: all 0.3s;
}

.cart-counter {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Bottom Row */
.header-bottom {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-bottom: 0.5rem;
}

.search-form {
    position: relative;
    width: 100%;
}

.search-form input {
    width: 100%;
    padding: 0.65rem 1rem 0.65rem 2.5rem;
    border: none;
    border-radius: 50px;
    background: var(--background);
    font-size: 0.9rem;
}

.search-form button {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #94a3b8;
}

.categories-nav {
    position: relative;
}

.categories-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    cursor: pointer;
    position: relative;
}

.categories-toggle svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    margin-right: 0.5rem;
}

.categories-toggle span {
    margin-left: 24px;
    /* Отступ для иконки */
}

.categories-menu {
    display: none;
    flex-direction: column;
    gap: 0.25rem;
    background: var(--card-bg);
    border-radius: var(--radius);
    margin-top: 0.5rem;
    padding: 0.5rem;
}

.categories-menu.show {
    display: flex;
}

.categories-menu a {
    padding: 0.75rem 1rem;
    color: var(--text);
    text-decoration: none;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 6px;
}

.categories-menu a:hover,
.categories-menu a.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.category-item {
    position: relative;
}

.subcategories-menu {
    display: none;
    width: 100%;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 6px;
    margin-top: 0.25rem;
    padding-left: 15px;
}

.category-item.active .subcategories-menu {
    display: block;
}

.subcategories-menu a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 2px solid var(--primary);
    margin: 0.25rem 0;
}

.dropdown-icon {
    margin-left: 6px;
    transition: transform 0.3s;
}

.category-item.active .dropdown-icon {
    transform: rotate(180deg);
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    padding: 1rem;
    width: 100%;
    margin: 0 auto;
}

.product-card {
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s;
}

.product-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-bottom: 1px solid var(--background);
}

.product-info {
    padding: 1rem;
}

.product-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.product-description {
    color: #64748b;
    font-size: 0.8rem;
    line-height: 1.4;
    margin-bottom: 0.75rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-badges {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.product-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
}

.category-badge {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.subcategory-badge {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.add-to-cart {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 0.75rem;
    width: 100%;
    justify-content: center;
    font-size: 0.85rem;
}

.add-to-cart svg {
    width: 16px;
    height: 16px;
}

/* Notifications */
.logout-notification {
    position: fixed;
    top: 10px;
    right: 10px;
    background: #4CAF50;
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    font-size: 0.9rem;
    max-width: 90%;
}

.close-notification {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    margin-left: 0.5rem;
}

.search-results-info {
    padding: 0.75rem 1rem;
    background: var(--background);
    text-align: center;
    color: #64748b;
    font-size: 0.9rem;
}

.auth-required-message {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 1rem;
    text-align: center;
}

.auth-message-container {
    width: 50%;
    max-width: 100%;
    padding: 1.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.auth-message-container h2 {
    margin-bottom: 0.75rem;
    color: #1e293b;
    font-size: 1.2rem;
}

.auth-message-container p {
    margin-bottom: 1.5rem;
    color: #64748b;
    font-size: 0.9rem;
}

.auth-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.auth-button {
    padding: 0.75rem 1.25rem;
    background: var(--primary);
    color: white;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.3s;
}

/* Animations */
@keyframes slideIn {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Tablet Styles */
@media (min-width: 481px) {
    .header {
        padding: 0.75rem;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1.5rem;
        padding: 1.5rem;
    }

    .product-image {
        height: 180px;
    }
}

/* Desktop Styles */
@media (min-width: 769px) {
    .header {
        padding: 0 1rem;
    }

    .header-container {
        max-width: 1400px;
    }

    .header-top {
        padding: 1rem 0;
    }

    .header-bottom {
        flex-direction: row;
        align-items: center;
        gap: 1.5rem;
        padding-bottom: 1rem;
    }

    .search-form {
        max-width: 400px;
    }

    .categories-menu {
        display: flex;
        flex-direction: row;
        background: transparent;
        gap: 0.5rem;
        margin-top: 0;
        padding: 0;
    }

    .categories-menu a {
        padding: 0.5rem 1rem;
        border-radius: 20px;
    }

    .categories-toggle {
        display: none;
    }

    .menu-toggle {
        display: none;
    }

    .subcategories-menu {
        position: absolute;
        left: 0;
        top: 100%;
        width: 220px;
        max-height: 60vh;
        background: white;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        border-radius: 8px;
        z-index: 1000;
        padding: 8px 0;
        overflow-y: auto;
        margin-top: 0;
        padding-left: 0;
    }

    .subcategories-menu a {
        padding: 8px 15px !important;
        margin: 0 !important;
        border-left: none !important;
    }

    .category-item:hover .subcategories-menu {
        display: block;
        animation: fadeIn 0.3s ease;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 2rem;
        padding: 2rem;
    }

    .product-image {
        height: 220px;
    }

    /* Кнопки с текстом на десктопе */
    .cart-btn {
        width: auto;
        padding: 0.7rem 1.2rem;
        border-radius: 30px;
        gap: 0.5rem;
    }

    .cart-btn::after {
        content: "Корзина";
        font-size: 0.95rem;
    }

    .auth-btn {
        width: auto;
        padding: 0.7rem 1.2rem;
        border-radius: 30px;
        gap: 0.5rem;
    }

    .auth-btn[href="login.php"]::after {
        content: "Вход";
        font-size: 0.95rem;
    }

    .auth-btn[href="logout.php"]::after {
        content: "Выход";
        font-size: 0.95rem;
    }
}

/* В мобильной версии */
@media (max-width: 768px) {
    .subcategories-menu {
        max-height: 200px;
        /* Ограничиваем высоту */
        overflow-y: auto;
        /* Включаем вертикальную прокрутку */
        -webkit-overflow-scrolling: touch;
        /* Для плавного скролла на iOS */
        overscroll-behavior: contain;
        /* Чтобы не скроллилась вся страница */
        padding-right: 5px;
        /* Чтобы скроллбар не наезжал на контент */
    }

    /* Стилизация скроллбара для WebKit */
    .subcategories-menu::-webkit-scrollbar {
        width: 3px;
    }

    .subcategories-menu::-webkit-scrollbar-thumb {
        background-color: rgba(99, 102, 241, 0.5);
        border-radius: 3px;
    }

    .subcategories-menu {
        position: relative;
    }

    .subcategories-menu::before,
    .subcategories-menu::after {
        content: '';
        position: sticky;
        left: 0;
        right: 0;
        height: 15px;
        pointer-events: none;
        z-index: 1;
    }

    .subcategories-menu::before {
        top: 0;
        background: linear-gradient(to bottom, white, transparent);
    }

    .subcategories-menu::after {
        bottom: 0;
        background: linear-gradient(to top, white, transparent);
    }
}



/* NEW */

/* ================== */
/* Анимация корзины */
/* ================== */

.add-to-cart {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.add-to-cart svg {
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    transform-origin: center;
    will-change: transform; /* Оптимизация анимации */
}

/* Состояние при нажатии */
.add-to-cart:active {
    transform: scale(0.95);
}

/* Анимация успешного добавления */
.add-to-cart.success {
    background-color: #10b981 !important;
}

/* Задержка для текста "Добавлено" */
.add-to-cart::after {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.2s;
}

/* Для мобильных устройств */
@media (max-width: 768px) {
    .add-to-cart svg {
        transition-duration: 0.2s;
    }
}


/* Сообщение "Товаров не найдено" */
.no-products-found {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 1rem;
    color: #64748b;
}

.no-products-found svg {
    margin-bottom: 1rem;
}

.no-products-found h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: #334155;
}

.no-products-found p {
    margin-bottom: 1.5rem;
    max-width: 400px;
}

.reset-filters {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: white;
    border-radius: 6px;
    transition: all 0.3s;
}

.reset-filters:hover {
    background: var(--primary-hover);
}


/* Стили для кнопки "Мои заказы" */
.orders-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    position: relative;
    transition: all 0.3s;
}

.orders-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* Для десктопной версии */
@media (min-width: 769px) {
    .orders-btn {
        width: auto;
        padding: 0.7rem 1.2rem;
        border-radius: 30px;
        gap: 0.5rem;
        margin: 0;
    }
    
    .orders-btn::after {
        content: "Заказы";
        font-size: 0.95rem;
        margin-left: 0.5rem;
    }
}

/* Обновляем контейнер header-actions */
.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}