/* Основные стили */
:root {
    --primary: #2c3e50;
    --secondary: #3498db;
    --success: #27ae60;
    --danger: #e74c3c;
    --light: #ecf0f1;
    --dark: #2c3e50;
    --gray: #95a5a6;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --radius: 8px;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f7fa;
    color: var(--dark);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior: none;
}

/* Шапка */
.header {
    background: #fff;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.logo {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.search-box {
    flex: 1;
    max-width: 500px;
}

.search-box input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 2px solid var(--light);
    border-radius: var(--radius);
    font-size: 16px; /* Предотвращает зум на iOS */
    transition: border-color 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--secondary);
}

/* Кнопка фильтров для мобильных */
.filter-toggle {
    display: none;
    padding: 0.5rem 0.75rem;
    background: var(--secondary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    gap: 0.5rem;
    align-items: center;
}

.filter-toggle .filter-count {
    background: white;
    color: var(--secondary);
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    font-size: 0.75rem;
}

/* Основной контент */
.main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.5rem;
}

/* Боковая панель фильтров */
.filters {
    background: #fff;
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--gray) transparent;
}

.filters::-webkit-scrollbar {
    width: 6px;
}

.filters::-webkit-scrollbar-track {
    background: transparent;
}

.filters::-webkit-scrollbar-thumb {
    background: var(--gray);
    border-radius: 3px;
}

.filters h2 {
    font-size: 1.1rem;
    margin: 0;
}

.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.btn-reset {
    width: auto;
    padding: 0.4rem 0.6rem;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-reset:hover {
    background: #c0392b;
}

.filter-main-checkbox {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--light);
}

.filter-price {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--light);
}

.btn-apply-filters {
    display: none;
    width: 100%;
    padding: 1rem;
    background: var(--success);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
    min-height: 50px;
}

@media (max-width: 900px) {
    .btn-apply-filters {
        display: block;
    }
    
    .filters-close {
        display: flex;
    }
}

.filters-close {
    display: none;
}

/* Аккордеон */
.filter-accordion {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.accordion-item {
    border: 1px solid var(--light);
    border-radius: var(--radius);
    overflow: hidden;
}

.accordion-header {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--light);
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--dark);
    transition: background 0.2s;
}

.accordion-header:hover {
    background: #e0e0e0;
}

.accordion-arrow {
    font-size: 0.7rem;
    transition: transform 0.3s;
    color: var(--gray);
}

.accordion-item.open .accordion-arrow {
    transform: rotate(90deg);
}

.accordion-content {
    display: none;
    padding: 1rem;
    max-height: 200px;
    overflow-y: auto;
}

.accordion-item.open .accordion-content {
    display: block;
}

.filters h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--light);
}

.filter-group {
    margin-bottom: 1.5rem;
}

.filter-group h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.checkbox-list {
    max-height: 200px;
    overflow-y: auto;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.25rem 0;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-label span {
    font-size: 0.95rem;
}

.checkbox-label .count {
    color: var(--gray);
    font-size: 0.85rem;
    margin-left: auto;
}

select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--light);
    border-radius: var(--radius);
    font-size: 0.95rem;
    background: #fff;
    cursor: pointer;
}

