/* ========================================
   ! STATS PANEL
   Выезжающая справа панель (тот же визуальный язык, что у остальных
   drawer'ов приложения: толстая рамка + "жёсткая" offset-тень). Два таба —
   "Переводчик" (translater_stats) и "База данных" (db_stats, см. db-stats.js) —
   переключаются кликом, каждый рендерит свои данные прямо в тело панели.
   append to index.html <head>, load after style.css
   ======================================== */

/* Toolbar button (top-buttons row) — same "active = filled yellow" language
   as .translater-btn.active in translater.css. */
#statsPanelBtn.active { background: var(--m-yellow) !important; }

.stats-panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 6999;
    opacity: 0;
    pointer-events: none;
    transition: opacity .28s ease;
}
.stats-panel-backdrop.open { opacity: 1; pointer-events: auto; }

.stats-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 88vw;
    max-width: 460px;
    background: var(--m-surface);
    border-left: 3px solid var(--m-dark);
    box-shadow: -8px 0 0 var(--m-dark);
    z-index: 7000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform .28s ease;
    outline: none;
}
.stats-panel.open { transform: translateX(0); }

.stats-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    padding-top: max(14px, env(safe-area-inset-top));
    background: var(--m-dark);
    color: var(--m-yellow);
    flex-shrink: 0;
}
.stats-panel-title {
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .5px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.stats-panel-close {
    background: none;
    border: 2px solid var(--m-yellow);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    min-width: 30px;
    color: var(--m-yellow);
    font-weight: 900;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .12s, color .12s, border-color .12s;
}
.stats-panel-close:hover,
.stats-panel-close:active { background: var(--m-pink); border-color: var(--m-pink); color: #fff; }

/* Top-level tab bar: Переводчик / База данных */
.stats-panel-tabs {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 2px solid var(--m-dark);
    flex-shrink: 0;
}
.stats-panel-tab {
    flex: 1;
    border: 2px solid var(--m-dark);
    background: var(--m-surface2);
    color: var(--m-dark);
    border-radius: 50px;
    padding: 8px 10px;
    font-size: 11.5px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .4px;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s, color .15s;
}
.stats-panel-tab:hover { background: var(--m-teal); color: var(--m-dark); border-color: var(--m-teal); }
.stats-panel-tab.active,
.stats-panel-tab.active:hover {
    background: var(--m-dark);
    color: var(--m-yellow);
    border-color: var(--m-dark);
}

.stats-panel-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 14px;
    gap: 10px;
}
/* "Переводчик" tab reuses tr-stats-* (translater.css) inside this body — its
   own sub-tabs/summary/list/pager stack top-to-bottom, same as before. */
.stats-panel-body > .tr-stats-tabs { flex-shrink: 0; }
.stats-panel-body > .tr-stats-list { flex: 1; }

/* "База данных" tab toolbar + scrollable body */
.stats-panel-db-toolbar {
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}
.stats-panel-refresh-btn {
    background: none;
    border: 2px solid var(--m-dark);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 15px;
    font-weight: 900;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--m-dark);
    transition: background .12s, color .12s, transform .1s;
}
.stats-panel-refresh-btn:hover { background: var(--m-teal); border-color: var(--m-teal); }
.stats-panel-refresh-btn.spinning { animation: stats-panel-spin .6s linear infinite; }
@keyframes stats-panel-spin { to { transform: rotate(360deg); } }

.stats-panel-db-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
}
/* db-stats.css's .dbstats-section/.dbstats-table etc. render fine unchanged
   inside this flex column — only the old .dbstats-overlay/.dbstats-modal
   shell (unused now) is skipped. */

/* ========== Mobile ========== */
@media (max-width: 480px) {
    .stats-panel { width: 100vw; max-width: 100vw; }
}
