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

:root {
    --bg: var(--tg-theme-bg-color, #f6f6f8);
    --card: var(--tg-theme-section-bg-color, #ffffff);
    --text: var(--tg-theme-text-color, #17181c);
    --hint: var(--tg-theme-hint-color, #8a8f98);
    --field: var(--tg-theme-secondary-bg-color, #eceef2);
    --accent: var(--tg-theme-button-color, #2a78d6);
    --accent-text: var(--tg-theme-button-text-color, #ffffff);
    --hairline: rgba(120, 125, 135, 0.16);
}

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    padding-bottom: 28px;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ================= Container — kontent doim markazda ================= */
.container {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
}

/* ================= Header ================= */
.header {
    position: sticky; top: 0; z-index: 10;
    background: var(--bg);
    padding: 12px clamp(14px, 4vw, 32px) 10px;
    border-bottom: 1px solid var(--hairline);
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.brand-icon {
    width: 42px; height: 42px; border-radius: 13px; flex-shrink: 0;
    background: var(--accent); font-size: 20px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 16px rgba(42, 120, 214, .3);
}
.brand-title { font-size: 16px; font-weight: 800; letter-spacing: -.3px; }
.brand-sub { font-size: 12px; color: var(--hint); margin-top: 1px; }

.search-box { position: relative; }
.search-icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--hint); pointer-events: none;
}
.search-box input {
    width: 100%; padding: 10px 14px 10px 36px;
    border: none; border-radius: 12px;
    background: var(--field); color: var(--text);
    font-size: 14px; outline: none; font-family: inherit;
    -webkit-appearance: none; appearance: none;
}
.search-box input::placeholder { color: var(--hint); }
.search-box input::-webkit-search-cancel-button { -webkit-appearance: none; }

.chips {
    display: flex; gap: 7px; overflow-x: auto;
    margin-top: 10px; padding-bottom: 3px;
    scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
    flex-shrink: 0; padding: 7px 13px; border-radius: 18px;
    background: var(--card); color: var(--text);
    border: 1px solid var(--hairline);
    font-size: 12.5px; font-weight: 600; cursor: pointer;
    font-family: inherit; transition: all .15s; white-space: nowrap;
}
.chip.active {
    background: var(--accent); color: var(--accent-text);
    border-color: var(--accent);
}

/* ================= Grid ================= */
.result-count {
    padding: 10px 2px 0; color: var(--hint); font-size: 12px;
}

main { padding: 0 clamp(14px, 4vw, 32px); }

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(142px, 1fr));
    gap: 12px;
    padding: 12px 0 20px;
}
@media (min-width: 480px) {
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 14px; }
}
@media (min-width: 760px) {
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; padding-top: 16px; }
}

/* Desktop: sichqonchali qurilmalarda hover-effekt */
@media (hover: hover) {
    .product-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 0 2px 0 rgba(145, 158, 171, .2), 0 20px 40px -4px rgba(145, 158, 171, .24);
    }
    .chip:hover:not(.active) { border-color: var(--accent); color: var(--accent); }
}

/* ================= Card — minimals.cc uslubi ================= */
.product-card {
    background: var(--card);
    border-radius: 16px;
    cursor: pointer;
    display: flex; flex-direction: column;
    box-shadow: 0 0 2px 0 rgba(145, 158, 171, .2), 0 12px 24px -4px rgba(145, 158, 171, .12);
    transition: transform .15s ease, box-shadow .15s ease;
    -webkit-tap-highlight-color: transparent;
}
.product-card:active { transform: scale(.97); }

.card-image-wrap {
    position: relative; padding: 6px;
}
.card-image {
    width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
    border-radius: 12px; background: var(--field);
}
.card-image-fallback {
    width: 100%; aspect-ratio: 1; border-radius: 12px; background: var(--field);
    display: flex; align-items: center; justify-content: center;
    font-size: 30px; opacity: .45;
}

.card-body {
    padding: 4px 12px 14px;
    display: flex; flex-direction: column; gap: 8px; flex: 1;
}
.card-name {
    font-size: 12.5px; font-weight: 600; line-height: 1.4;
    color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-bottom {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 8px; margin-top: auto;
}
.card-price {
    font-size: 13px; font-weight: 700; color: var(--text);
    letter-spacing: -.2px; flex-shrink: 0;
}
.card-price .sum { font-size: 10.5px; font-weight: 600; color: var(--hint); }
.card-price.empty { color: var(--hint); font-weight: 500; font-size: 11.5px; }
.card-category {
    font-size: 11px; color: var(--hint);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ================= Skeleton ================= */
.skeleton-card {
    border-radius: 16px; background: var(--card);
    box-shadow: 0 0 2px 0 rgba(145, 158, 171, .2), 0 12px 24px -4px rgba(145, 158, 171, .12);
    overflow: hidden;
    aspect-ratio: 3 / 4.2; position: relative;
}
.skeleton-card::after {
    content: ''; position: absolute; left: 6px; right: 6px; top: 6px;
    aspect-ratio: 1; background: var(--field); border-radius: 12px;
}
.skeleton-card::before {
    content: ''; position: absolute; inset: 0; z-index: 1;
    background: linear-gradient(100deg, transparent 35%, rgba(120,125,135,.10) 50%, transparent 65%);
    background-size: 220% 100%;
    animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { background-position: -220% 0; } }

/* ================= Empty ================= */
.empty { text-align: center; padding: 64px 24px; }
.empty-icon { font-size: 38px; margin-bottom: 12px; }
.empty-title { font-weight: 700; font-size: 15px; }
.empty-sub { color: var(--hint); font-size: 13px; margin-top: 4px; }

/* ================= Bottom sheet ================= */
.sheet-overlay {
    position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 50;
    display: flex; align-items: flex-end; justify-content: center;
    animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } }

.sheet {
    background: var(--card); width: 100%; max-width: 560px;
    border-radius: 20px 20px 0 0;
    max-height: 90vh; overflow-y: auto; position: relative;
    animation: sheetUp .24s cubic-bezier(.2, .8, .3, 1);
}
@keyframes sheetUp { from { transform: translateY(60px); opacity: .6; } to { transform: none; opacity: 1; } }

.sheet-close {
    position: absolute; top: 12px; right: 12px; z-index: 3;
    width: 30px; height: 30px; border-radius: 50%;
    border: none; cursor: pointer; font-size: 13px;
    background: rgba(20, 20, 24, .45); color: #fff;
    backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
}

.sheet-image-wrap {
    width: 100%; aspect-ratio: 4 / 3; background: var(--field);
    overflow: hidden;
}
.sheet-image { width: 100%; height: 100%; object-fit: cover; display: block; }
.sheet-image-wrap.fallback {
    display: flex; align-items: center; justify-content: center;
    font-size: 52px; opacity: .4; aspect-ratio: 16 / 7;
}
.sheet-image-wrap.fallback .sheet-image { display: none; }
.sheet-image-wrap.fallback::after { content: '📦'; }

.sheet-body { padding: 16px 18px calc(22px + env(safe-area-inset-bottom)); }
.sheet-category {
    color: var(--accent); font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .6px;
}
.sheet-body h2 { font-size: 18px; margin: 5px 0 2px; line-height: 1.25; letter-spacing: -.3px; }
.sheet-price { font-size: 19px; font-weight: 800; margin: 8px 0 4px; letter-spacing: -.3px; }
.sheet-price .sum { font-size: 13px; font-weight: 600; color: var(--hint); }
.sheet-desc {
    color: var(--text); opacity: .85; line-height: 1.6; white-space: pre-wrap;
    font-size: 13.5px; margin-top: 6px;
}

.contact-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    margin-top: 18px; padding: 13px;
    background: var(--accent); color: var(--accent-text);
    border-radius: 13px; text-decoration: none;
    font-weight: 700; font-size: 14.5px;
    transition: transform .12s;
}
.contact-btn:active { transform: scale(.98); }

/* Desktop: pastdan chiqadigan sheet o'rniga markazdagi oyna */
@media (min-width: 760px) {
    .sheet-overlay { align-items: center; padding: 24px; }
    .sheet {
        border-radius: 20px; max-height: 84vh;
        animation: dialogIn .2s ease;
    }
    @keyframes dialogIn { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
}
