@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
    --bg-0: #07070c;
    --bg-1: #0c0c14;
    --bg-2: #111119;
    --bg-3: #17171f;
    --bg-4: #1d1d28;
    --bg-hover: #22222e;
    --border: #252535;
    --border-light: #2e2e40;
    --text-1: #ecedf2;
    --text-2: #9a9ab0;
    --text-3: #5c5c72;
    --accent: #00d4aa;
    --accent-dim: #00d4aa22;
    --accent-hover: #00e8bb;
    --red: #f44;
    --red-dim: #f4444418;
    --blue: #4488ff;
    --orange: #ff9500;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 2px 16px rgba(0,0,0,.4);
    --transition: all .2s ease;
}

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

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg-0);
    color: var(--text-1);
    min-height: 100vh;
}

/* ═══ Top Nav ═══ */
.topnav {
    background: var(--bg-1);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    height: 56px;
    gap: 32px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.topnav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--accent);
    letter-spacing: -0.5px;
    flex-shrink: 0;
}

.topnav-logo span {
    width: 28px; height: 28px;
    background: linear-gradient(135deg, var(--accent), #0088ff);
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
}

.topnav-tabs {
    display: flex;
    gap: 4px;
    flex: 1;
}

.topnav-tab {
    padding: 8px 18px;
    border: none;
    background: transparent;
    color: var(--text-2);
    font-family: inherit;
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.topnav-tab:hover { color: var(--text-1); background: var(--bg-3); }
.topnav-tab.active { color: var(--accent); background: var(--accent-dim); }

.topnav-status {
    font-family: 'IBM Plex Mono', monospace;
    font-size: .7rem;
    color: var(--text-3);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.dot-live { width:6px; height:6px; border-radius:50%; background:var(--accent); animation:blink 2s infinite; }
.dot-off { width:6px; height:6px; border-radius:50%; background:var(--red); }

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ═══ Tab Pages ═══ */
.tab-page { display:none; }
.tab-page.active { display:block; }

/* ═══ Player Layout ═══ */
.player-layout {
    display: grid;
    grid-template-columns: 200px 220px 1fr;
    height: calc(100vh - 56px);
}

.sidebar-cats {
    background: var(--bg-1);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 8px 0;
}

.sidebar-cats h3 {
    padding: 12px 16px 8px;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-3);
    font-weight: 600;
}

.cat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: var(--transition);
    font-size: .85rem;
    color: var(--text-2);
    border-left: 3px solid transparent;
}

.cat-item:hover { background: var(--bg-3); color: var(--text-1); }
.cat-item.active { background: var(--accent-dim); color: var(--accent); border-left-color: var(--accent); }

.cat-icon { font-size: 1.1rem; }
.cat-count {
    margin-left: auto;
    font-family: 'IBM Plex Mono', monospace;
    font-size: .65rem;
    color: var(--text-3);
    background: var(--bg-3);
    padding: 1px 6px;
    border-radius: 10px;
}

/* ═══ Channel List ═══ */
.sidebar-channels {
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.channels-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.channels-search {
    flex: 1;
    padding: 7px 10px;
    background: var(--bg-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-1);
    font-family: inherit;
    font-size: .8rem;
    outline: none;
}

.channels-search:focus { border-color: var(--accent); }
.channels-search::placeholder { color: var(--text-3); }

.channel-list { flex:1; overflow-y:auto; }

.ch-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--bg-0);
}

.ch-item:hover { background: var(--bg-hover); }
.ch-item.active { background: var(--accent-dim); }

.ch-logo {
    width: 34px; height: 34px;
    border-radius: 6px;
    background: var(--bg-4);
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem;
    flex-shrink: 0;
    overflow: hidden;
}

.ch-logo img { width:100%; height:100%; object-fit:cover; }

