/* ===== СБРОС ===== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; background: #f5f7fa; }

/* ===== КОНТЕЙНЕРЫ ===== */
.container { max-width: 800px; margin: 0 auto; padding-bottom: 100px; }
.shop-layout { display: flex; max-width: 1200px; margin: 0 auto; min-height: 100vh; }
.main-content { flex: 1; padding: 15px; }
.cart-container { max-width: 800px; margin: 0 auto; padding: 15px; padding-bottom: 100px; }

/* ===== ХЕДЕР ===== */
.header, .cart-header, .product-header { display: flex; align-items: center; gap: 15px; padding: 15px; background: white; }
.cart-header, .product-header { border-radius: 16px; margin-bottom: 15px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.back-btn { font-size: 24px; text-decoration: none; color: #343a40; }
.cart-btn { margin-left: auto; position: relative; font-size: 24px; text-decoration: none; color: #343a40; }
.cart-count { position: absolute; top: -8px; right: -8px; background: #dc3545; color: white; font-size: 12px; padding: 2px 6px; border-radius: 10px; min-width: 20px; text-align: center; }

/* ===== БОКОВОЕ МЕНЮ ===== */
.sidebar { width: 280px; background: white; padding: 20px; border-right: 1px solid #e9ecef; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar-header { display: flex; justify-content: space-between; margin-bottom: 20px; }
.sidebar-logo { font-size: 1.3rem; font-weight: bold; color: #343a40; text-decoration: none; }
.close-sidebar { display: none; font-size: 24px; background: none; border: none; cursor: pointer; }
.sidebar-section { margin-bottom: 25px; }
.sidebar-title { font-weight: 600; margin-bottom: 15px; color: #343a40; }
.category-list { list-style: none; }
.category-link { display: flex; justify-content: space-between; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: #495057; }
.category-link:hover { background: #f8f9fa; }
.category-link.active { background: #007bff; color: white; }
.category-link.new-link { border: 1px solid #ffc107; }
.category-count { background: #e9ecef; color: #6c757d; padding: 2px 8px; border-radius: 20px; font-size: 0.75rem; }
.sidebar-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 999; }

/* ===== МОБИЛЬНЫЙ ХЕДЕР ===== */
.mobile-header { display: none; align-items: center; justify-content: space-between; padding: 10px 0; margin-bottom: 15px; }
.menu-btn { font-size: 24px; background: none; border: none; cursor: pointer; }
.shop-logo-mobile { font-size: 1.3rem; font-weight: bold; color: #343a40; text-decoration: none; }

/* ===== ПОИСК ===== */
.search-section { margin-bottom: 20px; position: relative; }
.search-form { display: flex; gap: 8px; }
.search-input { flex: 1; padding: 14px 16px; border: 1px solid #e9ecef; border-radius: 12px; font-size: 1rem; background: white; }
.search-input:focus { outline: none; border-color: #007bff; }
.search-btn { padding: 14px 20px; background: #007bff; color: white; border: none; border-radius: 12px; cursor: pointer; }
.search-results { position: absolute; top: 100%; left: 0; right: 0; background: white; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); max-height: 400px; overflow-y: auto; display: none; z-index: 100; }
.search-result-item { display: flex; gap: 12px; padding: 12px 15px; text-decoration: none; color: inherit; border-bottom: 1px solid #f0f0f0; }
.search-result-item:hover { background: #f8f9fa; }
.search-result-image { width: 50px; height: 50px; border-radius: 8px; overflow: hidden; background: #f8f9fa; display: flex; align-items: center; justify-content: center; }
.search-result-image img { width: 100%; height: 100%; object-fit: cover; }
.search-result-name { font-weight: 500; }
.search-result-price { color: #28a745; font-weight: bold; }

/* ===== КАРТОЧКИ ТОВАРОВ ===== */
.section-title { font-size: 1.3rem; font-weight: bold; margin-bottom: 15px; color: #343a40; }
.products-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
.product-card { background: white; border-radius: 16px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.05); position: relative; }
.product-image { width: 100%; aspect-ratio: 1; background: #f8f9fa; display: flex; align-items: center; justify-content: center; }
.product-image img { width: 100%; height: 100%; object-fit: cover; }
.product-image .no-image { font-size: 2.5rem; color: #6c757d; }
.new-badge { position: absolute; top: 10px; left: 10px; background: #ffc107; color: #856404; padding: 4px 8px; border-radius: 20px; font-size: 0.7rem; font-weight: 600; z-index: 1; }
.product-info { padding: 12px; }
.product-name { font-weight: 500; margin-bottom: 8px; }
.product-name a { color: #343a40; text-decoration: none; }
.product-price { font-size: 1.2rem; font-weight: bold; color: #28a745; margin-bottom: 8px; }
.btn-buy { width: 100%; padding: 10px; background: #28a745; color: white; border: none; border-radius: 10px; cursor: pointer; font-weight: 500; }

/* ===== СТРАНИЦА ТОВАРА ===== */
.gallery { background: white; }
.main-image { width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; background: white; }
.main-image img { width: 100%; height: 100%; object-fit: contain; }
.thumbnails { display: flex; gap: 8px; padding: 15px; overflow-x: auto; }
.thumbnail { width: 70px; height: 70px; border-radius: 10px; overflow: hidden; border: 2px solid transparent; cursor: pointer; flex-shrink: 0; }
.thumbnail.active { border-color: #007bff; }
.thumbnail img { width: 100%; height: 100%; object-fit: cover; }
.product-content { padding: 20px; background: white; margin-top: 10px; border-radius: 20px 20px 0 0; }
.product-category { color: #6c757d; margin-bottom: 8px; }
.product-category a { color: #6c757d; text-decoration: none; }
h1 { font-size: 1.6rem; margin-bottom: 10px; color: #343a40; }
.price { font-size: 2rem; font-weight: bold; color: #28a745; margin: 20px 0; }
.stock { display: inline-block; padding: 6px 16px; background: #d4edda; color: #155724; border-radius: 20px; }
.description { margin: 20px 0; line-height: 1.6; color: #495057; }

/* ===== СЕКЦИЯ ПОКУПКИ ===== */
.buy-section { position: fixed; bottom: 0; left: 0; right: 0; background: white; padding: 15px 20px; box-shadow: 0 -2px 10px rgba(0,0,0,0.05); max-width: 800px; margin: 0 auto; display: flex; gap: 10px; }
.qty-control { display: flex; align-items: center; gap: 8px; background: #f8f9fa; padding: 5px; border-radius: 12px; }
.qty-btn { width: 40px; height: 40px; border: none; background: white; border-radius: 10px; font-size: 1.2rem; cursor: pointer; }
.qty-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.qty-input { width: 50px; text-align: center; border: none; background: transparent; font-size: 1.1rem; }
.btn-cart { flex: 1; padding: 16px; background: #28a745; color: white; border: none; border-radius: 12px; font-size: 1.1rem; cursor: pointer; }

/* ===== КОРЗИНА ===== */
.cart-messages { margin-bottom: 15px; }
.cart-message { padding: 12px 15px; border-radius: 12px; margin-bottom: 10px; font-size: 0.9rem; }
.cart-message.error { background: #f8d7da; color: #721c24; border-left: 4px solid #dc3545; }
.cart-message.warning { background: #fff3cd; color: #856404; border-left: 4px solid #ffc107; }
.cart-items { display: flex; flex-direction: column; gap: 12px; }
.cart-item { display: flex; gap: 15px; padding: 15px; background: white; border-radius: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.cart-item-image { width: 80px; height: 80px; border-radius: 12px; overflow: hidden; background: #f8f9fa; flex-shrink: 0; }
.cart-item-image img { width: 100%; height: 100%; object-fit: cover; }
.cart-item-image .no-image { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 2rem; color: #6c757d; }
.cart-item-info { flex: 1; }
.cart-item-name { font-weight: 500; margin-bottom: 5px; }
.cart-item-name a { color: #343a40; text-decoration: none; }
.cart-item-price { font-size: 1.2rem; font-weight: bold; color: #28a745; margin-bottom: 10px; }
.cart-item-stock { font-size: 0.8rem; color: #6c757d; margin-bottom: 8px; }
.stock-low { color: #dc3545; }
.cart-item-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.quantity-control { display: flex; align-items: center; gap: 5px; }
.remove-btn { padding: 8px 12px; background: #f8d7da; color: #721c24; border: none; border-radius: 8px; cursor: pointer; }
.cart-empty { text-align: center; padding: 60px 20px; color: #6c757d; }
.cart-empty-icon { font-size: 4rem; margin-bottom: 20px; }
.cart-footer { position: fixed; bottom: 0; left: 0; right: 0; background: white; padding: 20px; box-shadow: 0 -2px 10px rgba(0,0,0,0.05); max-width: 800px; margin: 0 auto; }
.cart-total { display: flex; justify-content: space-between; font-size: 1.3rem; font-weight: bold; margin-bottom: 15px; }
.checkout-form input { width: 100%; padding: 14px; border: 1px solid #ddd; border-radius: 12px; margin-bottom: 10px; font-size: 1rem; }
.checkout-btn { display: block; width: 100%; padding: 18px; background: #28a745; color: white; border: none; border-radius: 12px; font-size: 1.2rem; font-weight: bold; cursor: pointer; text-decoration: none; text-align: center; }
.continue-link { display: block; text-align: center; margin-top: 15px; color: #007bff; text-decoration: none; }

/* ===== ПАГИНАЦИЯ ===== */
.pagination { display: flex; justify-content: center; gap: 5px; margin-top: 30px; }
.page-link { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: white; border-radius: 10px; text-decoration: none; color: #343a40; }
.page-link.active { background: #007bff; color: white; }

/* ===== ПУСТЫЕ СООБЩЕНИЯ ===== */
.empty-message { text-align: center; padding: 60px; color: #6c757d; background: white; border-radius: 16px; }

/* ===== ТОСТ УВЕДОМЛЕНИЯ ===== */
.toast { position: fixed; bottom: 100px; left: 20px; right: 20px; background: #28a745; color: white; padding: 15px; border-radius: 12px; text-align: center; max-width: 400px; margin: 0 auto; display: none; z-index: 1000; animation: slideUp 0.3s; }
@keyframes slideUp { from { transform: translateY(100px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ===== СТРАНИЦА УСПЕШНОГО ЗАКАЗА ===== */
.success-container { max-width: 500px; margin: 20px auto; background: white; border-radius: 24px; padding: 40px 30px; text-align: center; box-shadow: 0 4px 20px rgba(0,0,0,0.1); }
.success-icon { font-size: 5rem; margin-bottom: 20px; }
.success-title { font-size: 1.8rem; color: #28a745; margin-bottom: 15px; }
.order-number { font-size: 2.2rem; font-weight: bold; color: #343a40; background: #f8f9fa; padding: 15px; border-radius: 16px; margin: 25px 0; letter-spacing: 2px; }
.order-message { color: #6c757d; margin-bottom: 20px; line-height: 1.6; }
.warning-message { background: #fff3cd; color: #856404; padding: 15px; border-radius: 12px; margin: 20px 0; font-size: 0.95rem; }
.btn { display: inline-block; padding: 14px 30px; background: #007bff; color: white; text-decoration: none; border-radius: 12px; font-weight: 500; }
.shop-info { margin-top: 30px; padding-top: 20px; border-top: 1px solid #eee; color: #6c757d; font-size: 0.9rem; }

/* ===== АДАПТИВНОСТЬ ===== */
@media (max-width: 768px) {
    .shop-layout { display: block; }
    .sidebar { position: fixed; left: -280px; bottom: 0; z-index: 1000; transition: left 0.3s; box-shadow: 2px 0 10px rgba(0,0,0,0.1); }
    .sidebar.open { left: 0; }
    .sidebar-overlay.show { display: block; }
    .close-sidebar { display: block; }
    .mobile-header { display: flex; }
    .products-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .main-content { padding: 10px; }
    .cart-item { flex-wrap: wrap; }
    .cart-item-image { width: 100%; height: 180px; }
    .cart-item-info { width: 100%; }
}

@media (max-width: 480px) {
    .products-grid { grid-template-columns: 1fr; }
}

@media (min-width: 800px) {
    .container { box-shadow: 0 0 20px rgba(0,0,0,0.05); }
}