:root {
    --tg-theme-bg-color: #ffffff;
    --tg-theme-secondary-bg-color: #f5f5f5;
    --tg-theme-text-color: #000000;
    --tg-theme-hint-color: #999999;
    --tg-theme-link-color: #2481cc;
    --tg-theme-button-color: #2481cc;
    --tg-theme-button-text-color: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    -webkit-font-smoothing: antialiased;
}

#app {
    min-height: 100vh;
    padding-bottom: 100px;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    background: var(--tg-theme-bg-color);
    z-index: 10;
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.header h1 {
    font-size: 24px;
    margin-bottom: 12px;
}

.back-button {
    background: none;
    border: none;
    color: var(--tg-theme-link-color);
    font-size: 16px;
    cursor: pointer;
    padding: 8px 0;
    margin-bottom: 8px;
}

/* Categories */
.categories {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
}

.categories::-webkit-scrollbar {
    display: none;
}

.category-btn {
    flex-shrink: 0;
    padding: 8px 16px;
    border-radius: 20px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.category-btn.active {
    background-color: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
}

.category-btn:not(.active) {
    background-color: var(--tg-theme-secondary-bg-color, #f0f0f0);
    color: var(--tg-theme-text-color, #333);
}

/* ═════════════════════════════════════════════════════════════
   PRODUCTS GRID - MODERN DESIGN v2.0
   Компактный, красивый, мобильный-дружественный дизайн
   ═════════════════════════════════════════════════════════════ */

/* Grid Responsive */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    padding: 16px;
}

@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 8px;
        padding: 12px;
    }
}

@media (min-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

/* Card */
.card {
    background: var(--tg-theme-secondary-bg-color, #ffffff);
    color: var(--tg-theme-text-color);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 16px;
}

/* Product Card - Modern Design */
.product-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    color: var(--tg-theme-text-color);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    padding: 12px;
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: all 0.2s ease-in-out;
    position: relative;
}

.product-card:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.product-card:active {
    transform: translateY(0);
}

.product-card.disabled {
    opacity: 0.6;
    pointer-events: none;
}

/* Product Header */
.product-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
    flex: 1;
}

.product-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.product-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 0;
    line-height: 1.3;
    word-break: break-word;
}