.ch-name {
    font-size: .82rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ch-empty {
    padding: 40px 14px;
    text-align: center;
    color: var(--text-3);
    font-size: .82rem;
}

/* ═══ Player Area ═══ */
.player-area {
    background: var(--bg-0);
    display: flex;
    flex-direction: column;
}

.video-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    position: relative;
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.video-placeholder {
    color: var(--text-3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    font-size: .9rem;
}

.video-placeholder svg { width:48px; height:48px; opacity:.2; }

.player-stats {
    padding: 12px 20px;
    background: var(--bg-1);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 24px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: .72rem;
    color: var(--text-2);
    flex-wrap: wrap;
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-pill .dot { width:6px; height:6px; border-radius:50%; }
.stat-pill .p2p { background:var(--accent); }
.stat-pill .cdn { background:var(--orange); }
.stat-pill .peers { background:var(--blue); }
.stat-pill .upload { background:#a855f7; }

.stat-pill strong { color: var(--text-1); }

/* ═══ Admin Pages ═══ */
.admin-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 24px;
}

.admin-page h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
}

/* ═══ Table ═══ */
.tbl {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-2);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.tbl th {
    padding: 10px 14px;
    text-align: left;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text-3);
    background: var(--bg-3);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}

.tbl td {
    padding: 10px 14px;
    font-size: .84rem;
    border-bottom: 1px solid var(--bg-0);
    color: var(--text-2);
}

.tbl tr:hover td { background: var(--bg-hover); }

.tbl .url-cell {
    font-family: 'IBM Plex Mono', monospace;
    font-size: .7rem;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tbl .actions-cell { text-align: right; white-space: nowrap; }

/* ═══ Buttons ═══ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-accent { background:var(--accent); color:#000; }
.btn-accent:hover { background:var(--accent-hover); }
.btn-ghost { background:transparent; color:var(--text-2); border:1px solid var(--border); }
.btn-ghost:hover { border-color:var(--text-3); color:var(--text-1); }
.btn-edit { background:transparent; color:var(--blue); padding:4px 8px; font-size:.78rem; }
.btn-edit:hover { background:#4488ff15; }
.btn-del { background:transparent; color:var(--red); padding:4px 8px; font-size:.78rem; }
.btn-del:hover { background:var(--red-dim); }
.btn-sm { padding:6px 12px; font-size:.78rem; }

/* ═══ Modal ═══ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    width: 420px;
    max-width: 90vw;
    box-shadow: var(--shadow);
}

.modal h3 {
    font-size: 1rem;
    margin-bottom: 20px;
    font-weight: 600;
}

.form-group { margin-bottom: 14px; }

.form-label {
    display: block;
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-3);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.form-input, .form-select {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-1);
    font-family: inherit;
    font-size: .85rem;
    outline: none;
    transition: var(--transition);
}

.form-input:focus, .form-select:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-3); }
.form-input.mono { font-family: 'IBM Plex Mono', monospace; font-size: .78rem; }

.form-select { appearance: auto; }

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ═══ Settings ═══ */
.setting-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.setting-card h4 {
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.setting-card p {
    font-size: .78rem;
    color: var(--text-3);
    margin-bottom: 12px;
}

/* ═══ Toast ═══ */
.toast-box {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toast {
    padding: 10px 18px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .82rem;
    animation: fadeUp .3s ease;
}

.toast.ok { border-left: 3px solid var(--accent); }
.toast.err { border-left: 3px solid var(--red); }

@keyframes fadeUp { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

/* ═══ Responsive ═══ */
@media (max-width: 900px) {
    .player-layout { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; height: auto; }
    .sidebar-cats { border-right: none; border-bottom: 1px solid var(--border); display: flex; overflow-x: auto; padding: 4px 8px; gap: 4px; }
    .sidebar-cats h3 { display: none; }
    .cat-item { padding: 8px 12px; white-space: nowrap; border-left: none; border-bottom: 2px solid transparent; }
    .cat-item.active { border-left: none; border-bottom-color: var(--accent); }
    .sidebar-channels { border-right: none; border-bottom: 1px solid var(--border); max-height: 200px; }
    .video-container { min-height: 300px; }
}

/* Scrollbar */
::-webkit-scrollbar { width:4px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:var(--border); border-radius:4px; }
