/* ==========================================================================
 * FLUX AGGREGATOR: MONOCHROME BRUTALISM
 * ========================================================================== */
:root {
    --bg-base: #000000;
    --bg-surface: #0a0a0a;
    --bg-elevated: #121212;

    --border-dim: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.15);
    --border-strong: #ffffff;

    --text-main: #ffffff;
    --text-muted: #777777;
    --text-dim: #444444;

    /* Идеальные плавные кривые (Fluid Spring) */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html, body {
    height: 100dvh; width: 100vw; position: fixed; overflow: hidden; overscroll-behavior-y: none;
    background: var(--bg-base); color: var(--text-main);
    font-family: 'Inter', -apple-system, sans-serif;
    display: flex; flex-direction: column; -webkit-font-smoothing: antialiased;
}

/* --------------------------------------------------------------------------
 * 1. БАЗА И ФИКС ЧЕЛКИ (SAFE AREA)
 * -------------------------------------------------------------------------- */
.noise-layer { position: fixed; inset: 0; background: url('https://grainy-gradients.vercel.app/noise.svg'); opacity: 0.04; pointer-events: none; z-index: 0; }

.app-container { height: 100dvh; width: 100%; max-width: 600px; margin: 0 auto; display: flex; flex-direction: column; overflow: hidden; position: relative; z-index: 1; }

.safe-area-top {
    width: 100%; flex-shrink: 0;
    height: var(--tg-content-safe-area-inset-top, env(safe-area-inset-top, 40px));
    background: var(--bg-surface);
}

/* --------------------------------------------------------------------------
 * 2. PRELOADER (ЭКРАН ЗАГРУЗКИ)
 * -------------------------------------------------------------------------- */
.preloader {
    position: fixed; inset: 0; background: var(--bg-base); z-index: 99999;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    transition: opacity 0.5s var(--ease-out-expo), visibility 0.5s;
}
.preloader:not(.active) { opacity: 0; visibility: hidden; pointer-events: none; }
.spinner { width: 44px; height: 44px; border: 2px solid var(--border-dim); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 24px; }
.preloader-text { font-family: 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: 3px; color: var(--text-muted); text-transform: uppercase; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
 * 3. ROUTING (ПЛАВНЫЕ ПЕРЕХОДЫ МЕЖДУ ЭКРАНАМИ)
 * -------------------------------------------------------------------------- */
#main-content {
    flex: 1; display: grid; grid-template-columns: 100%; position: relative; min-height: 0;
}

.screen {
    grid-area: 1/1; display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden;
    padding-bottom: 120px; height: 100%; transition: 0.5s var(--ease-spring); will-change: transform, opacity;
}

#rss-screen { transform: translateX(-100%); opacity: 0; }
#tg-screen { transform: translateX(100%); opacity: 0; }
#settings-screen { transform: translateX(100%); opacity: 0; }

body.tab-rss-active #rss-screen { transform: translateX(0); opacity: 1; z-index: 2; pointer-events: auto; }
body.tab-rss-active #tg-screen, body.tab-rss-active #settings-screen { pointer-events: none; transform: translateX(40%) scale(0.95); opacity: 0; }

body.tab-tg-active #rss-screen { pointer-events: none; transform: translateX(-40%) scale(0.95); opacity: 0; }
body.tab-tg-active #tg-screen { transform: translateX(0); opacity: 1; z-index: 2; pointer-events: auto; }
body.tab-tg-active #settings-screen { pointer-events: none; transform: translateX(40%) scale(0.95); opacity: 0; }

body.tab-settings-active #rss-screen, body.tab-settings-active #tg-screen { pointer-events: none; transform: translateX(-40%) scale(0.95); opacity: 0; }
body.tab-settings-active #settings-screen { transform: translateX(0); opacity: 1; z-index: 2; pointer-events: auto; }

/* --------------------------------------------------------------------------
 * 4. HEADER & TYPOGRAPHY
 * -------------------------------------------------------------------------- */
.flux-header { padding: 25px 20px; display: flex; flex-direction: column; align-items: center; border-bottom: 1px solid var(--border-dim); background: var(--bg-surface); text-align: center; }

.app-badge { padding: 6px 16px; border: 1px solid var(--border-light); border-radius: 30px; margin-bottom: 25px; display: inline-flex; align-items: center; justify-content: center; }
.app-title-text { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 2px; color: var(--text-muted); }

