/* Общая тема для инвентаря/рынка — CS2/Standoff2-подобный стиль:
   тёмный фон, неоновый акцент, карточки со свечением по редкости скина. */

@import url('https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,300;14..32,500;14..32,800&family=Space+Grotesk:wght@400;500;600;700&display=swap');

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

/* Заглушка на время проверки авторизации — чтобы кнопка "Войти" не мигала перед
   тем, как Firebase поймёт, что пользователь уже залогинен (onAuthStateChanged асинхронный). */
.auth-gate-spinner {
    display: flex; flex-direction: column; align-items: center; gap: 14px;
    padding: 60px 20px; color: #888; font-size: 0.9rem;
}
.auth-gate-spinner .spin {
    width: 34px; height: 34px; border-radius: 50%;
    border: 3px solid rgba(10,255,180,0.15); border-top-color: var(--neon-mint, #0affb4);
    animation: authSpin 0.8s linear infinite;
}
@keyframes authSpin { to { transform: rotate(360deg); } }

:root {
    --neon-mint: #0affb4;
    --deep-pink: #ff0a6c;
    --bg-dark: #050507;
    --bg-panel: #0b0b12;
    --card-bg: rgba(255,255,255,0.03);
    --border-soft: rgba(255,255,255,0.08);
    --glow-mint: 0 0 16px rgba(10, 255, 180, 0.45);

    --q-default: #7d8590;
    --q-normal: #5aa0e8;
    --q-basic: #4caf50;
    --q-professional: #b366ff;
    --q-legendary: #ffb400;
}

body {
    background:
        radial-gradient(ellipse 900px 500px at 20% -10%, rgba(10,255,180,0.06), transparent 60%),
        radial-gradient(ellipse 900px 500px at 90% 10%, rgba(255,10,108,0.05), transparent 60%),
        var(--bg-dark);
    color: #eef5ff;
    font-family: 'Inter', sans-serif;
    overflow-x: hidden;
    min-height: 100vh;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 32px;
    border-bottom: 1px solid rgba(10, 255, 180, 0.15);
    backdrop-filter: blur(10px);
    flex-wrap: wrap;
    gap: 12px;
    position: sticky;
    top: 0;
    background: rgba(5,5,7,0.85);
    z-index: 50;
}
header img { height: 32px; vertical-align: middle; }
.badge-dev { color: var(--neon-mint); font-size: 0.75rem; margin-left: 10px; letter-spacing: 0.5px; }
nav a { color: #ccc; text-decoration: none; margin-left: 22px; font-size: 0.9rem; transition: color 0.15s; }
nav a:hover, nav a.active { color: var(--neon-mint); }

.main-content { max-width: 1100px; margin: 0 auto; padding: 30px 20px 70px; }

.hero { text-align: center; margin-bottom: 34px; }
.chip-badge {
    display: inline-block; padding: 6px 18px;
    border: 1px solid rgba(10,255,180,0.4); border-radius: 40px;
    font-size: 0.75rem; color: var(--neon-mint); margin-bottom: 14px;
    background: rgba(10,255,180,0.05);
}
.hero-title {
    font-family: 'Space Grotesk', sans-serif; font-size: 2.4rem; font-weight: 700;
    letter-spacing: 3px;
    background: linear-gradient(135deg, #fff 30%, var(--neon-mint));
    -webkit-background-clip: text; background-clip: text; color: transparent;
}

.tabs { display: flex; justify-content: center; gap: 12px; margin: 24px 0 30px; flex-wrap: wrap; }
.tab-btn {
    background: transparent; border: 1px solid var(--border-soft); color: #ccc;
    padding: 10px 26px; border-radius: 40px; cursor: pointer; font-size: 0.9rem;
    transition: all 0.2s;
}
.tab-btn:hover { border-color: rgba(10,255,180,0.4); color: #fff; }
.tab-btn.active { background: var(--neon-mint); color: #000; font-weight: 700; border-color: var(--neon-mint); }

.auth-card, .panel {
    background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent), var(--bg-panel);
    border: 1px solid var(--border-soft);
    border-radius: 20px;
    padding: 28px;
}

.btn {
    background: transparent; border: 1px solid rgba(10,255,180,0.5); color: var(--neon-mint);
    padding: 10px 22px; border-radius: 40px; cursor: pointer; font-size: 0.88rem;
    transition: all 0.2s;
}
.btn:hover { box-shadow: var(--glow-mint); background: rgba(10,255,180,0.08); }
.btn-primary { background: var(--neon-mint); color: #000; font-weight: 700; border-color: var(--neon-mint); }
.btn-primary:hover { box-shadow: 0 0 24px rgba(10,255,180,0.7); }
.btn-danger { border-color: rgba(255,10,108,0.5); color: var(--deep-pink); }
.btn-danger:hover { box-shadow: 0 0 16px rgba(255,10,108,0.45); }
.btn-small { padding: 6px 14px; font-size: 0.78rem; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

#userInfo, .user-info {
    display: flex; align-items: center; gap: 12px; margin-bottom: 24px;
    padding-bottom: 16px; border-bottom: 1px solid var(--border-soft);
}
.avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(10,255,180,0.3); }

.stats-row { display: flex; gap: 14px; margin-bottom: 26px; flex-wrap: wrap; }
.stat-pill {
    background: rgba(10,255,180,0.06); border: 1px solid rgba(10,255,180,0.2);
    border-radius: 40px; padding: 9px 20px; font-size: 0.85rem;
}

.weapons-grid, .market-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.weapon-card, .listing-card {
    background: var(--card-bg);
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    padding: 14px;
    text-align: center;
    position: relative;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    overflow: hidden;
}
.weapon-card::before, .listing-card::before {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(160deg, var(--rarity-color, transparent) 0%, transparent 45%);
    opacity: 0.18;
    pointer-events: none;
}
.weapon-card:hover, .listing-card:hover {
    transform: translateY(-4px);
    border-color: var(--rarity-color, rgba(10,255,180,0.4));
    box-shadow: 0 8px 24px -8px var(--rarity-color, rgba(10,255,180,0.4));
}
.weapon-card img, .listing-card img {
    width: 100%; height: 64px; object-fit: contain; margin-bottom: 10px;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.5));
}
.weapon-name { font-size: 0.86rem; font-weight: 700; }
.skin-name { font-size: 0.76rem; margin-top: 3px; font-weight: 600; }
.card-actions { margin-top: 10px; display: flex; gap: 6px; justify-content: center; }
.price-tag {
    margin-top: 8px; font-size: 0.9rem; font-weight: 700; color: var(--neon-mint);
}
.seller-row {
    margin-top: 6px; font-size: 0.72rem; color: #999; display: flex; align-items: center;
    justify-content: center; gap: 6px;
}
.seller-row img { width: 18px; height: 18px; border-radius: 50%; margin: 0; }

.quality-Default { --rarity-color: #7d8590; color: var(--q-default); }
.quality-Normal { --rarity-color: #5aa0e8; color: var(--q-normal); }
.quality-Basic { --rarity-color: #4caf50; color: var(--q-basic); }
.quality-Professional { --rarity-color: #b366ff; color: var(--q-professional); }
.quality-Legendary { --rarity-color: #ffb400; color: var(--q-legendary); text-shadow: 0 0 10px rgba(255,180,0,0.5); }

.icon { width: 1em; height: 1em; display: inline-block; vertical-align: -0.15em; flex-shrink: 0; }
.btn .icon { width: 1.05em; height: 1.05em; margin-right: 6px; vertical-align: -0.18em; }
h3 .icon, .stat-pill .icon, .chip-badge .icon { margin-right: 6px; }
.tab-btn .icon, .tab .icon { margin-right: 6px; }

.empty-state { text-align: center; color: #888; padding: 50px 0; grid-column: 1/-1; }
.empty-state .icon { width: 40px; height: 40px; color: #444; display: block; margin: 0 auto 12px; }

/* Поиск / фильтры */
.filter-bar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.search-input-wrap { position: relative; flex: 1; min-width: 180px; }
.search-input-wrap .icon {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: #777; width: 18px; height: 18px;
}
.search-input-wrap input {
    width: 100%; background: #111318; border: 1px solid var(--border-soft); border-radius: 40px;
    padding: 11px 16px 11px 40px; color: #eef5ff; font-size: 0.9rem;
}
.search-input-wrap input:focus { outline: none; border-color: rgba(10,255,180,0.5); }
.select-pill {
    background: #111318; border: 1px solid var(--border-soft); color: #ddd;
    border-radius: 40px; padding: 11px 16px; font-size: 0.85rem; cursor: pointer;
}

/* Значок "листает сам себя каждые 5с" */
.live-badge {
    display: inline-flex; align-items: center; gap: 6px; font-size: 0.72rem; color: #6f6;
    background: rgba(10,255,180,0.08); border: 1px solid rgba(10,255,180,0.25);
    border-radius: 40px; padding: 5px 12px; margin-bottom: 14px;
}
.live-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: #0affb4; animation: livePulse 1.4s infinite; }
@keyframes livePulse { 0%,100%{opacity:1; box-shadow:0 0 0 rgba(10,255,180,0.5);} 50%{opacity:0.4;} }

/* Кнопка "детали/стакан" поверх карточки */
.detail-btn {
    position: absolute; top: 8px; right: 8px; z-index: 2;
    background: rgba(0,0,0,0.55); border: 1px solid var(--border-soft); border-radius: 50%;
    width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
    color: #ccc; cursor: pointer;
}
.detail-btn:hover { color: var(--neon-mint); border-color: rgba(10,255,180,0.5); }
.detail-btn .icon { width: 15px; height: 15px; margin: 0; }

/* Модалка деталей предмета — стакан заявок + история */
.item-modal-box {
    background: var(--bg-panel); border: 1px solid rgba(10,255,180,0.3);
    border-radius: 20px; padding: 24px; width: min(560px, calc(100vw - 32px));
    max-height: 85vh; overflow-y: auto; text-align: left;
}
.item-modal-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.item-modal-head img { width: 64px; height: 40px; object-fit: contain; }
.orderbook-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
@media (max-width: 560px) { .orderbook-cols { grid-template-columns: 1fr; } }
.orderbook-col h4 { font-size: 0.8rem; color: #aaa; margin-bottom: 8px; display: flex; align-items: center; gap: 5px; }
.orderbook-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.orderbook-row {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    background: rgba(255,255,255,0.03); border: 1px solid var(--border-soft); border-radius: 10px;
    padding: 8px 12px; font-size: 0.82rem;
}
.orderbook-row .ob-price { font-weight: 700; }
.orderbook-row.ask .ob-price { color: #ff6b8a; }
.orderbook-row.bid .ob-price { color: var(--neon-mint); }
.orderbook-row .ob-who { color: #888; font-size: 0.72rem; }
.orderbook-row button { flex-shrink: 0; }

.history-list { display: flex; flex-direction: column; gap: 4px; max-height: 160px; overflow-y: auto; }
.history-row {
    display: flex; justify-content: space-between; font-size: 0.78rem; color: #999;
    padding: 6px 10px; border-bottom: 1px solid rgba(255,255,255,0.04);
}
.history-row .h-price { color: var(--neon-mint); font-weight: 700; }

.place-order-form { display: flex; gap: 8px; margin-top: 6px; }
.place-order-form input {
    flex: 1; background: #111318; border: 1px solid var(--border-soft); border-radius: 10px;
    padding: 10px 14px; color: #eef5ff; font-size: 0.9rem;
}

/* Мобильная нижняя навигация — приоритет удобства на телефоне */
.mobile-nav { display: none; }
@media (max-width: 720px) {
    header nav { display: none; }
    .main-content { padding-bottom: 90px; }
    .mobile-nav {
        display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
        background: rgba(8,8,12,0.92); backdrop-filter: blur(14px);
        border-top: 1px solid rgba(10,255,180,0.15);
        padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
        justify-content: space-around;
    }
    .mobile-nav a {
        display: flex; flex-direction: column; align-items: center; gap: 3px;
        color: #888; text-decoration: none; font-size: 0.65rem; flex: 1; padding: 4px;
    }
    .mobile-nav a .icon { width: 22px; height: 22px; }
    .mobile-nav a.active { color: var(--neon-mint); }

    .weapons-grid, .market-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .hero-title { font-size: 1.7rem; }
    .modal-box { width: calc(100vw - 32px); }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .select-pill { width: 100%; }
}

footer { text-align: center; padding: 26px; color: #777; font-size: 0.8rem; }
footer a { color: #999; margin: 0 10px; text-decoration: none; }
footer a:hover { color: var(--neon-mint); }

.toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: #111; border: 1px solid var(--neon-mint); color: #fff;
    padding: 10px 20px; border-radius: 40px; font-size: 0.85rem; opacity: 0; transition: all 0.3s; z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Модалка (продажа/цена) */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.75); backdrop-filter: blur(4px);
    display: none; align-items: center; justify-content: center; z-index: 998;
}
.modal-overlay.show { display: flex; }
.modal-box {
    background: var(--bg-panel); border: 1px solid rgba(10,255,180,0.3);
    border-radius: 18px; padding: 26px; width: 320px; text-align: center;
}
.modal-box img { width: 100px; height: 60px; object-fit: contain; margin: 10px auto; }
.modal-box input {
    width: 100%; background: #111318; border: 1px solid var(--border-soft); border-radius: 10px;
    padding: 10px 14px; color: #eef5ff; font-size: 0.95rem; margin: 14px 0; text-align: center;
}
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 6px; }
