/* ==========================================================================
   CATALOG — Адаптивный CSS с анимациями
   Версия: 2.0 (Mobile-First)
   ========================================================================== */

/* === CSS VARIABLES === */
:root {
    --color-primary: #8b5cf6;
    --color-primary-light: #a78bfa;
    --color-success: #10b981;
    --color-success-dark: #059669;
    --color-danger: #ef4444;
    --color-danger-dark: #dc2626;
    --color-text: #1e293b;
    --color-text-dark: #1f2937;
    --color-text-secondary: #374151;
    --color-text-muted: #64748b;
    --color-text-light: #9ca3af;
    --color-bg: #f8fafc;
    --color-bg-light: #f1f5f9;
    --color-border: #e5e7eb;
    --color-white: #ffffff;
    --color-star: #fbbf24;

    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2rem;
    --space-xl: 3rem;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 8px 30px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.15);

    --transition: all 0.3s ease;
    --transition-slow: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --touch-min: 44px;
}

/* === RESET === */
* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body { 
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; 
    background: var(--color-bg); 
    color: var(--color-text);
    line-height: 1.6;
    overflow-x: hidden;
}

img { max-width: 100%; height: auto; display: block; }

/* === CONTAINER === */
.container { 
    width: 100%;
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 0 var(--space-sm); 
}

/* ==========================================================================
   ANIMATIONS (Keyframes)
   ========================================================================== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(239,68,68,0.7); }
    70% { box-shadow: 0 0 0 10px rgba(239,68,68,0); }
    100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}

@keyframes shimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

@keyframes countUp {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes rotateIn {
    from { opacity: 0; transform: rotate(-180deg) scale(0.5); }
    to { opacity: 1; transform: rotate(0) scale(1); }
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.header { 
    background: var(--color-white); 
    padding: var(--space-sm) 0; 
    box-shadow: var(--shadow-md); 
    position: sticky; 
    top: 0; 
    z-index: 100;
    animation: fadeInDown 0.5s ease;
}

.header__inner { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    gap: var(--space-sm);
    min-height: var(--touch-min);
}

.header__left { 
    display: flex; 
    align-items: center; 
    gap: var(--space-sm); 
    flex: 1;
    min-width: 0;
}

.logo img { 
    height: clamp(36px, 8vw, 50px); 
    transition: var(--transition);
}

.logo:hover img {
    transform: scale(1.05) rotate(-3deg);
}

.header__title { 
    color: var(--color-text-dark); 
    font-weight: 700; 
    font-size: clamp(0.9rem, 3vw, 1.5em);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    animation: slideInLeft 0.5s ease 0.1s both;
}

.header__title i {
    color: var(--color-primary);
    margin-right: var(--space-xs);
    animation: rotateIn 0.6s ease 0.3s both;
}

.header__right { 
    display: flex; 
    align-items: center; 
    gap: var(--space-xs); 
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn { 
    padding: var(--space-xs) var(--space-sm); 
    border-radius: var(--radius-md); 
    text-decoration: none; 
    font-weight: 600; 
    font-size: 0.85rem;
    display: inline-flex; 
    align-items: center; 
    justify-content: center;
    gap: var(--space-xs);
    transition: var(--transition); 
    cursor: pointer; 
    border: none;
    min-height: var(--touch-min);
    white-space: nowrap;
}

.btn span {
    display: none;
}

.btn-primary { 
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light)); 
    color: var(--color-white); 
}
.btn-primary:hover { 
    transform: translateY(-2px); 
    box-shadow: 0 10px 30px rgba(139,92,246,0.4); 
}

.btn-secondary { 
    background: var(--color-bg); 
    color: var(--color-text-secondary); 
    border: 2px solid var(--color-border);
}
.btn-secondary:hover { 
    background: var(--color-bg-light); 
    transform: translateY(-2px);
}

.btn-admin { 
    background: linear-gradient(135deg, var(--color-danger), var(--color-danger-dark)); 
    color: var(--color-white); 
    animation: pulse 2s infinite;
}
.btn-admin:hover { 
    box-shadow: 0 10px 30px rgba(239,68,68,0.4); 
    transform: translateY(-2px);
}

/* ==========================================================================
   HERO — Улучшенный с анимациями
   ========================================================================== */
.hero { 
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light)); 
    color: var(--color-white); 
    padding: var(--space-xl) 0; 
    text-align: center; 
    margin-bottom: var(--space-lg);
    position: relative;
    overflow: hidden;
    animation: fadeIn 0.6s ease;
}

/* Animated background circles */
.hero::before,
.hero::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    animation: float 6s ease-in-out infinite;
}

.hero::before {
    width: 200px;
    height: 200px;
    top: -50px;
    right: -50px;
    animation-delay: 0s;
}

