/* --- PREMIUM B2B DESIGN SYSTEM --- */
:root { 
    --tg-bg: var(--tg-theme-bg-color, #f0f2f5); 
    --tg-card: var(--tg-theme-secondary-bg-color, #ffffff); 
    --tg-text: var(--tg-theme-text-color, #000000); 
    --tg-hint: var(--tg-theme-hint-color, #8e8e93);
    --tg-accent: var(--tg-theme-button-color, #007aff); 
    --tg-btn-text: var(--tg-theme-button-text-color, #ffffff);
    
    --red: #ff3b30;
    --green: #34c759;
    --icon-bg: rgba(142, 142, 147, 0.12);
    --radius: 12px;
    --header-height: 56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; outline: none; }

body { 
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    margin: 0; padding: 0; background: var(--tg-bg); color: var(--tg-text); 
    padding-bottom: 100px; overflow-x: hidden; -webkit-font-smoothing: antialiased;
}

/* HEADER */
.header-container { position: sticky; top: 0; z-index: 100; background: var(--tg-card); border-bottom: 1px solid rgba(0,0,0,0.05); }
.header { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; height: var(--header-height); padding: 0 8px; }
.title-text { font-weight: 700; font-size: 17px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; grid-column: 2; color: var(--tg-text); }

/* ПОИСК */
.search-bar { padding: 0 16px 12px 16px; display: none; background: var(--tg-card); }
.search-bar.visible { display: block; animation: slideDown 0.2s ease-out; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.search-input { width: 100%; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--tg-hint); background: var(--tg-bg); color: var(--tg-text); font-size: 16px; transition: all 0.2s; }
.search-input:focus { border-color: var(--tg-accent); }

/* СПИСКИ */
.list, .cart-list { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 12px 16px; }

/* ПАПКИ (iOS Style) */
.folder { background: var(--tg-card); padding: 12px 16px; border-radius: var(--radius); display: flex; align-items: center; gap: 16px; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,0.05); transition: background 0.1s; }
.folder:active { background: var(--tg-bg); transform: scale(0.99); }
.f-icon-box { width: 42px; height: 42px; background: var(--icon-bg); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }

/* Спец-стиль для иконки Шары */
.f-icon-box.sale { background: rgba(255, 59, 48, 0.15); border: 1px solid rgba(255, 59, 48, 0.3); }

/* 🔥 НОВИЙ VIP СТИЛЬ ДЛЯ "ЧАСТІ ЗАМОВЛЕННЯ" */
.f-icon-box.premium {
    background: linear-gradient(135deg, #FFD700 0%, #F5A623 100%);
    color: #fff;
    border: 1px solid rgba(255, 215, 0, 0.6);
    box-shadow: 0 4px 12px rgba(245, 166, 35, 0.35);
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.f-name { font-size: 17px; font-weight: 600; color: var(--tg-text); flex: 1; }
.f-arrow { color: var(--tg-hint); font-size: 18px; font-weight: 600; opacity: 0.5; }

/* КАРТОЧКА */
.card { background: var(--tg-card); border-radius: 14px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.04); display: flex; flex-direction: column; transform: translateZ(0); position: relative; border: 1.5px solid transparent; transition: all 0.2s; }
.card.active-in-cart { border-color: var(--green); background: rgba(52, 199, 89, 0.05); }
.img-box { height: 130px; background: #ffffff; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; padding: 10px; cursor: pointer; }
.img-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.info { padding: 10px; flex: 1; display: flex; flex-direction: column; }
.name { font-size: 13px; line-height: 1.35; height: 54px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; margin-bottom: 8px; color: var(--tg-text); font-weight: 500; }
.price-row { display: flex; justify-content: space-between; align-items: center; margin-top: auto; }
.price { font-weight: 700; font-size: 16px; color: var(--tg-text); }
.stock { font-size: 11px; color: var(--green); font-weight: 600; background: rgba(52, 199, 89, 0.1); padding: 2px 6px; border-radius: 4px; }

/* УПРАВЛЕНИЕ */
.qty-control { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; padding: 2px; }
.btn-qty { width: 36px; height: 36px; border: none; background: var(--tg-bg); border-radius: 8px; font-weight: bold; font-size: 20px; color: var(--tg-text); cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.1); display: flex; align-items: center; justify-content: center; }
.qty-input { flex: 1; width: 0; height: 36px; margin: 0 6px; border: 1px solid var(--tg-hint); border-radius: 8px; background: var(--tg-bg); color: var(--tg-text); text-align: center; font-size: 17px; font-weight: 700; -moz-appearance: textfield; }
.qty-input:focus { border-color: var(--tg-accent); background: var(--tg-card); outline: none; }
.btn-confirm { width: 36px; height: 36px; border: none; background: var(--green); border-radius: 8px; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.btn-buy { background: var(--tg-accent); color: var(--tg-btn-text); border: none; padding: 10px; border-radius: 10px; width: 100%; font-weight: 600; font-size: 14px; cursor: pointer; margin-top: 10px; height: 40px; transition: 0.1s; }
.btn-buy.in-cart { background: transparent; color: var(--green); border: 1.5px solid var(--green); }

/* ИКОНКИ */
.btn-icon { background: none; border: none; cursor: pointer; padding: 0; color: var(--tg-accent); display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; }
.btn-icon svg { width: 24px; height: 24px; fill: currentColor; }
.btn-back { background: none; border: none; cursor: pointer; padding: 0; display: flex; align-items: center; justify-content: flex-start; visibility: hidden; opacity: 0; color: var(--tg-text); transition: 0.2s; width: 44px; height: 44px; }
.btn-back.visible { visibility: visible; opacity: 1; }
.btn-trash { color: var(--red); }

/* НИЖНЯЯ ПАНЕЛЬ */
.bottom-bar { position: fixed; bottom: 20px; left: 16px; right: 16px; background: var(--tg-text); color: var(--tg-bg); padding: 14px 20px; border-radius: 16px; display: flex; align-items: center; justify-content: space-between; box-shadow: 0 10px 30px rgba(0,0,0,0.3); z-index: 200; transform: translateY(150%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.bottom-bar.visible { transform: translateY(0); }
.bottom-bar.hidden-search { transform: translateY(200%) !important; }
.total-sum { font-size: 18px; font-weight: 700; }
.btn-checkout-bar { background: transparent; color: inherit; border: none; font-weight: 600; font-size: 16px; padding: 0; }

/* КОШИК */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--tg-bg); z-index: 300; display: none; flex-direction: column; }
.cart-item { display: flex; align-items: center; gap: 12px; background: var(--tg-card); padding: 12px; border-radius: 14px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.cart-item img { width: 50px; height: 50px; object-fit: contain; background: #fff; border-radius: 8px; border: 1px solid rgba(0,0,0,0.05); flex-shrink: 0; }
.cart-details { flex: 1; min-width: 0; margin-right: 8px; }
.cart-title { font-size: 14px; font-weight: 600; margin-bottom: 2px; color: var(--tg-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-price { font-size: 13px; color: var(--tg-hint); }
.cart-price b { color: var(--tg-text); }
.cart-delete { background: none; border: none; cursor: pointer; padding: 0; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; color: var(--red); flex-shrink: 0; }
.cart-delete svg { width: 24px; height: 24px; }
.comment-box { padding: 16px; border-top: 1px solid rgba(0,0,0,0.05); background: var(--tg-card); }
.comment-input { width: 100%; padding: 12px; border: 1px solid var(--tg-hint); border-radius: 12px; font-size: 16px; background: var(--tg-bg); resize: none; color: var(--tg-text); }

.hidden { display: none !important; }
.skeleton { background: linear-gradient(90deg, rgba(128,128,128,0.1) 25%, rgba(128,128,128,0.2) 50%, rgba(128,128,128,0.1) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* --- PRODUCT MODAL (Увеличенная карточка) --- */
.product-modal-overlay {
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    padding: 20px;
    z-index: 400; /* Выше корзины */
}
.product-modal-content {
    background: var(--tg-card);
    width: 100%;
    max-width: 400px;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}
.pm-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: rgba(0,0,0,0.1);
    border: none;
    border-radius: 16px;
    font-size: 16px;
    color: var(--tg-text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
}
.pm-img-box {
    width: 100%;
    height: 280px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.pm-img-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.pm-info {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.pm-title {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--tg-text);
}
.pm-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.pm-price {
    font-size: 24px;
    font-weight: 700;
    color: var(--tg-text);
}
.pm-stock {
    font-size: 13px;
    color: var(--green);
    font-weight: 600;
    background: rgba(52, 199, 89, 0.1);
    padding: 4px 8px;
    border-radius: 6px;
}
.pm-controls {
    margin-top: 10px;
}