.flux-display { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 10px; width: 100%; }
.flux-main-title { font-size: 32px; font-weight: 900; letter-spacing: -1px; line-height: 1; color: #fff; text-shadow: 0 0 30px rgba(255,255,255,0.15); text-transform: uppercase;}
.flux-sub-text { font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 600; color: var(--text-muted); }

.section-title { font-size: 11px; font-weight: 800; color: var(--text-muted); letter-spacing: 2px; padding: 20px 20px 10px; text-transform: uppercase; display: flex; justify-content: space-between; align-items: center;}

/* --------------------------------------------------------------------------
 * 5. БРУТАЛЬНЫЕ КНОПКИ И ПЕРЕКЛЮЧАТЕЛИ
 * -------------------------------------------------------------------------- */
.btn-primary {
    display: flex; align-items: center; justify-content: center; gap: 10px; width: calc(100% - 40px); margin: 0 20px 15px; padding: 16px;
    background: #fff; color: #000; font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px;
    border: none; border-radius: 12px; cursor: pointer; transition: transform 0.2s var(--ease-spring), background 0.2s;
}
.btn-primary:active { transform: scale(0.96); background: #d0d0d0; }
.btn-icon { width: 18px; height: 18px; fill: none; stroke: #000; flex-shrink: 0; }

.search-bar-container { padding: 0 20px 15px; }
.search-input { 
    width: 100%; padding: 14px 16px; background: var(--bg-elevated); border: 1px solid var(--border-light); 
    border-radius: 12px; color: #fff; font-size: 14px; outline: none; transition: 0.3s; 
}
.search-input:focus { border-color: #fff; box-shadow: 0 0 15px rgba(255,255,255,0.05); }

/* --------------------------------------------------------------------------
 * 6. СПИСКИ ИСТОЧНИКОВ (КАРТОЧКИ RSS И TG)
 * -------------------------------------------------------------------------- */
.list-container { padding: 0 20px; display: flex; flex-direction: column; gap: 12px; }

.source-card {
    display: flex; align-items: center; justify-content: space-between; padding: 18px 20px;
    background: var(--bg-elevated); border: 1px solid var(--border-light); border-radius: 14px; transition: 0.3s;
}
.source-card.paused { opacity: 0.5; border-style: dashed; }

.source-info { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.source-title { font-size: 15px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 8px;}
.source-route { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-muted); }

.source-controls { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.btn-icon-only { background: none; border: none; padding: 5px; cursor: pointer; opacity: 0.7; transition: 0.2s; }
.btn-icon-only:active { transform: scale(0.9); opacity: 1; }
.btn-icon-only svg { stroke: #fff; fill: none; width: 20px; height: 20px; }

/* --------------------------------------------------------------------------
 * 7. СТАТУС БЕЙДЖИ
 * -------------------------------------------------------------------------- */
.status-badge {
    font-family: 'Inter', sans-serif; font-size: 9px; font-weight: 800; letter-spacing: 0.5px;
    padding: 4px 8px; border-radius: 6px; text-transform: uppercase; display: inline-block;
}
.badge-active { background: #fff; color: #000; }
.badge-paused { background: transparent; color: var(--text-dim); border: 1px dashed var(--text-dim); }
.badge-error { background: rgba(255,0,0,0.1); color: #ff4444; border: 1px solid rgba(255,0,0,0.3); }

/* --------------------------------------------------------------------------
 * 8. НИЖНЯЯ НАВИГАЦИЯ
 * -------------------------------------------------------------------------- */
.bottom-nav {
    position: fixed; bottom: 0; width: 100%; display: flex;
    background: rgba(0,0,0,0.85); backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px);
    border-top: 1px solid var(--border-light); padding-bottom: env(safe-area-inset-bottom); z-index: 1000;
}
.nav-tab { flex: 1; padding: 14px 0; display: flex; flex-direction: column; align-items: center; gap: 6px; background: none; border: none; color: var(--text-muted); cursor: pointer; transition: 0.3s; }
.nav-tab.active { color: #fff; }
.nav-icon { display: flex; align-items: center; justify-content: center; height: 24px; }
.nav-icon svg { width: 24px; height: 24px; transition: 0.4s var(--ease-spring); stroke: currentColor; fill: none; stroke-width: 1.5; }
.nav-tab.active .nav-icon svg { transform: translateY(-4px); filter: drop-shadow(0 4px 8px rgba(255,255,255,0.3)); }
.nav-tab span { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; line-height: 1; }

/* --------------------------------------------------------------------------
 * 9. МОДАЛЬНЫЕ ОКНА И ФОРМЫ (БРУТАЛИЗМ)
 * -------------------------------------------------------------------------- */
.center-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 50000; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: 0.4s var(--ease-out-expo); padding: 20px; }
.center-modal.active { opacity: 1; pointer-events: auto; }

.modal-dialog { width: 100%; max-width: 340px; background: var(--bg-surface); border: 1px solid var(--border-light); border-radius: 24px; padding: 25px 20px; transform: scale(0.95) translateY(20px); transition: 0.4s var(--ease-spring); display: flex; flex-direction: column; align-items: center; margin: auto; max-height: 80vh; overflow-y: auto;}
.center-modal.active .modal-dialog { transform: scale(1) translateY(0); }

.modal-drag-handle { width: 40px; height: 4px; background: var(--border-light); border-radius: 2px; margin-bottom: 25px; flex-shrink: 0;}
.modal-title { font-size: 16px; font-weight: 800; letter-spacing: 1.5px; margin-bottom: 24px; color: #fff; text-align: center; text-transform: uppercase;}

.input-wrapper { width: 100%; margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px;}
.input-label { font-size: 10px; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; padding-left: 4px;}
.input-base { width: 100%; padding: 14px 16px; background: var(--bg-elevated); border: 1px solid var(--border-light); border-radius: 12px; color: #fff; font-size: 14px; transition: 0.3s; outline: none; box-sizing: border-box; }
.input-base:focus { border-color: var(--border-strong); background: #000; box-shadow: 0 0 20px rgba(255,255,255,0.05); }

/* Стили для Select/Dropdown */
select.input-base { appearance: none; background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 16px center; background-size: 16px; }

.modal-actions { width: 100%; display: flex; flex-direction: column; gap: 10px; margin-top: 10px;}
.btn-submit { width: 100%; padding: 16px; background: #fff; color: #000; font-weight: 800; font-size: 13px; border-radius: 12px; border: none; text-transform: uppercase; letter-spacing: 1px; cursor: pointer; transition: 0.2s; display: flex; justify-content: center; align-items: center;}
.btn-submit:active { transform: scale(0.96); background: #ccc; }

.btn-cancel {
    width: 100%; padding: 14px; background: transparent;
    border: 1px solid var(--border-light); border-radius: 12px;
    color: var(--text-muted); font-weight: 700; font-size: 12px;
    text-transform: uppercase; letter-spacing: 1px; cursor: pointer;
    transition: 0.2s; display: flex; justify-content: center; align-items: center;
}
.btn-cancel:active { background: rgba(255,255,255,0.05); color: #fff; border-color: rgba(255,255,255,0.3); }