.hero::after {
    width: 150px;
    height: 150px;
    bottom: -30px;
    left: -30px;
    animation-delay: -3s;
}

.hero .container {
    position: relative;
    z-index: 1;
}

.hero h1 { 
    font-size: clamp(1.8rem, 6vw, 2.8em); 
    margin-bottom: var(--space-sm);
    font-weight: 800;
    animation: fadeInUp 0.6s ease 0.2s both;
    text-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.hero p { 
    font-size: clamp(1rem, 3vw, 1.3em); 
    opacity: 0.95;
    animation: fadeInUp 0.6s ease 0.4s both;
}

/* Counter animation for product count */
.hero-counter {
    display: inline-block;
    font-size: 3em;
    font-weight: 800;
    margin: var(--space-sm) 0;
    animation: countUp 0.8s ease 0.5s both;
}

/* ==========================================================================
   FILTERS
   ========================================================================== */
.filters { 
    background: var(--color-white); 
    padding: var(--space-md); 
    border-radius: var(--radius-lg); 
    box-shadow: var(--shadow-md); 
    margin-bottom: var(--space-lg);
    animation: fadeInUp 0.5s ease 0.3s both;
}

.filter-group { 
    display: flex; 
    flex-wrap: wrap; 
    gap: var(--space-xs); 
    justify-content: center;
}

.filter-btn { 
    padding: var(--space-xs) var(--space-sm); 
    border: 2px solid var(--color-border); 
    background: var(--color-white); 
    border-radius: var(--radius-full); 
    cursor: pointer; 
    transition: var(--transition); 
    text-decoration: none; 
    color: var(--color-text-secondary); 
    font-weight: 500;
    font-size: 0.9rem;
    min-height: var(--touch-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.filter-btn.active, 
.filter-btn:hover { 
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light)); 
    color: var(--color-white); 
    border-color: var(--color-primary); 
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(139,92,246,0.3);
}

.filter-btn.active {
    animation: scaleIn 0.3s ease;
}

/* ==========================================================================
   CATALOG GRID
   ========================================================================== */
.catalog-grid { 
    display: grid; 
    grid-template-columns: 1fr; 
    gap: var(--space-md); 
    padding-bottom: var(--space-xl);
}

.catalog-item { 
    background: var(--color-white); 
    border-radius: var(--radius-lg); 
    overflow: hidden; 
    box-shadow: var(--shadow-md); 
    transition: var(--transition-slow); 
    display: flex; 
    flex-direction: column;
    animation: fadeInUp 0.5s ease both;
}

.catalog-item:nth-child(1) { animation-delay: 0.05s; }
.catalog-item:nth-child(2) { animation-delay: 0.1s; }
.catalog-item:nth-child(3) { animation-delay: 0.15s; }
.catalog-item:nth-child(4) { animation-delay: 0.2s; }
.catalog-item:nth-child(5) { animation-delay: 0.25s; }
.catalog-item:nth-child(6) { animation-delay: 0.3s; }

.catalog-item:hover { 
    transform: translateY(-8px); 
    box-shadow: var(--shadow-xl); 
}

.catalog-image { 
    height: clamp(180px, 40vw, 220px); 
    background: linear-gradient(135deg, var(--color-bg), var(--color-bg-light)); 
    position: relative; 
    overflow: hidden; 
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.catalog-image img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    transition: transform 0.4s ease; 
}

.catalog-item:hover .catalog-image img { 
    transform: scale(1.05); 
}

.catalog-image i {
    font-size: 3em;
    color: #cbd5e1;
    animation: fadeIn 0.5s ease;
}

.catalog-content { 
    padding: var(--space-md); 
    display: flex; 
    flex-direction: column; 
    flex-grow: 1;
}

.catalog-title { 
    font-size: 1.2em; 
    font-weight: 700; 
    margin-bottom: var(--space-xs); 
    color: var(--color-text-dark); 
    line-height: 1.3;
}

.catalog-description { 
    color: var(--color-text-muted); 
    line-height: 1.5; 
    margin-bottom: var(--space-xs); 
    font-size: 0.9em;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 2.8em;
    max-height: 2.8em;
}

.catalog-label { 
    font-size: 0.8em; 
    color: var(--color-text-light); 
    font-weight: 500; 
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.catalog-price { 
    font-size: 1.4em; 
    font-weight: 800; 
    color: var(--color-success-dark); 
    margin: 2px 0 var(--space-xs);
    transition: var(--transition);
}

.catalog-item:hover .catalog-price {
    transform: scale(1.05);
}

.catalog-stars { 
    color: var(--color-star); 
    margin-bottom: var(--space-xs); 
    display: flex; 
    gap: 2px;
    font-size: 0.9em;
}

.catalog-tags { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 4px; 
    margin-bottom: var(--space-sm);
}

.tag { 
    background: linear-gradient(135deg, var(--color-bg), var(--color-bg-light)); 
    padding: 3px 8px; 
    border-radius: 12px; 
    font-size: 0.75rem; 
    color: #475569; 
    font-weight: 500; 
    white-space: nowrap;
    transition: var(--transition);
    cursor: default;
}

.tag:hover { 
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light)); 
    color: var(--color-white); 
    transform: scale(1.05);
}

