/* Stream Player — matches MediaFlow dark theme */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --bg: #0a0a0f;
    --bg-alt: #111118;
    --surface: #1a1a24;
    --border: #2a2a3a;
    --text: #e8e8f0;
    --text-muted: #8888aa;
    --accent: #FF9900;
    --accent-blue: #146EB4;
    --accent-green: #2ECC71;
    --accent-purple: #9B59B6;
    --accent-red: #E74C3C;
    --mono: 'JetBrains Mono', ui-monospace, monospace;
}
body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

.navbar {
    position: sticky; top: 0; z-index: 100;
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.75rem 1.5rem;
    background: rgba(10,10,15,0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
.nav-brand { display: flex; align-items: center; gap: 0.75rem; font-weight: 700; font-size: 1.05rem; }
.nav-links { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.nav-links a { color: var(--text-muted); text-decoration: none; font-size: 0.85rem; font-weight: 500; }
.nav-links a:hover { color: var(--accent); }
.tool-title { font-size: 0.9rem; font-weight: 600; color: var(--accent); }
.nav-tool-link { color: var(--text-muted); }

.player-page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 1.25rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: calc(100vh - 56px);
}

.player-toolbar {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.1rem;
}
.url-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}
#streamUrl {
    flex: 1 1 280px;
    min-width: 0;
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #0d1117;
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.8rem;
}
#streamUrl:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
#streamType {
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 600;
}
.btn-primary, .btn-secondary, .btn-chip, .btn-tiny {
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
    font-size: 0.8rem;
}
.btn-primary {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
    padding: 0.55rem 1rem;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary {
    background: var(--surface);
    color: var(--text);
    padding: 0.55rem 0.9rem;
}
.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.sample-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    margin-top: 0.75rem;
}
.sample-label { font-size: 0.75rem; color: var(--text-muted); margin-right: 0.25rem; }
.btn-chip {
    background: var(--surface);
    color: var(--text-muted);
    padding: 0.3rem 0.65rem;
    font-size: 0.72rem;
}
.btn-chip:hover { border-color: var(--accent); color: var(--accent); }
.link-chip { text-decoration: none; display: inline-flex; align-items: center; }
.cors-note {
    margin-top: 0.65rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.45;
}
.cors-note strong { color: var(--text); }

.player-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 1rem;
    flex: 1;
    min-height: 0;
}
@media (max-width: 960px) {
    .player-layout { grid-template-columns: 1fr; }
}

.player-stage {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
}
.video-wrap {
    position: relative;
    background: #000;
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
    aspect-ratio: 16 / 9;
}
#video {
    width: 100%;
    height: 100%;
    display: block;
    background: #000;
}
.video-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.55);
    pointer-events: none;
    transition: opacity 0.2s;
}
.video-overlay.hidden { opacity: 0; visibility: hidden; }
.overlay-msg {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    padding: 1rem;
}
.overlay-msg strong { color: var(--accent); }

.player-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.5rem;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.55rem 0.65rem;
}
.stat-k {
    display: block;
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.2rem;
}
.stat-v {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text);
    word-break: break-all;
}

.debug-panel {
    display: flex;
    flex-direction: column;
    min-height: 420px;
    max-height: calc(100vh - 220px);
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.debug-tabs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.65rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.debug-tab {
    appearance: none;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.45rem 0.75rem;
    cursor: pointer;
}
.debug-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.debug-actions {
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}
.btn-tiny {
    background: var(--bg);
    color: var(--text-muted);
    padding: 0.25rem 0.5rem;
    font-size: 0.68rem;
}
.btn-tiny:hover { color: var(--accent); border-color: var(--accent); }
.auto-scroll-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
}
.auto-scroll-label.is-paused {
    color: var(--accent);
}
.net-follow-hint {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--accent);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    background: rgba(255, 153, 0, 0.12);
    border: 1px solid rgba(255, 153, 0, 0.35);
    white-space: nowrap;
}

.debug-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.debug-view { display: none; flex: 1; min-height: 0; flex-direction: column; }
.debug-view.active { display: flex; }

.net-filters, .console-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    padding: 0.45rem 0.65rem;
    border-bottom: 1px solid var(--border);
}
.net-filter {
    appearance: none;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
}
.net-filter.active {
    background: rgba(255,153,0,0.15);
    border-color: rgba(255,153,0,0.45);
    color: var(--accent);
}

