/* =============================================
   XBuyPin WebApp - Telegram Mini App Uslublari
   uzpin.games bilan 1 ga 1
   ============================================= */

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

:root {
    --bg:           #0e0e0e;
    --card-bg:      #1a1a1a;
    --card-bg2:     #242424;
    --gold:         #f5a623;
    --gold-dark:    #c8791e;
    --text:         #ffffff;
    --muted:        #888888;
    --border:       #2a2a2a;
    --success:      #34c759;
    --danger:       #ff3b30;
    --nav-h:        70px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ---- Barcha sahifalar ---- */
.page { display: none; padding: 0 0 calc(var(--nav-h) + 10px) 0; min-height: 100vh; }
.page.active { display: block; }

/* ---- Header ---- */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 16px 8px;
}
.app-logo { font-size: 22px; font-weight: 800; color: var(--gold); letter-spacing: 1px; }
.app-logo span { color: var(--text); }

/* ---- Foydalanuvchi kartasi (Bosh sahifada) ---- */
.user-card {
    margin: 0 16px 20px;
    background: linear-gradient(135deg, #1f1f1f, #2a2a2a);
    border-radius: 16px;
    padding: 16px;
    border: 1px solid #333;
}
.user-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.user-name { font-size: 16px; font-weight: 700; }
.user-balance-label { font-size: 12px; color: var(--muted); }
.user-balance-amount { font-size: 20px; font-weight: 800; color: var(--gold); }

.topup-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    color: #000;
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity 0.2s;
}
.topup-btn:active { opacity: 0.85; }

/* ---- Promo Banner ---- */
.promo-banner {
    margin: 0 16px 20px;
    background: linear-gradient(135deg, #1a2e1a, #0d1f3c);
    border-radius: 16px;
    padding: 18px;
    border: 1px solid #333;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
}
.promo-banner .icon { font-size: 36px; }
.promo-banner h4 { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.promo-banner p { font-size: 12px; color: var(--muted); }

/* ---- Section sarlavhasi ---- */
.section-title {
    font-size: 18px;
    font-weight: 700;
    padding: 0 16px;
    margin-bottom: 14px;
}

/* ---- O'yinlar Grid ---- */
.games-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 0 16px;
    margin-bottom: 20px;
}
.game-item {
    background: var(--card-bg);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s;
    border: 1px solid var(--border);
}
.game-item:active { transform: scale(0.96); }
.game-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}
.game-item-name {
    font-size: 11px;
    font-weight: 600;
    padding: 8px 6px;
    text-align: center;
    color: var(--text);
    line-height: 1.3;
}

/* ---- Mahsulot sahifasi ---- */
.product-page-header {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.back-btn {
    background: var(--card-bg);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.product-page-header h2 { font-size: 18px; font-weight: 700; }

.products-list { padding: 0 16px; }
.product-row {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.15s;
}
.product-row.selected { border-color: var(--gold); }
.product-row h4 { font-size: 16px; font-weight: 600; }
.product-row .price { color: var(--gold); font-weight: 700; font-size: 16px; }

.buy-section { padding: 16px; }
.buy-section input {
    width: 100%;
    background: var(--card-bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    color: white;
    font-size: 15px;
    margin-bottom: 14px;
    outline: none;
}
.buy-section input:focus { border-color: var(--gold); }

/* ---- Hamyon sahifasi ---- */
.wallet-header {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.wallet-header h2 { font-size: 22px; font-weight: 800; }
.refresh-btn { background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; }

.balance-card {
    margin: 0 16px 20px;
    background: linear-gradient(135deg, #2a2200, #1a1500);
    border-radius: 20px;
    padding: 24px 20px;
    border: 1px solid #3a3000;
}
.balance-label { font-size: 13px; color: var(--gold); font-weight: 600; margin-bottom: 8px; }
.balance-amount { font-size: 36px; font-weight: 800; margin-bottom: 4px; }
.balance-currency { font-size: 18px; color: var(--muted); font-weight: 500; }
.balance-divider { height: 1px; background: #3a3000; margin: 16px 0; }

.history-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--muted);
    padding: 0 16px;
    margin-bottom: 12px;
}
.history-item {
    background: var(--card-bg);
    margin: 0 16px 10px;
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.history-item .h-left h4 { font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.history-item .h-left p { font-size: 12px; color: var(--muted); }
.history-item .h-right { font-size: 14px; font-weight: 700; color: var(--danger); }
.history-item .h-right.plus { color: var(--success); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 14px; }

/* ---- Profil sahifasi ---- */
.profile-avatar-section { text-align: center; padding: 30px 16px 20px; }
.profile-avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 800;
    color: #000;
}
.profile-name { font-size: 20px; font-weight: 800; margin-bottom: 6px; }
.profile-id { font-size: 14px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; }

.profile-menu { padding: 0 16px; }
.menu-item {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: background 0.15s;
}
.menu-item:active { background: var(--card-bg2); }
.menu-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.menu-item-text h4 { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.menu-item-text p { font-size: 12px; color: var(--muted); }
.menu-arrow { margin-left: auto; color: var(--muted); font-size: 18px; }

.api-key-box {
    background: var(--card-bg2);
    border-radius: 12px;
    padding: 12px;
    margin: 10px 16px;
    font-family: monospace;
    font-size: 13px;
    color: var(--success);
    word-break: break-all;
    border: 1px solid var(--border);
}

/* ---- Pastki Navigatsiya ---- */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--nav-h);
    background: #141414;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}
.nav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    padding: 8px 0;
    transition: all 0.2s;
    color: var(--muted);
    border: none;
    background: none;
}
.nav-tab.active { color: var(--gold); }
.nav-tab svg { width: 24px; height: 24px; }
.nav-tab span { font-size: 10px; font-weight: 600; }

/* ---- Xabar qutilari ---- */
.alert-err { background: rgba(255,59,48,.12); border: 1px solid var(--danger); color: var(--danger); padding: 12px 16px; border-radius: 10px; margin: 0 16px 14px; font-size: 14px; }
.alert-ok  { background: rgba(52,199,89,.12); border: 1px solid var(--success); color: var(--success); padding: 12px 16px; border-radius: 10px; margin: 0 16px 14px; font-size: 14px; }

/* ---- Telegram login modal ---- */
.login-modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.85);
    display: flex; align-items: center; justify-content: center;
    z-index: 999;
    padding: 20px;
}
.login-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 30px 24px;
    text-align: center;
    max-width: 340px; width: 100%;
    border: 1px solid var(--border);
}
.login-card h2 { font-size: 22px; margin-bottom: 10px; }
.login-card p { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.login-input { width: 100%; background: var(--card-bg2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; color: white; font-size: 15px; margin-bottom: 10px; outline: none; }
.login-input:focus { border-color: var(--gold); }
