/* Базовые стили для адаптивного мобильного UI (Стиль "Collector Auction Pro") */
:root {
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-color: #212529;
    --muted-color: #6c757d;
    --accent-color: #0077ff;
    --danger-color: #dc3545;
    --success-color: #198754;
    --border-color: #dee2e6;
    --border-radius: 12px;
}

* { box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }

body {
    margin: 0; padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    overscroll-behavior-y: none;
}

/* Dev-панель сверху */
#dev-bar {
    background: #333; color: white; padding: 8px;
    display: flex; gap: 8px; align-items: center;
    font-size: 12px; overflow-x: auto;
}
#dev-bar button { padding: 4px 8px; cursor: pointer; }

/* Общие элементы */
.screen { padding: 16px; max-width: 600px; margin: 0 auto; }
.muted { color: var(--muted-color); font-size: 14px; }
.text-center { text-align: center; }

button {
    border: none; border-radius: 8px; font-weight: 600;
    cursor: pointer; padding: 12px 16px; width: 100%;
    transition: opacity 0.2s;
}
button:active { opacity: 0.8; }
.btn-primary { background: var(--accent-color); color: white; }
.btn-secondary { background: #e9ecef; color: var(--text-color); }
.btn-danger { background: var(--danger-color); color: white; }

input[type="text"], input[type="number"] {
    width: 100%; padding: 12px; border: 1px solid var(--border-color);
    border-radius: 8px; margin-bottom: 12px; font-size: 16px;
}

/* Хедер */
#top-bar {
    background: var(--card-bg); padding: 12px 16px;
    display: flex; justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

/* Карточка лота */
#lot-card {
    background: var(--card-bg); border-radius: var(--border-radius);
    overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    margin-top: 16px;
}

.gallery img { width: 100%; height: 250px; object-fit: cover; background: #eee; }

.lot-info { padding: 16px; }
#lot-title { margin: 0 0 8px 0; font-size: 20px; }

.price-board {
    display: flex; justify-content: space-between; align-items: flex-end;
    margin: 16px 0; border-bottom: 1px solid var(--border-color); padding-bottom: 16px;
}
.current-price { font-size: 32px; font-weight: 700; color: var(--text-color); }

.timer-board { text-align: center; margin-bottom: 16px; }
.timer { font-size: 36px; font-weight: bold; font-variant-numeric: tabular-nums; }
.timer.urgent { color: var(--danger-color); animation: pulse 1s infinite; }

@keyframes pulse { 50% { opacity: 0.5; } }

/* Контролы ставок */
.controls { padding: 16px; background: #fafafa; border-top: 1px solid var(--border-color); }
#bid-input { font-weight: bold; font-size: 18px; text-align: center; }

.quick-bids { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.quick-bids button { padding: 8px; font-size: 12px; background: white; border: 1px solid var(--border-color); }

.autobid-section { margin-top: 16px; font-size: 14px; }
.autobid-row { display: flex; gap: 8px; margin-top: 8px; }
.autobid-row input { margin-bottom: 0; }
.autobid-row button { width: auto; white-space: nowrap; }

/* Итоги раунда */
.summary-screen { text-align: center; background: var(--success-color); color: white; border-radius: 12px; padding: 32px 16px; }
.winner-title { font-size: 24px; margin-bottom: 8px; }
#summary-price { font-size: 40px; margin: 0 0 24px 0; }
.top-bids { background: rgba(0,0,0,0.2); padding: 16px; border-radius: 8px; margin-bottom: 24px; text-align: left; }
.top-bids ul { list-style: none; padding: 0; margin: 0; }
.top-bids li { padding: 4px 0; display: flex; justify-content: space-between; }
.next-lot-teaser { background: white; color: var(--text-color); padding: 16px; border-radius: 8px; }
#summary-timer { font-size: 24px; color: var(--accent-color); }

/* Админка */
.admin-screen { border: 2px dashed var(--danger-color); margin-top: 24px; }
.admin-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }

/* Стили для конструктора сессий и лотов */
.admin-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.admin-tabs button { flex: 1; padding: 8px; font-size: 13px; }
.admin-tabs .active-tab { background: var(--text-color); color: white; }

.auction-item, .lot-queue-item {
    background: #f1f3f5; border: 1px solid var(--border-color);
    border-radius: 8px; padding: 12px; margin-bottom: 8px;
    display: flex; justify-content: space-between; align-items: center;
}
.lot-queue-item img { width: 50px; height: 50px; object-fit: cover; border-radius: 6px; }
.lot-queue-info { display: flex; align-items: center; gap: 12px; flex: 1; margin-left: 12px; }
.lot-queue-actions { display: flex; gap: 4px; }
.lot-queue-actions button { width: 36px; padding: 6px; font-size: 14px; }

/* Модальные окна */
.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    display: flex; justify-content: center; align-items: center;
    z-index: 1000; padding: 16px; overflow-y: auto;
}
.modal-content {
    background: var(--card-bg); padding: 24px; border-radius: var(--border-radius);
    width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto;
}
.modal-content textarea {
    width: 100%; min-height: 80px; padding: 12px; border: 1px solid var(--border-color);
    border-radius: 8px; margin-bottom: 12px; font-size: 14px;
}
.modal-content select {
    width: 100%; padding: 12px; border: 1px solid var(--border-color);
    border-radius: 8px; margin-bottom: 12px; font-size: 16px; background: white;
}

/* ==========================================================================
   Навигация и Каркас (Мобильный UI)
   ========================================================================== */

/* Хедер (Top Bar) */
#top-bar {
    position: sticky; top: 0; z-index: 100;
    background: var(--card-bg); padding: 12px 16px;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.header-btn { background: none; border: none; font-size: 24px; padding: 0; width: auto; color: var(--text-color); margin: 0; }
.logo { font-weight: 800; font-size: 18px; color: var(--accent-color); }

/* Нижний Таб-бар */
#bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--card-bg); border-top: 1px solid var(--border-color);
    display: flex; justify-content: space-around; padding: 8px 0;
    z-index: 100; padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
.nav-item {
    background: none; border: none; display: flex; flex-direction: column;
    align-items: center; font-size: 10px; color: var(--muted-color); padding: 4px;
    width: 25%; margin: 0;
}
.nav-item.active { color: var(--accent-color); }
.nav-item i { font-size: 20px; margin-bottom: 4px; font-style: normal; }

/* Боковое меню (Drawer) */
#drawer-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 1001; display: none; opacity: 0; transition: opacity 0.3s;
}
#drawer {
    position: fixed; top: 0; left: -300px; bottom: 0; width: 280px;
    background: var(--card-bg); z-index: 1002; transition: left 0.3s;
    padding: 20px; box-shadow: 2px 0 8px rgba(0,0,0,0.1);
}
.drawer-open #drawer-overlay { display: block; opacity: 1; }
.drawer-open #drawer { left: 0; }