.product-weight {
    font-size: 12px;
    color: #9ca3af;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Product Price */
.product-price {
    font-size: 20px;
    font-weight: 700;
    color: var(--tg-theme-button-color, #2481cc);
    margin: 8px 0;
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.product-price-value {
    font-size: 20px;
}

.product-price-currency {
    font-size: 14px;
    font-weight: 600;
    opacity: 0.9;
}

/* Product Availability */
.product-availability {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    margin: 8px 0;
}

.product-available {
    color: #6b7280;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.product-available::before {
    content: '✓';
    color: #31a24c;
    font-weight: bold;
    font-size: 12px;
}

.product-stock-low {
    color: #f59e0b;
}

.product-stock-low::before {
    content: '⚠️';
}

.product-unavailable {
    color: #ef4444;
    font-weight: 600;
}

.product-unavailable::before {
    content: '✕';
    color: #ef4444;
    font-weight: bold;
}

.stock-badge {
    display: inline-block;
    background-color: #fef3c7;
    color: #92400e;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.product-in-cart {
    background-color: #dbeafe;
    color: #1e40af;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
}

.product-in-cart::before {
    content: '✓';
}

/* Product Footer */
.product-footer {
    display: flex;
    gap: 4px;
    margin-top: auto;
}

/* Buttons */
.btn-primary {
    background-color: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-primary:active {
    opacity: 0.8;
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #f0f0f0;
    color: #333;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.btn-large {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    margin: 16px 0;
}

/* Cart Button */
.cart-button {
    position: fixed;
    bottom: 16px;
    left: 16px;
    right: 16px;
    background-color: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    padding: 16px;
    cursor: pointer;
    z-index: 100;
}

.cart-content {
    display: flex;
    justify-between;
    align-items: center;
}

.cart-title {
    font-weight: 600;
    font-size: 16px;
}

.cart-count {
    margin-left: 8px;
    font-size: 14px;
    opacity: 0.9;
}

.cart-total {
    font-weight: bold;
    font-size: 18px;
}

/* Cart Items */
.cart-items {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cart-item {
    background: var(--tg-theme-secondary-bg-color, #ffffff);
    color: var(--tg-theme-text-color);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 16px;
}

.cart-item-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 12px;
}

.cart-item-info h3 {
    font-size: 16px;
    margin-bottom: 4px;
}

.cart-item-weight {
    font-size: 14px;
    color: var(--tg-theme-hint-color);
}

.cart-item-remove {
    background: none;
    border: none;
    color: #ff3b30;
    font-size: 14px;
    cursor: pointer;
}

.cart-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.quantity-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quantity-btn.minus {
    background-color: var(--tg-theme-secondary-bg-color, #f0f0f0);
    color: var(--tg-theme-text-color, #333);
}

.quantity-btn.plus {
    background-color: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
}

.quantity-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.quantity-value {
    font-weight: 600;
    font-size: 16px;
    min-width: 32px;
    text-align: center;
}

.cart-item-price {
    font-weight: bold;
    font-size: 16px;
}


/* Form */
.form-card {
    margin: 16px;
}

.form-label {
    display: block;
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--tg-theme-hint-color);
}

.form-input {
    width: 100%;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    font-size: 16px;
    background: var(--tg-theme-secondary-bg-color, #ffffff);
    color: var(--tg-theme-text-color);
}

.form-input:focus {
    outline: none;
    border-color: var(--tg-theme-button-color);
    box-shadow: 0 0 0 2px rgba(36, 129, 204, 0.15);
}

.form-hint {
    margin-top: 6px;
    font-size: 12px;
    color: var(--tg-theme-hint-color);
}


/* Total Card */
.total-card {
    margin: 16px;
    background-color: var(--tg-theme-secondary-bg-color, #f9f9f9);
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.total-label {
    font-size: 18px;
    font-weight: 600;
}

.total-amount {
    font-size: 24px;
    font-weight: bold;
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.loading-icon {
    font-size: 48px;
    margin-bottom: 16px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Error */
.error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 16px;
    text-align: center;
}

.error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.error-message {
    background-color: #ffebee;
    border: 1px solid: #ef5350;
    color: #c62828;
    padding: 12px;
    border-radius: 8px;
    margin: 16px;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 16px;
    text-align: center;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state h2 {
    margin-bottom: 24px;
}

/* Closed Screen */
.closed-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 32px;
    text-align: center;
}

.closed-icon {
    font-size: 64px;
    margin-bottom: 24px;
}

.closed-container h1 {
    font-size: 24px;
    margin-bottom: 16px;
}

.closed-container p {
    color: var(--tg-theme-hint-color);
    white-space: pre-line;
    line-height: 1.5;
}

/* Success Screen */
.success-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 32px;
    text-align: center;
}

.success-icon {
    font-size: 64px;
    margin-bottom: 24px;
}

.success-container h1 {
    font-size: 24px;
    margin-bottom: 24px;
}

.order-details {
    width: 100%;
    max-width: 400px;
    text-align: left;
    margin-bottom: 24px;
}

.order-detail {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.order-detail:last-child {
    margin-bottom: 0;
}

.detail-label {
    color: var(--tg-theme-hint-color);
}

.detail-value {
    font-weight: bold;
}

.success-message {
    color: var(--tg-theme-hint-color);
    line-height: 1.5;
    margin-bottom: 24px;
    max-width: 400px;
}

.hint-text {
    text-align: center;
    color: var(--tg-theme-hint-color);
    font-size: 14px;
    margin: 16px;
}
