:root {
    --primary: #FFA726;
    --surface: #FFFFFF;
    --background: #FFF9F2;
    --on-surface: #2D2D2D;
    --on-surface-secondary: #666666;
    --border: rgba(0, 0, 0, 0.08);
    --error: #D32F2F;

    --elevation-1: 0 2px 8px rgba(0, 0, 0, 0.06);
    --elevation-2: 0 4px 12px rgba(0, 0, 0, 0.1);

    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --body-font-size: 15px;

    --spacing-xs: 8px;
    --spacing-sm: 12px;
    --spacing-md: 16px;
    --spacing-lg: 24px;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    overflow-x: hidden; /* Запрещаем горизонтальную прокрутку страницы */
    touch-action: pan-y; /* Разрешаем только вертикальный скролл для всей страницы */
    position: relative;
}

body {
    font-family: var(--font-family);
    background: var(--background);
    color: var(--on-surface);
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent; /* Removes tap highlight on mobile */
}

.container { /* Added container for max-width */
    max-width: 1200px;
    margin: 0 auto;
}

.app-bar {
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1000;
    padding: 0 var(--spacing-md);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

.app-bar__content {
    display: flex;
    align-items: center;
    height: 56px;
    margin: 0 auto;
}

.app-bar__logo {
    font-size: 28px;
    margin-right: var(--spacing-sm);
}

.app-bar__title {
    font-size: 20px;
    font-weight: 700;
}

.tabs-container {
    background: var(--surface);
    z-index: 999;
    border-bottom: 1px solid var(--border);
    width: 100%;
    overflow: hidden;
}

.tabs-container.scrolled {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.tabs {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs) var(--spacing-md);
    overflow-x: auto;
    scrollbar-width: none;
    margin: 0 auto;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    padding: var(--spacing-xs) var(--spacing-md);
    border: none;
    background: rgba(0, 0, 0, 0.05);
    color: var(--on-surface-secondary);
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    white-space: nowrap;
}

.tab:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--primary);
}

.tab.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 167, 38, 0.3);
    font-weight: 600;
    position: relative;
    border: 1px solid rgba(255, 167, 38, 0.5);
    transition: background-color 0.3s ease;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); /* Responsive grid */
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    /* max-width: 1200px;  Removed, handled by .container*/
    margin: 0 auto;
}

.product-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: box-shadow 0.2s ease; /* Simplified transition */
    border: 1px solid var(--border);
    display: flex;          /* Flexbox for vertical layout */
    flex-direction: column; /* Stack children vertically */
}

.product-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    /* transform: translateY(-2px);  Removed for better mobile experience*/
}

/* No need for :active state, :hover is enough for touch devices */

.product-image-container {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #f8f8f8;
    position: relative;
    overflow: hidden;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-content {
    padding: var(--spacing-sm);
    display: flex;         /* Flexbox for inner content */
    flex-direction: column;/* Stack title, description, etc. */
    flex-grow: 1;          /* Allow content to fill available space */
}

.product-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
    line-height: 1.3;
}

.description-container {
    position: relative;
    margin-bottom: var(--spacing-sm);
    flex-grow: 1;      /* Allow description to take available space */
}

.product-description {
    font-size: 13px;
    color: var(--on-surface-secondary);
    height: 36px;        /* Initial height for 2 lines */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
}

.product-description:after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1.2em;
    background: linear-gradient(to bottom, transparent, var(--surface));
}

.product-card.expanded .product-description {
    height: auto;       /* Allow full height on expand */
    -webkit-line-clamp: unset;
}

.product-card.expanded .product-description:after {
    opacity: 0;
}

.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-xs);
    min-height: 40px;
    margin-top: auto;      /* Push footer to the bottom */
}

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

.quantity-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.quantity-btn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: var(--spacing-xs);
    cursor: pointer;
    transition: background 0.3s ease;
    width: 30px;  /* Fixed width for buttons */
    height: 30px; /* Fixed height for buttons */
    display: flex; /* Center the +/- icons */
    align-items: center;
    justify-content: center;
}


.quantity-btn:hover {
    background: darkorange;
}

.error-message {
    text-align: center;
    padding: var(--spacing-md);
    background: rgba(255, 0, 0, 0.1);
    border-radius: var(--radius-md);
    color: var(--error);
}

.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: rgba(255, 255, 255, 0.8);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
}

