/* Базовые стили магазина */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    min-height: 100vh;
    padding-bottom: 80px;
    color: var(--text);
}

/* Header */
.shop-header {
    background: var(--header-bg, linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%));
    padding: 16px;
    max-width: 500px;
    margin: 0 auto;
    border-bottom: var(--header-border, none);
}

.shop-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.shop-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--header-text, white);
}

.shop-logo-img {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--header-icon-bg, rgba(255,255,255,0.2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.shop-name {
    font-weight: 700;
    font-size: 1.1rem;
}

.header-actions {
    display: flex;
    gap: 12px;
}

.header-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--header-icon-bg, rgba(255,255,255,0.2));
    border: none;
    color: var(--header-text, white);
    font-size: 1.2rem;
    cursor: pointer;
    position: relative;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-btn svg {
    stroke: var(--header-text, white);
}

.cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--accent);
    color: var(--accent-text);
    font-size: 0.7rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Banner */
.shop-banner {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    overflow: hidden;
}

.shop-banner img {
    width: 100%;
    max-height: 180px;
    object-fit: cover;
    display: block;
}

/* Container */
.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 16px;
}

/* Floating WhatsApp Button */
.wa-float {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: #25D366;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
    cursor: pointer;
    z-index: 1000;
    text-decoration: none;
    transition: transform 0.2s;
}

.wa-float:hover { transform: scale(1.1); }
.wa-float svg { width: 32px; height: 32px; fill: white; }

/* Product Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.product-card {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.product-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: var(--secondary);
}

.product-img-placeholder {
    width: 100%;
    aspect-ratio: 1;
    background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    opacity: 0.3;
}

.product-info { padding: 12px; }

.product-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price {
    color: var(--primary);
    font-weight: 700;
    font-size: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    width: 100%;
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-text);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.btn-whatsapp {
    background: #25D366;
    color: white;
}

.btn-whatsapp:hover { background: #20BD5A; }

.btn-outline {
    background: var(--card-bg);
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-theme {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.btn-theme:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon { font-size: 4rem; margin-bottom: 16px; }
.empty-text { color: var(--text-muted); }

/* Utils */
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* Locale Switcher */
.locale-switcher {
    display: flex;
    gap: 4px;
    background: var(--header-icon-bg, rgba(255,255,255,0.2));
    border-radius: 8px;
    padding: 4px;
}

.locale-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 1rem;
    transition: all 0.2s;
    opacity: 0.6;
}

.locale-btn:hover {
    opacity: 0.9;
    background: rgba(255,255,255,0.2);
}

.locale-btn.active {
    opacity: 1;
    background: rgba(255,255,255,0.3);
}

/* ========================================
   Search Bar & Dropdown
   ======================================== */

.search-container {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    padding: 12px 0;
    margin-bottom: 4px;
}

.search-input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    border: 2px solid var(--border, #E5E7EB);
    background: var(--card-bg);
    font-size: 1rem;
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(91, 63, 217, 0.1);
}

.search-input::placeholder {
    color: var(--text-muted, #9CA3AF);
}

/* Search Dropdown */
.search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-height: 60vh;
    overflow-y: auto;
    z-index: 101;
}

.search-dropdown.hidden {
    display: none;
}

/* Search Item */
.search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--border, #E5E7EB);
    transition: background 0.15s;
}

.search-item:last-child {
    border-bottom: none;
}

.search-item:hover {
    background: var(--secondary, #F3F4F6);
}

.search-item-img {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--secondary, #F3F4F6);
    flex-shrink: 0;
}

.search-item-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    opacity: 0.5;
}

.search-item-info {
    flex: 1;
    min-width: 0;
}

.search-item-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-item-price {
    color: var(--primary);
    font-weight: 700;
    font-size: 0.85rem;
}

/* Highlight matched text */
.highlight {
    background: var(--accent, #FFC300);
    color: var(--accent-text, #1F1F1F);
    padding: 0 2px;
    border-radius: 2px;
}

/* Search Empty State */
.search-empty {
    padding: 32px 16px;
    text-align: center;
}

.search-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.search-empty-text {
    color: var(--text-muted, #9CA3AF);
    font-size: 0.9rem;
}

/* ========================================
   Skeleton Loading
   ======================================== */

.skeleton-card {
    pointer-events: none;
}

.skeleton-img {
    background: linear-gradient(90deg, var(--secondary, #E5E7EB) 25%, var(--bg, #F9FAFB) 50%, var(--secondary, #E5E7EB) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

.skeleton-text {
    height: 14px;
    background: linear-gradient(90deg, var(--secondary, #E5E7EB) 25%, var(--bg, #F9FAFB) 50%, var(--secondary, #E5E7EB) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-text.short {
    width: 60%;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Search Loading */
.search-loading .search-item {
    pointer-events: none;
}

.search-loading .skeleton-img {
    width: 48px;
    height: 48px;
    border-radius: 8px;
}

.search-loading .search-item-info .skeleton-text {
    height: 12px;
    margin-bottom: 6px;
}

.search-loading .search-item-info .skeleton-text:first-child {
    width: 80%;
}

.search-loading .search-item-info .skeleton-text.short {
    width: 40%;
    margin-bottom: 0;
}

/* ========================================
   Loading Indicator (Infinite Scroll)
   ======================================== */

.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    color: var(--text-muted, #9CA3AF);
    font-size: 0.9rem;
}

.loading-indicator.hidden {
    display: none;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--secondary, #E5E7EB);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Category Grid (большие карточки с картинками) ===== */
.category-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 12px 16px;
    max-width: 500px;
    margin: 0 auto;
}

.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: transform 0.2s;
}

.category-card:active {
    transform: scale(0.95);
}

.category-card-img {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 16px;
    overflow: hidden;
    background: var(--card-bg, #fff);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
}

.category-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.category-card-emoji {
    font-size: 2.5rem;
}

.category-card-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text);
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Sticky Category Bar (chips с emoji) ===== */
.category-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg, #f5f5f5);
    padding: 8px 16px;
    max-width: 500px;
    margin: 0 auto;
    border-bottom: 1px solid var(--border, #e5e7eb);
}

.category-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}

.category-chips::-webkit-scrollbar {
    display: none;
}

.category-chip {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--border, #d1d5db);
    background: var(--card-bg, #fff);
    color: var(--text-secondary, #6b7280);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.category-chip:active {
    transform: scale(0.95);
}

.category-chip.active {
    background: var(--primary, #5B3FD9);
    color: #fff;
    border-color: var(--primary, #5B3FD9);
}

/* Анимация fade для товаров при смене категории */
.products-grid.fade-out {
    opacity: 0;
    transition: opacity 0.15s ease;
}

.products-grid.fade-in {
    opacity: 1;
    transition: opacity 0.15s ease;
}