.price-range {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.price-range input {
    width: 80px;
    padding: 0.5rem;
    border: 1px solid var(--light);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.btn-reset {
    width: 100%;
    padding: 0.75rem;
    background: var(--light);
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-reset:hover {
    background: #ddd;
}

/* Каталог */
.catalog {
    min-width: 0;
}

.catalog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-filters {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.checkbox-label.inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    white-space: nowrap;
}

.results-count {
    font-size: 1rem;
    color: var(--gray);
}

.sort-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sort-box label {
    font-size: 0.95rem;
    color: var(--gray);
}

.sort-box select {
    width: auto;
    min-width: 180px;
}

/* Сетка товаров */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}

/* Режим списка */
.products-grid.view-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Карточка товара */
.product-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.75rem;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    -webkit-touch-callout: none;
}

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

.product-image {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    background: #f0f0f0;
}

.product-name {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-producer {
    font-size: 0.75rem;
    color: var(--gray);
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-price {
    margin-top: auto;
}

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

.price-unit {
    font-size: 0.75rem;
    color: var(--gray);
}

.product-stock {
    margin-top: 0.25rem;
    font-size: 0.8rem;
}

.stock-yes {
    color: var(--success);
}

.stock-no {
    color: var(--danger);
}

.product-details-btn {
    display: none;
}

.product-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn-add-cart {
    flex: 1;
    padding: 0.6rem 0.5rem;
    background: var(--success);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-add-cart:active {
    transform: scale(0.95);
    background: #219a52;
}

.btn-add-cart-modal {
    margin-top: 1rem;
    width: 100%;
    padding: 0.875rem;
    font-size: 1rem;
    min-height: 50px;
}

/* Режим списка - строка товара */
.product-row {
    display: grid;
    grid-template-columns: 50px 1fr auto auto auto;
    gap: 1rem;
    align-items: center;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.product-row:hover {
    background: #fafafa;
}

.product-row:active {
    background: #f5f5f5;
}

.product-row-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    background: #f0f0f0;
    cursor: pointer;
}

.product-row-info {
    min-width: 0;
}

.product-row-name {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-row-meta {
    font-size: 0.8rem;
    color: var(--gray);
    margin-top: 0.25rem;
}

.product-row-package {
    background: var(--light);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.product-row-stock {
    font-size: 0.85rem;
    white-space: nowrap;
}

.product-row-prices {
    text-align: right;
    white-space: nowrap;
}

.product-row-prices .price-pack {
    font-size: 1rem;
}

.product-row-prices .price-unit {
    font-size: 0.75rem;
}

.btn-row {
    min-height: 40px;
    padding: 0.5rem 1rem;
}

/* Превью изображения */
.image-preview {
    position: fixed;
    z-index: 1000;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    padding: 8px;
    display: none;
    animation: fadeIn 0.2s ease-out;
}

.image-preview img {
    width: 200px;
    height: 200px;
    object-fit: cover;
    border-radius: 4px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* Переключатель вида */
.view-toggle {
    display: flex;
    gap: 0.25rem;
    background: var(--light);
    padding: 0.25rem;
    border-radius: 6px;
}

.view-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--gray);
    transition: all 0.2s;
}

.view-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.view-btn:hover:not(.active) {
    color: var(--dark);
}

.catalog-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* На мобильных - кнопки вида и сортировка в ряд */
@media (max-width: 900px) {
    .catalog-controls {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .view-toggle {
        order: 1;
    }
    
    .sort-box {
        order: 2;
        flex: 1;
        max-width: 200px;
    }
}
    
/* Уведомление */
.notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--dark);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 2000;
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
}

.notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Пагинация */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.pagination button {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--light);
    background: #fff;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.pagination button:hover {
    background: var(--light);
}

.pagination button.active {
    background: var(--secondary);
    color: #fff;
    border-color: var(--secondary);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    overflow-y: auto;
    padding: 1rem;
    padding-bottom: var(--safe-area-bottom);
}

.modal-content {
    background: #fff;
    margin: 5% auto;
    padding: 1.25rem;
    border-radius: var(--radius);
    max-width: 500px;
    width: 100%;
    position: relative;
    animation: modalIn 0.25s ease-out;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray);
    transition: color 0.2s;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--light);
    border-radius: 50%;
}

.modal-close:active {
    color: var(--dark);
    background: #ddd;
}

.modal-product-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    background: #f0f0f0;
}

.modal h2 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
    padding-right: 2rem;
}

.modal-producer {
    color: var(--gray);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.modal-details {
    display: grid;
    gap: 0.5rem;
}

.modal-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--light);
    font-size: 0.9rem;
}

.modal-row:last-child {
    border-bottom: none;
}

.modal-label {
    color: var(--gray);
}

.modal-value {
    font-weight: 600;
}

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