.net-table-wrap {
    flex: 1;
    min-height: 0;
    overflow: auto;
}
.net-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.72rem;
    font-family: var(--mono);
}
.net-table th {
    position: sticky;
    top: 0;
    background: var(--surface);
    color: var(--text-muted);
    text-align: left;
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 0.45rem 0.5rem;
    border-bottom: 1px solid var(--border);
    z-index: 1;
}
.net-table td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid rgba(42,42,58,0.7);
    vertical-align: top;
}
.net-table tbody tr {
    cursor: pointer;
}
.net-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.net-table tbody tr.selected { background: rgba(255,153,0,0.1); }
.net-table tbody tr.is-error td { color: #ff8a80; }
.col-id { width: 2.2rem; }
.col-method { width: 3.2rem; }
.col-status { width: 3.2rem; }
.col-type { width: 4.5rem; }
.col-time { width: 4rem; }
.col-size { width: 4rem; }
.col-url { word-break: break-all; color: var(--accent-purple); }
.type-pill {
    display: inline-block;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    background: rgba(136,136,170,0.15);
    color: var(--text-muted);
    text-transform: uppercase;
}
.type-pill.manifest { background: rgba(20,110,180,0.2); color: #79c0ff; }
.type-pill.segment { background: rgba(46,204,113,0.15); color: #7ee787; }
.type-pill.key { background: rgba(155,89,182,0.2); color: #d2a8ff; }
.type-pill.init { background: rgba(255,153,0,0.15); color: var(--accent); }
.type-pill.error { background: rgba(231,76,60,0.2); color: #ff8a80; }
.net-empty td {
    text-align: center;
    color: var(--text-muted);
    font-family: Inter, sans-serif;
    padding: 2rem 1rem;
    cursor: default;
}

.net-detail {
    flex-shrink: 0;
    max-height: 28%;
    overflow: auto;
    border-top: 1px solid var(--border);
    padding: 0.65rem 0.75rem;
    background: #0d1117;
    font-family: var(--mono);
    font-size: 0.7rem;
}
.net-detail-empty { color: var(--text-muted); font-family: Inter, sans-serif; font-size: 0.78rem; }
.net-detail-row {
    display: grid;
    grid-template-columns: 6.5rem 1fr;
    gap: 0.4rem;
    margin-bottom: 0.3rem;
}
.net-detail-k { color: var(--text-muted); }
.net-detail-v { color: var(--text); word-break: break-all; }

.net-table tbody tr.is-manifest { cursor: pointer; }
.net-table tbody tr.is-manifest:hover .col-url { color: var(--accent); }

.net-detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.55rem;
    padding-top: 0.45rem;
    border-top: 1px solid rgba(42, 42, 58, 0.8);
}
.btn-open-viewer {
    color: #79c0ff !important;
    border-color: rgba(121, 192, 255, 0.45) !important;
    background: rgba(20, 110, 180, 0.15);
}
.btn-open-viewer:hover {
    color: #fff !important;
    border-color: #79c0ff !important;
    background: rgba(20, 110, 180, 0.35);
}
.net-detail-hint {
    margin-top: 0.4rem;
    color: var(--text-muted);
    font-family: Inter, sans-serif;
    font-size: 0.72rem;
}

.console-out {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 0.5rem 0.75rem;
    background: #0d1117;
    font-family: var(--mono);
    font-size: 0.72rem;
    line-height: 1.55;
}
.console-line {
    padding: 0.15rem 0;
    border-bottom: 1px solid rgba(42,42,58,0.4);
    word-break: break-word;
}
.console-line .ts { color: #484f58; margin-right: 0.5rem; }
.console-line.level-log { color: #c9d1d9; }
.console-line.level-info { color: #79c0ff; }
.console-line.level-warn { color: #e3b341; }
.console-line.level-error { color: #ff7b72; }
.console-line.level-player { color: #7ee787; }
.console-line.level-network { color: #d2a8ff; }

@media (max-width: 640px) {
    .debug-panel { max-height: none; min-height: 360px; }
    .player-page { padding: 0.75rem; }
}
