@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

:root {
    --bg-color: var(--tg-theme-bg-color, #f3f4f6);
    --text-color: var(--tg-theme-text-color, #111827);
    --button-color: var(--tg-theme-button-color, #3b82f6);
    --button-text-color: var(--tg-theme-button-text-color, #ffffff);
    --hint-color: var(--tg-theme-hint-color, #6b7280);
    --card-bg: rgba(255, 255, 255, 0.7);
    --card-border: rgba(255, 255, 255, 0.5);
    --shadow: 0 4px 30px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-border: rgba(255, 255, 255, 0.1);
    --shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    padding: 16px;
    padding-bottom: 80px; /* space for main button */
    transition: background-color 0.3s, color 0.3s;
}

.header {
    text-align: center;
    margin-bottom: 24px;
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--button-color), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* CATALOG STYLES */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}

.product-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 12px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.product-img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 12px;
    background: rgba(0,0,0,0.05);
}

.product-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    line-height: 1.2;
}

.product-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--button-color);
    margin-bottom: 4px;
}

.in-stock {
    font-size: 13px;
    color: var(--hint-color);
    margin-bottom: 12px;
    flex-grow: 1;
}

.add-btn {
    background: var(--button-color);
    color: var(--button-text-color);
    border: none;
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: opacity 0.2s, transform 0.1s;
}

.add-btn:active {
    opacity: 0.8;
    transform: scale(0.95);
}

.controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: rgba(0,0,0,0.05);
    border-radius: 12px;
    padding: 4px;
}
[data-theme="dark"] .controls {
    background: rgba(255,255,255,0.1);
}

.ctrl-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 18px;
    font-weight: bold;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}
.ctrl-btn:active {
    background: rgba(128,128,128,0.2);
}
.qty {
    font-weight: 600;
    font-size: 16px;
}

/* CART STYLES */
.section-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 16px;
    text-align: center;
}

.cart-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cart-item {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
}

.cart-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cart-item-name {
    font-weight: 600;
    font-size: 16px;
}

.cart-item-price {
    color: var(--button-color);
    font-weight: 700;
    font-size: 14px;
}

.cart-total {
    margin-top: 24px;
    font-size: 20px;
    font-weight: 700;
    text-align: right;
    border-top: 1px solid var(--card-border);
    padding-top: 16px;
}

/* MODAL STYLES */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-color);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    transition: opacity 0.3s ease;
}
.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    max-width: 400px;
    width: 100%;
}
.modal-content h2 {
    font-size: 20px;
    margin-bottom: 12px;
    text-align: center;
    color: var(--text-color);
}
.modal-content p {
    font-size: 14px;
    margin-bottom: 12px;
    color: var(--hint-color);
    line-height: 1.4;
}
.checkbox-container {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
    margin-top: 10px;
    font-size: 14px;
    color: var(--text-color);
    cursor: pointer;
}
.checkbox-container input {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    accent-color: var(--button-color);
}
.add-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
