/* ============================================
   2026 MODERN TELEGRAM MINI APP DESIGN
   Mobile-First | 2-Column Grid | Glassmorphism
   ============================================ */

/* === CSS VARIABLES === */
:root {
    /* Telegram Theme Colors */
    --tg-bg: #0a0a0a;
    --tg-text: #ffffff;
    --tg-hint: #8e8e93;
    
    /* 2026 Color Palette */
    --primary: #007AFF;
    --primary-dark: #0051D5;
    --secondary: #5856D6;
    --success: #34C759;
    --warning: #FF9500;
    --danger: #FF3B30;
    
    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-strong: rgba(255, 255, 255, 0.15);
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.12);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.16);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.24);
    
    /* Spacing (8px base) */
    --space-xs: 0.5rem;  /* 8px */
    --space-sm: 0.75rem; /* 12px */
    --space-md: 1rem;    /* 16px */
    --space-lg: 1.5rem;  /* 24px */
    --space-xl: 2rem;    /* 32px */
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* === RESET === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 
                 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(180deg, 
                var(--tg-bg) 0%, 
                #1a1a1a 50%, 
                var(--tg-bg) 100%);
    color: var(--tg-text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* === CONTAINER === */
.app-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 140px var(--space-md) var(--space-xl);
    animation: fadeIn var(--transition-slow) ease-out;
}

/* === HEADER === */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--glass-strong);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--glass-border);
    padding: var(--space-sm) var(--space-md) var(--space-md);
    transition: transform var(--transition-base);
    transform: translateY(0);
}

.header.hidden {
    transform: translateY(-100%);
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
}

.title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #ffffff 0%, #a0a0a0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 0.75rem;
    color: var(--tg-hint);
    font-weight: 500;
}

/* === SEARCH BAR === */
.search-container {
    position: relative;
    margin-bottom: var(--space-md);
}

.search-bar {
    width: 100%;
    padding: var(--space-sm) var(--space-md) var(--space-sm) 2.75rem;
    background: var(--glass-bg);
    border: 1.5px solid var(--glass-border);
    border-radius: var(--radius-full);
    color: var(--tg-text);
    font-size: 1rem;
    font-weight: 500;
    transition: all var(--transition-base);
}

.search-bar:focus {
    outline: none;
    background: var(--glass-strong);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

.search-bar::placeholder {
    color: var(--tg-hint);
}

.search-icon {
    position: absolute;
    left: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--tg-hint);
    pointer-events: none;
}

/* === CATEGORY CHIPS (Horizontal Scroll) === */
.category-chips {
    display: flex;
    gap: var(--space-sm);
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    padding: var(--space-xs) 0;
    margin: 0 calc(-1 * var(--space-md));
    padding-left: var(--space-md);
    padding-right: var(--space-md);
    
    /* Prevent browser back gesture */
    touch-action: pan-x;
    overscroll-behavior-x: contain;
    -webkit-overscroll-behavior-x: contain;
}

.category-chips::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
}

.chip {
    flex-shrink: 0;
    padding: var(--space-xs) var(--space-md);
    background: var(--glass-bg);
    border: 1.5px solid var(--glass-border);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--tg-text);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    user-select: none;
}

.chip:active {
    transform: scale(0.95);
}

.chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 12px rgba(0, 122, 255, 0.4);
}

/* === PRODUCTS GRID - 2 COLUMNS MOBILE === */
.products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* ⭐ ALWAYS 2 COLUMNS */
    gap: var(--space-md);
    margin-top: var(--space-lg);
    animation: slideUp var(--transition-slow) ease-out;
}

/* Tablet: 3 columns */
@media (min-width: 640px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-lg);
    }
}

/* Desktop: 4 columns */
@media (min-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* === PRODUCT CARD (Bento Style) === */
.product-card {
    position: relative;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition-base);
    animation: fadeIn var(--transition-base) ease-out;
    animation-fill-mode: both;
}

.product-card:active {
    transform: scale(0.97);
}

.product-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

/* Card Image */
.product-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1; /* ⭐ SQUARE IMAGE */
    overflow: hidden;
    background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.product-card:hover .product-image {
    transform: scale(1.05);
}

/* Badge (Sold/New) */
.product-badge {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    padding: 0.25rem 0.625rem;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    color: #ffffff;
    z-index: 10;
}

.product-badge.sold {
    background: rgba(255, 59, 48, 0.9);
}

.product-badge.new {
    background: rgba(52, 199, 89, 0.9);
}

/* Card Content */
.product-info {
    padding: var(--space-md);
}

.product-category {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--tg-hint);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.product-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--tg-text);
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    min-height: 2.6em;
}

.product-price {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: auto;
}

/* === SKELETON LOADERS (Shimmer Effect) === */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.skeleton-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.skeleton-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.03) 0%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(255, 255, 255, 0.03) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-content {
    padding: var(--space-md);
}

.skeleton-line {
    height: 12px;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.03) 0%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(255, 255, 255, 0.03) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-sm);
}

.skeleton-category {
    width: 50%;
    height: 10px;
}

.skeleton-title {
    width: 90%;
}

.skeleton-price {
    width: 40%;
    height: 16px;
    margin-top: var(--space-sm);
}

/* === ANIMATIONS === */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animation for cards */
.product-card:nth-child(1) { animation-delay: 0ms; }
.product-card:nth-child(2) { animation-delay: 50ms; }
.product-card:nth-child(3) { animation-delay: 100ms; }
.product-card:nth-child(4) { animation-delay: 150ms; }
.product-card:nth-child(5) { animation-delay: 200ms; }
.product-card:nth-child(6) { animation-delay: 250ms; }

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: var(--space-xl) var(--space-md);
    color: var(--tg-hint);
    font-size: 1rem;
}

.empty-state p {
    margin-top: var(--space-md);
    font-weight: 500;
}

/* === SCROLL TO TOP BUTTON === */
.scroll-top-btn {
    position: fixed;
    bottom: var(--space-xl);
    right: var(--space-md);
    width: 48px;
    height: 48px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-full);
    color: #ffffff;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.8);
    transition: all var(--transition-base);
    z-index: 1000;
}

.scroll-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.scroll-top-btn:active {
    transform: scale(0.9);
}

/* === PRODUCT MODAL (Full Screen) === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    z-index: 9999;
    display: none;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    background: var(--tg-bg);
    overflow-y: auto;
    animation: modalSlideUp var(--transition-slow) ease-out;
}

@keyframes modalSlideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.modal-close {
    position: fixed;
    top: var(--space-md);
    right: var(--space-md);
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    color: #ffffff;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:active {
    transform: scale(0.9);
}

/* === RESPONSIVE TWEAKS === */
@media (max-width: 374px) {
    /* Small phones */
    .products-grid {
        gap: var(--space-sm);
    }
    
    .product-title {
        font-size: 0.8125rem;
    }
    
    .product-price {
        font-size: 1rem;
    }
}

