/* ===== СБРОС И БАЗОВЫЕ СТИЛИ ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --green: #53B175;
    --green-dark: #489E67;
    --green-light: #E8F5E9;
    --green-pale: #F0FAF4;
    --bg: #F2F3F2;
    --white: #FFFFFF;
    --text: #181725;
    --text-secondary: #7C7C7C;
    --text-muted: #B1B1B1;
    --border: #E2E2E2;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.1);
    --radius: 16px;
    --radius-sm: 12px;
    --nav-height: 70px;
    --categories-height: 64px;
    --wa-green: #25D366;
    --sale: #FF6B35;
    --sale-bg: #FFF3EE;
    --sale-card-bg: #FFEFE8;
    --sale-card-border: #FFD8CB;
}

html {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

body {
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    overflow-x: hidden;
    padding-bottom: calc(var(--nav-height) + 18px);
}

/* ===== ЭКРАНЫ ===== */
.screen {
    display: none;
    animation: fadeIn 0.25s ease;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== ШАПКА (не sticky — прокручивается) ===== */
.header {
    text-align: center;
    padding: 24px 16px 8px;
}

.header-logo {
    font-size: 36px;
    margin-bottom: 4px;
    animation: bounce 2s infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

.header-title {
    font-size: 24px;
    font-weight: 800;
    color: var(--green);
    letter-spacing: -0.5px;
}

.header-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ===== ПОИСК ===== */
.search-wrap {
    position: relative;
    margin: 16px 16px 0;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 14px 16px 14px 44px;
    border: none;
    border-radius: var(--radius);
    background: var(--white);
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    box-shadow: var(--shadow);
    outline: none;
    transition: box-shadow 0.2s;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    box-shadow: 0 0 0 2px var(--green), var(--shadow);
}

/* ===== БАННЕР ===== */
.banner {
    background: linear-gradient(135deg, var(--green) 0%, #3d9d5e 100%);
    border-radius: var(--radius);
    padding: 24px 20px;
    margin: 16px 16px 0;
    color: white;
    overflow: hidden;
    position: relative;
}

.banner-top {
    margin: 8px 16px 0;
}

.banner::after {
    content: '';
    position: absolute;
    right: -20px;
    top: -20px;
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.banner-content {
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
    z-index: 1;
}

.banner-copy {
    margin-left: -26px;
}

.banner-emoji {
    font-size: 32px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.banner-title {
    font-size: 22px;
    font-weight: 700;
}

.banner-text {
    font-size: 13px;
    opacity: 0.9;
    margin-top: 2px;
}

.banner-text + .banner-text {
    margin-top: 8px;
}

/* ===== ФИКСИРОВАННЫЕ БАРЫ КАТЕГОРИЙ (ВЕРХ/НИЗ) ===== */
.sticky-bar {
    left: 0;
    right: 0;
    z-index: 150;
    background: var(--bg);
    padding: 10px 0 5px;
    transition: transform 0.3s ease;
}

.sticky-bar-top {
    position: sticky;
    top: 0;
    z-index: 170;
    padding: 8px 0 2px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}


/* Ограничение ширины на десктопе */
@media (min-width: 480px) {
    .sticky-bar-top {
        max-width: 430px;
        margin: 0 auto;
    }
}

/* Скрываем метку когда бар внизу, чтобы не загромождать */

/* ===== КАТЕГОРИИ (чипсы) ===== */
.categories-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 5px 0 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.categories-bar::-webkit-scrollbar {
    display: none;
}

.cat-chip {
    flex-shrink: 0;
    padding: 12px 22px;
    /* Чуть шире по высоте и вширь */
    border: 1.5px solid var(--border);
    border-radius: 24px;
    background: var(--white);
    font-size: 14px;
    /* Чуть крупнее шрифт */
    font-weight: 600;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

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

.cat-chip.active {
    background: var(--green);
    color: white;
    border-color: var(--green);
}

/* Специальный стиль для чипа "Акция" */
.cat-chip[data-category="sale"] {
    border-color: var(--sale);
    color: var(--sale);
}

.cat-chip[data-category="sale"].active {
    background: var(--sale);
    color: white;
    border-color: var(--sale);
}

/* Метка времени обновления */
.last-update {
    font-size: 11px;
    color: var(--text-muted);
    padding: 0 16px 8px;
    text-align: right;
}

/* ===== LOADING-БАННЕР ===== */
.loading-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 16px;
    padding: 12px 16px;
    background: var(--white);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-secondary);
    box-shadow: var(--shadow);
}

.loading-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--green-pale);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

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

/* ===== СЕКЦИЯ КАТЕГОРИИ ===== */
.category-section {
    margin-bottom: 20px;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding: 0 18px;
}

.category-emoji {
    font-size: 22px;
}

.category-name {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.category-count {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 10px;
}

/* ===== СПИСОК ТОВАРОВ ===== */
.products-list {
    padding: 12px 16px 8px;
}

/* ===== КАРТОЧКА ТОВАРА ===== */
.product-card {
    display: flex;
    align-items: center;
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 8px;
    box-shadow: var(--shadow);
    transition: transform 0.15s, box-shadow 0.15s;
    gap: 12px;
}

.product-card:active {
    transform: scale(0.98);
}

.product-card.in-cart {
    border-left: 3px solid var(--green);
}

.product-card.sale-card {
    background: var(--sale-card-bg);
    box-shadow: 0 0 0 1px var(--sale-card-border), var(--shadow);
}

.product-emoji {
    font-size: 28px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--green-pale);
    border-radius: 12px;
    flex-shrink: 0;
}

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

.product-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

.sale-flame {
    display: inline-block;
    font-size: 12px;
    line-height: 1;
    margin-left: 2px;
    vertical-align: baseline;
}

.product-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--green);
    margin-top: 2px;
}

/* ===== СЧЁТЧИК ===== */
.counter {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.counter-btn {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 10px;
    font-size: 18px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.counter-btn:active {
    transform: scale(0.9);
}

.counter-btn.minus {
    background: var(--bg);
    color: var(--text-secondary);
}

.counter-btn.minus:hover {
    background: #e0e0e0;
}

.counter-btn.plus {
    background: var(--green);
    color: white;
}

.counter-btn.plus:hover {
    background: var(--green-dark);
}

.counter-btn.plus.is-active {
    background: #4e8ef7;
}

.counter-btn.plus.is-active:hover {
    background: #3f7be2;
}

.counter-val {
    width: auto;
    min-width: 10px;
    text-align: right;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.counter-val.has-value {
    color: var(--green);
}

.counter-value-wrap {
    min-width: 48px;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 1px;
}

.counter-unit {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: lowercase;
}

/* ===== ПУСТОЙ РЕЗУЛЬТАТ ===== */
.empty-state,
.cart-empty {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-secondary);
}

.empty-emoji {
    font-size: 48px;
    margin-bottom: 12px;
}

.cart-empty-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== ЭКРАН КОРЗИНЫ ===== */
.cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 16px 16px;
}

.cart-title {
    font-size: 22px;
    font-weight: 800;
}

.clear-btn {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    border: 1.5px solid #ff6b6b;
    border-radius: 20px;
    background: transparent;
    color: #ff6b6b;
    cursor: pointer;
    transition: all 0.2s;
}

.clear-btn:active {
    background: #ff6b6b;
    color: white;
}

.cart-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 16px;
}

.cart-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    box-shadow: var(--shadow);
}