.btn-order { 
    width: 100%; 
    background: linear-gradient(135deg, var(--color-success), var(--color-success-dark)); 
    color: var(--color-white); 
    padding: var(--space-sm) var(--space-md); 
    border-radius: var(--radius-md); 
    font-weight: 700; 
    text-align: center; 
    text-decoration: none; 
    transition: var(--transition); 
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    min-height: var(--touch-min);
    font-size: 0.95em;
    position: relative;
    overflow: hidden;
}

.btn-order::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn-order:hover::before {
    left: 100%;
}

.btn-order:hover { 
    transform: translateY(-3px); 
    box-shadow: 0 15px 40px rgba(16,185,129,0.4); 
}

/* ==========================================================================
   EMPTY STATE
   ========================================================================== */
.empty-state { 
    text-align: center; 
    padding: var(--space-xl) var(--space-md); 
    grid-column: 1 / -1; 
    color: var(--color-text-muted);
    animation: fadeInUp 0.5s ease;
}

.empty-icon { 
    font-size: clamp(3rem, 10vw, 5em); 
    color: #d1d5db; 
    margin-bottom: var(--space-md);
    animation: float 3s ease-in-out infinite;
}

.empty-state h2 {
    font-size: 1.5em;
    margin-bottom: var(--space-xs);
    color: var(--color-text-dark);
}

.empty-state p {
    margin-bottom: var(--space-md);
}

/* ==========================================================================
   TABLET (min-width: 480px)
   ========================================================================== */
@media (min-width: 480px) {
    .container { 
        padding: 0 var(--space-md); 
    }

    .btn span {
        display: inline;
    }

    .btn {
        padding: 12px 24px;
        font-size: 0.95rem;
    }

    .header__title {
        font-size: 1.2em;
    }

    .hero {
        padding: var(--space-xl) 0 var(--space-2xl);
    }

    .filters {
        padding: var(--space-lg);
    }

    .filter-group {
        gap: var(--space-sm);
    }

    .filter-btn {
        padding: var(--space-xs) var(--space-md);
        font-size: 1rem;
    }

    .catalog-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-md);
    }

    .catalog-item {
        animation: fadeInUp 0.5s ease both;
    }

    .catalog-item:nth-child(1) { animation-delay: 0.05s; }
    .catalog-item:nth-child(2) { animation-delay: 0.1s; }
    .catalog-item:nth-child(3) { animation-delay: 0.15s; }
    .catalog-item:nth-child(4) { animation-delay: 0.2s; }
    .catalog-item:nth-child(5) { animation-delay: 0.25s; }
    .catalog-item:nth-child(6) { animation-delay: 0.3s; }
}

/* ==========================================================================
   TABLET LANDSCAPE / SMALL LAPTOP (min-width: 768px)
   ========================================================================== */
@media (min-width: 768px) {
    .header {
        padding: var(--space-md) 0;
    }

    .header__inner {
        flex-wrap: nowrap;
    }

    .header__left {
        gap: var(--space-md);
    }

    .header__right {
        gap: var(--space-sm);
    }

    .hero {
        padding: 60px 0;
        margin-bottom: var(--space-xl);
    }

    .hero h1 {
        font-size: 2.5em;
    }

    .filters {
        padding: 35px;
        margin-bottom: var(--space-xl);
    }

    .filter-group {
        margin-top: 0;
    }

    .catalog-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 30px;
        padding-bottom: 60px;
    }

    .catalog-content {
        padding: 25px;
    }

    .catalog-title {
        font-size: 1.3em;
    }

    .catalog-price {
        font-size: 1.6em;
    }

    .btn-order {
        padding: 16px;
        font-size: 1em;
    }
}

/* ==========================================================================
   DESKTOP (min-width: 1024px)
   ========================================================================== */
@media (min-width: 1024px) {
    .container {
        padding: 0 var(--space-lg);
    }

    .hero h1 {
        font-size: 2.8em;
    }

    .catalog-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ==========================================================================
   LARGE DESKTOP (min-width: 1280px)
   ========================================================================== */
@media (min-width: 1280px) {
    .catalog-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}