/* Корзина в шапке */
.cart-icon {
    position: relative;
    cursor: pointer;
    padding: 0.5rem;
    font-size: 1.3rem;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-count {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    padding: 0.1rem 0.35rem;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
    font-weight: 600;
}

/* Страница корзины */
.cart-page {
    display: none;
}

.cart-page.active {
    display: block;
}

.cart-container {
    max-width: 800px;
    margin: 0 auto;
    background: #fff;
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    padding-bottom: calc(1rem + var(--safe-area-bottom));
}

.cart-container h1 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.cart-items {
    margin-bottom: 1.5rem;
}

.cart-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--light);
    align-items: center;
    flex-wrap: wrap;
}

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

.cart-item-image {
    width: 60px;
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

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

.cart-item-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cart-item-price {
    color: var(--gray);
    font-size: 0.8rem;
}

.cart-item-quantity {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cart-item-quantity button {
    width: 36px;
    height: 36px;
    border: 1px solid var(--light);
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-item-quantity button:active {
    background: var(--light);
}

.cart-item-quantity span {
    min-width: 28px;
    text-align: center;
    font-weight: 600;
    font-size: 1rem;
}

.cart-item-total {
    font-weight: 700;
    color: var(--primary);
    min-width: 80px;
    text-align: right;
    font-size: 0.95rem;
}

.cart-item-remove {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.5rem;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-item-remove:active {
    opacity: 0.7;
}

.cart-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--gray);
}

.cart-empty-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.cart-empty .btn-continue {
    margin-top: 1rem;
    background: var(--secondary);
    color: white;
}

.cart-empty .btn-continue:active {
    background: #2980b9;
}

.cart-summary {
    border-top: 2px solid var(--light);
    padding-top: 1rem;
    position: sticky;
    bottom: 0;
    background: #fff;
    margin: 0 -1rem;
    padding: 1rem;
    padding-bottom: calc(1rem + var(--safe-area-bottom));
}

.cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.cart-total span:last-child {
    color: var(--primary);
}

.btn-checkout {
    width: 100%;
    padding: 1rem;
    background: var(--success);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 0.5rem;
    transition: background 0.2s;
    min-height: 50px;
}

.btn-checkout:active {
    background: #219a52;
    transform: scale(0.98);
}

.btn-continue {
    width: 100%;
    padding: 0.75rem;
    background: var(--light);
    color: var(--dark);
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
    min-height: 44px;
}

.btn-continue:active {
    background: #ddd;
}

/* Адаптивность */
@media (max-width: 900px) {
    .main {
        grid-template-columns: 1fr;
    }
    
    .filters {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 200;
        max-height: 100vh;
        border-radius: 0;
        transform: translateX(-100%);
        transition: transform 0.3s ease-out;
        padding-top: calc(1rem + env(safe-area-inset-top, 0px));
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    }
    
    .filters.active {
        transform: translateX(0);
    }
    
    .filter-toggle {
        display: flex;
    }
    
    .header-content {
        flex-wrap: wrap;
    }
    
    .search-box {
        order: 3;
        max-width: 100%;
        width: 100%;
    }
    
    .filters-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 150;
    }
    
    .filters-overlay.active {
        display: block;
    }
    
    .filters-close {
        display: block;
        position: absolute;
        top: 0.75rem;
        right: 0.75rem;
        font-size: 1.5rem;
        cursor: pointer;
        color: var(--gray);
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--light);
        border-radius: 50%;
    }
}