.loading::before {
    content: "Загрузка...";
    font-size: 24px;
    color: var(--primary);
}

/* ... (previous CSS, up to the carousel styles) ... */

/* Carousel Styles */
.carousel-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
}

.carousel-wrapper.hidden {
    display: none;
}

.carousel-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.5s ease;
    display: flex;
}

.carousel-item.active {
    opacity: 1;
    z-index: 2;
}

.carousel-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.carousel-arrow-controls {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transform: translateY(-50%);
    z-index: 3;
    padding: 0 var(--spacing-xs); /* Keep padding */
}

.carousel-prev,
.carousel-next {
    /* --- KEY STYLING CHANGES --- */
    background: rgba(255, 255, 255, 0.6); /* Lighter background */
    border: 1px solid rgba(0, 0, 0, 0.1);   /* Subtle border */
    padding: 0;          /* Remove padding (size controlled by width/height) */
    cursor: pointer;
    font-size: 20px;     /* Slightly smaller font */
    color: var(--on-surface);
    border-radius: 50%;
    width: 30px;         /* Smaller size */
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4;
    transition: background-color 0.3s ease, opacity 0.3s ease; /* Smooth transitions */
    opacity: 0.8;       /* Slightly transparent */
    margin: 0 -15px;   /* Negative margin to move arrows outwards */
}

.carousel-prev:hover,
.carousel-next:hover {
    background-color: rgba(255, 255, 255, 0.9); /* Slightly more opaque on hover */
    opacity: 1;         /* Fully opaque on hover */
}

.carousel-dots-container {
    position: absolute;
    bottom: var(--spacing-xs);
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    z-index: 3;
}

.carousel-dots {
    display: flex;
    gap: var(--spacing-xs);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.dot.active {
    background: var(--primary);
}

/* ... (rest of the CSS) ... */

/* --- KEY CHANGES END HERE --- */



/* Swipe animations */
.tab.active {
    /* animation: tab-active 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28); Removed for better mobile behavior */
}

/* @keyframes tab-active {  Removed keyframes for better mobile experience
    0% {
        transform: translateY(0) scale(0.95);
        opacity: 0.7;
    }

    50% {
        transform: translateY(-2px) scale(1.1);
    }

    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
} */

/* Improved tab transitions */
.tabs-container {
    scroll-behavior: smooth;
}

.tab {
    transition:
        /* transform 0.3s ease, Removed for better mobile experience*/
        background 0.3s ease,
        color 0.3s ease;
}

/* Active tab indicator */
.tabs-container::after {
    content: none;
}

.active-tab-indicator {
    display: none;
}

/* Animation for quantity update */
.quantity-controls span.updated {
    animation: quantity-update 0.2s ease;
}

@keyframes quantity-update {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* Навигация по вкладкам */
.tabs-container {
    position: relative;
}

.tabs-navigation {
    display: none;
}

.tab-nav-btn {
    display: none;
}

/* Адаптация под Telegram Mini Apps */
.telegram-app .tabs {
    padding: var(--spacing-xs) var(--spacing-md); /* Уменьшаем отступы */
    margin-bottom: 0; /* Убираем нижний отступ */
    scroll-behavior: smooth;
}

.telegram-app .tab {
    font-size: 15px;
    padding: var(--spacing-xs) var(--spacing-md); /* Уменьшаем отступы */
    min-width: auto;
    text-align: center;
    margin: 0 1px;
    border-radius: var(--radius-md);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.telegram-app .tab.active {
    position: relative;
    box-shadow: 0 3px 10px rgba(255, 167, 38, 0.25);
}

/* Удаляем подсветку линией под активной вкладкой */
.telegram-app .tab.active::after {
    display: none;
}

/* Улучшения для мобильных устройств */
@media (max-width: 768px) {
    .tabs-container {
        overflow: hidden;
    }
    
    .tabs {
        scroll-behavior: smooth;
        padding: var(--spacing-xs) var(--spacing-xs); /* Уменьшаем отступы */
    }
    
    .tab {
        min-width: auto;
        flex-shrink: 0;
    }
}

/* Улучшения для touch-интерфейса */
.tab:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

/* Улучшения производительности */
.product-card, .tab, .tabs {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Animation для подтверждения действий */
@keyframes confirm-action {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.tab.confirm-action {
    animation: confirm-action 0.3s ease;
}
