/* style.css */
:root {
    --tg-bg-color: var(--tg-theme-bg-color, #f4f4f8);
    --tg-text-color: var(--tg-theme-text-color, #1c1c1d);
    --tg-hint-color: var(--tg-theme-hint-color, #99989d);
    --tg-link-color: var(--tg-theme-link-color, #2ea6ff);
    --tg-button-color: var(--tg-theme-button-color, #2ea6ff);
    --tg-button-text-color: var(--tg-theme-button-text-color, #ffffff);
    --tg-secondary-bg-color: var(--tg-theme-secondary-bg-color, #ffffff);
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--tg-bg-color);
    color: var(--tg-text-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app-root {
    padding: 15px;
}

/* Стили для страниц */
.page {
    display: flex;
    flex-direction: column;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

header h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
}

.back-button {
    background: none;
    border: 1px solid var(--tg-hint-color);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    color: var(--tg-text-color);
    cursor: pointer;
}

/* Карточка категории */
.list-item {
    background-color: var(--tg-secondary-bg-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 10px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 500;
    transition: transform 0.2s;
}
.list-item:active {
    transform: scale(0.98);
}

/* Сетка товаров */
.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

/* Карточка товара */
.product-card {
    background-color: var(--tg-secondary-bg-color);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.product-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    cursor: pointer;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-info {
    padding: 10px;
}

.product-info h3 {
    font-size: 14px;
    font-weight: 500;
    margin: 0 0 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-info .price {
    font-size: 16px;
    font-weight: 700;
}

.product-actions {
    padding: 0 10px 10px;
}

/* Кнопки и контролы */
.add-to-cart-btn, .checkout-btn {
    width: 100%;
    padding: 12px;
    background-color: var(--tg-button-color);
    color: var(--tg-button-text-color);
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}
.add-to-cart-btn:disabled, .checkout-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.quantity-control {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #eef1f5;
    border-radius: 8px;
}
.quantity-control button {
    background: none;
    border: none;
    color: var(--tg-link-color);
    font-size: 20px;
    font-weight: 500;
    width: 40px;
    height: 44px;
    cursor: pointer;
}
.quantity-control span {
    font-size: 16px;
    font-weight: 600;
}

/* Корзина */
.cart-icon {
    position: relative;
    cursor: pointer;
    font-size: 24px;
}
.cart-counter {
    position: absolute;
    top: -5px;
    right: -10px;
    background-color: var(--tg-link-color);
    color: white;
    font-size: 12px;
    font-weight: bold;
    border-radius: 50%;
    padding: 2px 6px;
}

.cart-item {
    display: flex;
    align-items: center;
    padding: 10px;
    background-color: var(--tg-secondary-bg-color);
    border-radius: 12px;
    margin-bottom: 10px;
}
.cart-item img {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    margin-right: 15px;
}
.cart-item-details { flex-grow: 1; display: flex; flex-direction: column; }
.cart-item-name { font-weight: 600; }
.cart-item-price-per-unit { font-size: 12px; color: var(--tg-hint-color); }
.cart-item-total-price { font-weight: 700; margin-top: 4px; }
.cart-item-actions { display: flex; flex-direction: column; align-items: flex-end; }
.cart-item-actions .quantity-control { background: none; }
.delete-btn { font-size: 16px; color: var(--tg-hint-color); background: none; border: none; cursor: pointer; margin-top: 5px; }

.cart-summary { padding: 10px; }
.summary-row { display: flex; justify-content: space-between; margin-bottom: 5px; }
.summary-row.total { font-size: 18px; font-weight: 700; margin-top: 10px; }

#page-cart footer { padding-top: 20px; }
.continue-shopping {
    width: 100%;
    padding: 15px;
    background: none;
    border: 1px solid var(--tg-hint-color);
    color: var(--tg-text-color);
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
}

/* Модальное окно */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    z-index: 1000;
}
.modal-content {
    background-color: var(--tg-secondary-bg-color);
    width: 100%;
    border-radius: 15px 15px 0 0;
    padding: 15px;
    box-sizing: border-box;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header { text-align: right; }
.close-modal-btn { background: none; border: none; font-size: 24px; cursor: pointer; }
.modal-body img { width: 100%; border-radius: 12px; }
.modal-body h2 { font-size: 22px; }
.modal-body .price { font-size: 20px; font-weight: 700; }
.modal-body .description { font-size: 16px; color: var(--tg-hint-color); line-height: 1.5; }
.modal-footer { margin-top: 20px; }