/* Отступ снизу для контента, чтобы его не перекрывал таб-бар */
#app { padding-bottom: 70px; }

/* ==========================================================================
   Главная и Кабинет
   ========================================================================== */

/* Карточка сессии на Главной */
.session-card {
    background: var(--card-bg); border-radius: var(--border-radius);
    overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 16px; border: 1px solid var(--border-color);
}
.session-img {
    width: 100%; height: 160px; object-fit: cover; background: #eee;
}
.session-info { padding: 12px 16px; }
.session-title { margin: 0 0 4px 0; font-size: 16px; }
.session-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted-color); }
.session-btn { 
    width: 100%; padding: 10px; margin-top: 12px; border: none; 
    border-radius: 6px; font-weight: bold; cursor: pointer;
}
.btn-live-join { background: var(--danger-color); color: white; animation: pulse 2s infinite; }

/* Карточка лота в Кабинете */
.cabinet-item {
    display: flex; gap: 12px; padding: 12px;
    border: 1px solid var(--border-color); border-radius: 8px;
    margin-bottom: 12px; background: var(--card-bg);
}
.cabinet-img { width: 60px; height: 60px; object-fit: cover; border-radius: 6px; }
.cabinet-details { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.cabinet-name { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.cabinet-price { font-size: 14px; color: var(--accent-color); font-weight: bold; }
.status-badge { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 10px; font-weight: bold; }
.badge-win { background: #d1e7dd; color: #0f5132; }
.badge-lead { background: #cfe2ff; color: #084298; }
.badge-lost { background: #f8d7da; color: #842029; }

/* ==========================================================================
   Сводный блок счета сессии в Личном кабинете (Шаг 6.9.3)
   ========================================================================== */
.session-invoice-box {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.session-invoice-header {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}
.session-invoice-summary {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
    font-size: 14px;
    line-height: 1.6;
}