@media (max-width: 600px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    
    .product-card {
        padding: 0.5rem;
    }
    
    .product-image {
        height: 100px;
    }
    
    .product-name {
        font-size: 0.8rem;
    }
    
    .price-pack {
        font-size: 0.9rem;
    }
    
    .price-unit {
        font-size: 0.7rem;
    }
    
    .product-stock {
        font-size: 0.75rem;
    }
    
    .btn-add-cart {
        font-size: 0.8rem;
        padding: 0.5rem;
        min-height: 40px;
    }
    
    .header-content {
        padding: 0.5rem;
    }
    
    .main {
        padding: 0.5rem;
    }
    
    .logo {
        font-size: 1rem;
    }
    
    .catalog-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .catalog-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .sort-box {
        flex: 1;
    }
    
    .sort-box select {
        width: 100%;
    }
    
    .results-count {
        font-size: 0.9rem;
    }
    
    /* Список на мобильных */
    .product-row {
        grid-template-columns: 40px 1fr auto;
        gap: 0.75rem;
        padding: 0.5rem 0.75rem;
    }
    
    .product-row-image {
        width: 40px;
        height: 40px;
    }
    
    .product-row-name {
        font-size: 0.85rem;
    }
    
    .product-row-meta {
        display: none;
    }
    
    .product-row-stock {
        display: none;
    }
    
    .product-row-prices {
        display: none;
    }
    
    .btn-row {
        display: none;
    }
    
    .product-row:active .btn-row {
        display: block;
        position: absolute;
        right: 0.75rem;
        top: 50%;
        transform: translateY(-50%);
    }
    
    /* Пагинация для мобильных */
    .pagination {
        gap: 0.25rem;
    }
    
    .pagination button {
        padding: 0.5rem 0.6rem;
        font-size: 0.9rem;
        min-width: 40px;
        min-height: 40px;
    }
    
    /* Модальное окно на мобильных */
    .modal {
        padding: 0.5rem;
    }
    
    .modal-content {
        margin: 0;
        padding: 1rem;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-product-image {
        height: 150px;
    }
    
    /* Корзина на мобильных */
    .cart-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .cart-item-image {
        width: 100%;
        height: 80px;
    }
    
    .cart-item-info {
        width: 100%;
    }
    
    .cart-item-quantity {
        width: 100%;
        justify-content: flex-start;
    }
    
    .cart-item-total {
        width: 100%;
        text-align: left;
        font-size: 1.1rem;
    }
    
    .cart-item-remove {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
    }
    
    .cart-item {
        position: relative;
        padding-right: 2.5rem;
    }
}

/* Очень маленькие экраны */
@media (max-width: 360px) {
    .products-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.4rem;
    }
    
    .product-card {
        padding: 0.4rem;
    }
    
    .product-image {
        height: 80px;
    }
    
    .product-name {
        font-size: 0.75rem;
        -webkit-line-clamp: 3;
    }
    
    .price-pack {
        font-size: 0.85rem;
    }
    
    .btn-add-cart {
        font-size: 0.75rem;
        padding: 0.4rem;
    }
}

/* Горизонтальная ориентация на мобильных */
@media (max-height: 500px) and (orientation: landscape) {
    .modal-content {
        max-height: 95vh;
    }
    
    .modal-product-image {
        height: 120px;
    }
}

/* Плавная прокрутка и производительность */
.product-card {
    will-change: transform;
}

.product-image {
    will-change: transform;
}

/* Улучшенная прокрутка на iOS */
.filters,
.cart-items,
.modal-content {
    -webkit-overflow-scrolling: touch;
}

/* Убираем hover эффекты на тач-устройствах */
@media (hover: none) {
    .product-card:hover {
        transform: none;
        box-shadow: var(--shadow);
    }
    
    .btn-add-cart:hover {
        background: var(--success);
    }
    
    .btn-checkout:hover {
        background: var(--success);
    }
}

/* Сообщение "Товары не найдены" */
.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray);
    font-size: 1.1rem;
}

/* Быстрый заказ на мобильных */
.quick-order-hint {
    display: none;
    position: fixed;
    bottom: calc(1rem + var(--safe-area-bottom));
    left: 1rem;
    right: 1rem;
    background: var(--dark);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    text-align: center;
    z-index: 50;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Улучшение читаемости на маленьких экранах */
@media (max-width: 600px) {
    .no-results {
        padding: 2rem 1rem;
        font-size: 1rem;
    }
    
    .checkbox-label {
        padding: 0.4rem 0;
    }
    
    .checkbox-label span {
        font-size: 0.9rem;
    }
    
    .accordion-header {
        padding: 0.6rem 0.75rem;
        font-size: 0.9rem;
    }
    
    .accordion-content {
        padding: 0.75rem;
    }
    
    .filter-group h3 {
        font-size: 0.85rem;
    }
    
    .price-range input {
        width: 70px;
        padding: 0.4rem;
        font-size: 16px;
    }
}
