:root {
    --bg-color: var(--tg-theme-bg-color, #ffffff);
    --text-color: var(--tg-theme-text-color, #111111);
    --secondary-bg: var(--tg-theme-secondary-bg-color, #f4f4f5);
    --button-color: var(--tg-theme-button-color, #2481cc);
    --button-text: var(--tg-theme-button-text-color, #ffffff);
    --border-radius-sm: 6px;
    --border-radius-md: 10px;
    --border-radius-lg: 14px;
}

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

body {
    background-color: var(--secondary-bg);
    color: var(--text-color);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 80px;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    position: relative;
    min-height: 100vh;
}

.header {
    background-color: var(--bg-color);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 10px 12px;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.header .title {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
    background: linear-gradient(90deg, var(--button-color), #4facfe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 10px;
    width: 16px;
    height: 16px;
    color: #8e8e93;
}

#searchInput {
    width: 100%;
    padding: 9px 10px 9px 34px;
    border: 1px solid transparent;
    border-radius: var(--border-radius-md);
    background: var(--secondary-bg);
    color: var(--text-color);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
}

#searchInput:focus {
    background: var(--bg-color);
    border: 1px solid var(--button-color);
    box-shadow: 0 2px 8px rgba(36, 129, 204, 0.15);
}

/* Product list */
.product-list {
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Folder card (home screen) */
.folder-card {
    background: var(--bg-color);
    border-radius: var(--border-radius-md);
    padding: 10px 14px;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.04);
    transition: transform 0.15s, box-shadow 0.15s;
    animation: slideUpFade 0.3s ease both;
}

.folder-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}


@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Compact product card — name + qty on ONE row */
.product-card {
    background: var(--bg-color);
    border-radius: var(--border-radius-md);
    padding: 9px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    border: 1px solid rgba(0,0,0,0.04);
    transition: transform 0.15s;
    animation: slideUpFade 0.3s ease both;
}

.product-card:active { transform: scale(0.99); }

.product-info {
    flex: 1;
    min-width: 0;
}

.product-name {
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.35;
    word-break: break-word;
}

.product-path {
    font-size: 10.5px;
    color: #aaa;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Qty controls */
.qty-controls {
    display: flex;
    align-items: center;
    gap: 3px;
    background: var(--secondary-bg);
    border-radius: var(--border-radius-sm);
    padding: 3px;
    flex-shrink: 0;
}

.qty-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--bg-color);
    border-radius: 5px;
    color: var(--button-color);
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s;
}

.qty-btn:active { transform: scale(0.92); }

.qty-input {
    width: 38px;
    height: 28px;
    text-align: center;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 5px;
    background: var(--bg-color);
    color: var(--text-color);
    font-weight: 700;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    -moz-appearance: textfield;
}
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.qty-input:focus { border-color: var(--button-color); }

/* Category header */
.category-header {
    padding: 10px 4px 3px;
}

/* Floating Cart */
.floating-cart {
    position: fixed;
    bottom: 16px;
    left: 12px;
    right: 12px;
    max-width: 576px;
    margin: 0 auto;
    background: var(--button-color);
    color: var(--button-text);
    border: none;
    border-radius: var(--border-radius-lg);
    padding: 13px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(36, 129, 204, 0.4);
    cursor: pointer;
    transform: translateY(100px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 50;
}

.floating-cart.visible { transform: translateY(0); }

.cart-icon {
    position: relative;
    width: 22px;
    height: 22px;
}

.badge {
    position: absolute;
    top: -5px;
    right: -7px;
    background: #ff3b30;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    line-height: 1.3;
}

/* Cart View */
.cart-view {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--secondary-bg);
    z-index: 100;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.cart-view.active { transform: translateX(0); }

.cart-view .header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cart-view .title { margin-bottom: 0; }

.back-btn {
    background: transparent;
    border: none;
    color: var(--button-color);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.cart-list {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    flex: 1;
}

.cart-item {
    background: var(--bg-color);
    padding: 10px 12px;
    border-radius: var(--border-radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.cart-item-info { flex: 1; min-width: 0; padding-right: 8px; }

.cart-item-name {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.35;
    word-break: break-word;
}

.cart-footer {
    padding: 12px;
    background: var(--bg-color);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.primary-btn {
    width: 100%;
    background: var(--button-color);
    color: var(--button-text);
    border: none;
    padding: 14px;
    border-radius: var(--border-radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.loader {
    text-align: center;
    padding: 40px;
    color: #8e8e93;
    font-size: 14px;
}