.cart-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cart-item-name {
    font-size: 14px;
    font-weight: 600;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cart-item-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--green);
}

.cart-item-counter {
    margin-left: 8px;
}

/* ===== БЛОК ЗАКАЗА (текст) ===== */
.cart-summary {
    margin: 16px 16px 100px;
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.summary-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.summary-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.copy-btn {
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.copy-btn:active {
    background: var(--green-pale);
    border-color: var(--green);
    color: var(--green-dark);
}

.copy-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cart-text {
    font-family: 'Inter', monospace;
    font-size: 13px;
    color: var(--text);
    white-space: pre-wrap;
    line-height: 1.7;
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 12px;
    background: var(--green-pale);
    max-height: 240px;
    overflow-y: auto;
}

.cart-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 16px;
    font-weight: 700;
}

.cart-total-price {
    color: var(--green);
    font-size: 20px;
}

.cart-total-note {
    margin-top: 10px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-secondary);
}

/* ===== КНОПКА WhatsApp ===== */
.whatsapp-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: calc(100% - 32px);
    position: fixed;
    bottom: calc(var(--nav-height) + 14px);
    left: 16px;
    right: 16px;
    padding: 16px;
    background: var(--wa-green);
    color: white;
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    border: none;
    border-radius: var(--radius);
    text-decoration: none;
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4);
    transition: transform 0.15s, box-shadow 0.15s;
    z-index: 100;
}

.whatsapp-btn:active {
    transform: scale(0.97);
    box-shadow: 0 3px 12px rgba(37, 211, 102, 0.3);
}

.wa-icon {
    width: 22px;
    height: 22px;
}

/* ===== НИЖНЯЯ НАВИГАЦИЯ ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: space-around;
    box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.06);
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 20px;
    position: relative;
    font-family: inherit;
    transition: all 0.2s;
}

.nav-btn svg {
    width: 24px;
    height: 24px;
    color: var(--text-muted);
    transition: color 0.2s;
}

.nav-btn span {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    transition: color 0.2s;
}

.nav-btn.active svg {
    color: var(--green);
}

.nav-btn.active span {
    color: var(--green);
    font-weight: 600;
}

.cart-badge {
    position: absolute;
    top: 2px;
    right: 10px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #ff6b6b;
    color: white;
    font-size: 11px;
    font-weight: 700;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: popIn 0.3s ease;
}

@keyframes popIn {
    from {
        transform: scale(0);
    }

    to {
        transform: scale(1);
    }
}

/* ===== АДАПТИВНОСТЬ ===== */
@media (min-width: 480px) {
    body {
        max-width: 430px;
        margin: 0 auto;
        box-shadow: -1px 0 0 var(--border), 1px 0 0 var(--border);
        min-height: 100vh;
    }

    .bottom-nav {
        max-width: 430px;
        left: 50%;
        transform: translateX(-50%);
    }

    .whatsapp-btn {
        max-width: 398px;
        left: 50%;
        transform: translateX(-50%);
    }

    .whatsapp-btn:active {
        transform: translateX(-50%) scale(0.97);
    }
}
