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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--tg-theme-bg-color, #fff);
    color: var(--tg-theme-text-color, #222);
    padding: 0;
    margin: 0;
    min-height: 100vh;
}

.header {
    background: linear-gradient(135deg, #392f5e 0%, #483B77 100%);
    color: white;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.logo img {
    width: 40px;
    height: 40px;
    margin-right: 10px;
}

.header h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

.header p {
    opacity: 0.9;
    font-size: 14px;
}

.container {
    padding: 20px;
    max-width: 100%;
    margin: 0 auto;
    /* background: #8A94CC; */
}

.categories {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    margin-bottom: 25px;
    padding: 5px 0px 10px 0px;
}

.category-btn {
    flex-shrink: 0;
    background: var(--tg-theme-button-color, #007AFF);
    color: var(--tg-theme-button-text-color, white);
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.category-btn:hover, .category-btn.active {
    background: var(--tg-theme-button-color, #0056CC);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    /* grid-auto-rows: 1fr; */
    gap: 20px;
    margin-bottom: 100px;
}

.product-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--tg-theme-secondary-bg-color, #f8f9fa);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.product-image {
    height: 180px;
    background: linear-gradient(45deg, #483B77, #6250a3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: white;
    overflow: hidden;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}

.product-info {
    padding: 9px 16px;
}

.product-name {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--tg-theme-text-color, #222);
}

.product-description {
    color: var(--tg-theme-hint-color, #666);
    font-size: 14px;
    margin-bottom: 15px;
    line-height: 1.4;
}

.product-price {
    font-size: 20px;
    font-weight: 700;
    color: #8B4513;
    margin-bottom: 15px;
}

.add-to-cart-btn {
    width: 100%;
    background: var(--tg-theme-button-color, #007AFF);
    color: var(--tg-theme-button-text-color, white);
    border: none;
    padding: 12px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
}

.add-to-cart-btn:hover {
    background: var(--tg-theme-button-color, #0056CC);
    transform: translateY(-1px);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--tg-theme-bg-color, white);
    margin: 10% auto;
    padding: 0;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-header {
    padding: 25px 25px 15px;
    border-bottom: 1px solid var(--tg-theme-hint-color, #eee);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--tg-theme-text-color, #222);
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--tg-theme-hint-color, #666);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 25px;
}

.option-group {
    margin-bottom: 25px;
}

.option-group h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--tg-theme-text-color, #222);
    font-weight: 600;
}

.option-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--tg-theme-secondary-bg-color, #f8f9fa);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.option-item:hover {
    background: var(--tg-theme-button-color, #007AFF);
    color: white;
}

.option-item.selected {
    border-color: var(--tg-theme-button-color, #007AFF);
    background: rgba(0, 122, 255, 0.1);
}

.option-info {
    flex: 1;
}

.option-name {
    font-weight: 600;
    margin-bottom: 2px;
}

.option-price {
    font-size: 14px;
    color: #8B4513;
    font-weight: 600;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 25px 0;
    justify-content: center;
}

.quantity-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--tg-theme-button-color, #007AFF);
    color: white;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quantity-btn:hover {
    transform: scale(1.1);
}

.quantity-display {
    font-size: 20px;
    font-weight: 700;
    min-width: 40px;
    text-align: center;
    color: var(--tg-theme-text-color, #222);
}

.total-price {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    color: #8B4513;
    margin: 20px 0;
}

.cart-info {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--tg-theme-bg-color, white);
    padding: 15px 20px;
    border-top: 1px solid var(--tg-theme-hint-color, #eee);
    display: none;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
}

.cart-info.show {
    display: block;
}

.cart-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.checkout-btn {
    width: 100%;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.checkout-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.3);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--tg-theme-hint-color, #666);
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 10px;
    color: var(--tg-theme-text-color, #222);
}

@media (max-width: 600px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .modal-content {
        margin: 5% auto;
        width: 95%;
        max-height: 90vh;
    }
}