/* panel.css — the Live Control Panel look, lifted from the PHP panel's
   inline <style> blocks so every page shares one stylesheet instead of
   three near-identical copies. Variable names and values are unchanged,
   so anything already styled against them keeps rendering identically. */

:root {
    --bg:       #0d0f12;
    --surface:  #141720;
    --surface2: #191d27;
    --border:   #1e2330;
    --accent:   #00e5a0;
    --accent2:  #0077ff;
    --warn:     #ff4f4f;
    --muted:    #3a3f50;
    --text:     #c8ccd8;
    --text-dim: #5a607a;
    --mono:     'Share Tech Mono', monospace;
    --sans:     'Barlow', sans-serif;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    min-height: 100vh;
    padding: 40px 20px;
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0,229,160,0.06) 0%, transparent 60%),
        repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(255,255,255,0.02) 39px, rgba(255,255,255,0.02) 40px),
        repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(255,255,255,0.02) 39px, rgba(255,255,255,0.02) 40px);
}
body.centered { display: flex; align-items: center; justify-content: center; }

.wrapper { max-width: 860px; margin: 0 auto; }
.wrapper.wide { max-width: 1040px; }

/* ── Header ── */
header { margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.header-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.eyebrow { font-family: var(--mono); font-size: 11px; color: var(--accent); letter-spacing: 0.2em; text-transform: uppercase; margin-bottom: 4px; }
.logo-group h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; color: #fff; }
h1 { font-size: 24px; font-weight: 700; color: #fff; }
.rtmp-url { font-family: var(--mono); font-size: 11px; color: var(--text-dim); text-align: right; }
.rtmp-url span { display: block; color: var(--accent); font-size: 12px; margin-top: 3px; }

/* ── Status chips ── */
.status-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.status-chip {
    display: flex; align-items: center; gap: 6px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 20px; padding: 5px 12px 5px 8px;
    font-family: var(--mono); font-size: 11px; color: var(--text-dim);
    transition: border-color 0.2s;
}
.status-chip.on  { border-color: rgba(0,229,160,0.3); color: var(--text); }
.status-chip.err { border-color: rgba(255,79,79,0.3); color: var(--warn); }
.chip-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex-shrink: 0; transition: background 0.3s, box-shadow 0.3s; }
.chip-dot.on  { background: var(--accent); box-shadow: 0 0 5px var(--accent); }
.chip-dot.err { background: var(--warn);   box-shadow: 0 0 5px var(--warn); }
.status-bar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.btn-refresh {
    display: inline-flex; align-items: center; gap: 6px;
    background: transparent; border: 1px solid var(--border);
    border-radius: 20px; padding: 5px 14px;
    font-family: var(--mono); font-size: 11px; color: var(--text-dim);
    cursor: pointer; transition: border-color 0.2s, color 0.2s;
}
.btn-refresh:hover { border-color: var(--accent); color: var(--accent); }
.btn-refresh .refresh-icon { display: inline-block; transition: transform 0.5s; }
.btn-refresh.spinning .refresh-icon { animation: spin 0.7s linear infinite; }

/* ── Banners ── */
.alert { background: rgba(255,79,79,0.1); border: 1px solid var(--warn); color: var(--warn); padding: 12px 16px; border-radius: 6px; font-family: var(--mono); font-size: 13px; margin-bottom: 24px; }
.banner { padding: 12px 16px; border-radius: 6px; font-family: var(--mono); font-size: 13px; margin-bottom: 24px; display: none; }
.banner.ok  { background: rgba(0,229,160,0.08); border: 1px solid var(--accent); color: var(--accent); }
.banner.err { background: rgba(255,79,79,0.08); border: 1px solid var(--warn);   color: var(--warn); }

.section-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 12px; }

/* ── Cards ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px 24px; margin-bottom: 24px; }
.platforms { display: grid; gap: 12px; margin-bottom: 28px; }
.platforms .card { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 16px; margin-bottom: 0; transition: border-color 0.2s; }
.card.active   { border-color: rgba(0,229,160,0.3); }
.card.inactive { opacity: 0.65; }

.platform-icon { width: 40px; height: 40px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; }
.icon-yt   { background: rgba(255,0,0,0.15);    color: #ff4444; }
.icon-fb   { background: rgba(24,119,242,0.15); color: #1877f2; }
.icon-inst { background: rgba(225,48,108,0.15); color: #e1306c; }
.platform-name { font-weight: 600; font-size: 15px; color: #fff; margin-bottom: 6px; }

/* ── Form fields ── */
.form-field { margin-bottom: 14px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { display: block; font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; color: var(--text-dim); text-transform: uppercase; margin-bottom: 6px; }
.form-field input, .form-field select, .form-field textarea {
    width: 100%; background: rgba(255,255,255,0.04); border: 1px solid var(--muted);
    border-radius: 6px; padding: 9px 12px; font-family: var(--sans); font-size: 13px;
    color: var(--text); outline: none; transition: border-color 0.2s;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--accent); }
.form-field select option { background: #1a1e2a; }
.form-field textarea { resize: vertical; min-height: 80px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

.key-field-wrap { position: relative; }
.key-input {
    width: 100%; background: rgba(255,255,255,0.04); border: 1px solid var(--muted);
    border-radius: 5px; padding: 7px 36px 7px 10px; font-family: var(--mono);
    font-size: 12px; color: var(--text); outline: none; transition: border-color 0.2s;
}
.key-input:focus { border-color: var(--accent); }
.reveal-btn, .clear-key-btn, .pw-reveal {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; color: var(--text-dim);
    font-size: 14px; line-height: 1; transition: color 0.2s;
}
.reveal-btn:hover, .pw-reveal:hover { color: var(--accent); }
.clear-key-btn:hover { color: var(--warn); }
.pw-wrap { position: relative; }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; gap: 8px; padding: 11px 22px;
    border-radius: 7px; border: none; cursor: pointer; font-family: var(--sans);
    font-weight: 600; font-size: 14px; letter-spacing: 0.02em;
    transition: opacity 0.2s, transform 0.1s; text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary   { background: var(--accent); color: #000; }
.btn-primary:hover { opacity: 0.88; }
.btn-danger    { background: transparent; color: var(--warn); border: 1px solid var(--warn); }
.btn-danger:hover { background: rgba(255,79,79,0.1); }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--muted); }
.btn-blue { background: var(--accent2); color: #fff; }
.btn-blue:hover { opacity: 0.88; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 32px; }

.btn-sm { padding: 5px 12px; border-radius: 5px; font-family: var(--mono); font-size: 11px; cursor: pointer; border: 1px solid var(--border); background: transparent; color: var(--text-dim); transition: all 0.2s; }
.btn-sm:hover { border-color: var(--accent); color: var(--accent); }
.btn-del { color: var(--warn); border-color: var(--warn); }
.btn-del:hover { background: rgba(255,79,79,0.08); }

/* ── Badges ── */
.role-badge { font-family: var(--mono); font-size: 10px; font-weight: 700; padding: 3px 10px; border-radius: 4px; }
.role-admin  { background: rgba(0,229,160,0.12); color: var(--accent); }
.role-viewer { background: rgba(90,96,122,0.2);  color: var(--text-dim); }
.group-badge { font-family: var(--mono); font-size: 11px; padding: 3px 10px; border-radius: 4px; background: rgba(0,119,255,0.12); color: #4da6ff; }
.you-badge { font-family: var(--mono); font-size: 10px; padding: 2px 8px; border-radius: 4px; background: rgba(0,119,255,0.12); color: #4da6ff; margin-left: 6px; }
.group-viewing-badge { font-family: var(--mono); font-size: 10px; background: rgba(0,119,255,0.15); color: #4da6ff; border: 1px solid rgba(0,119,255,0.3); border-radius: 4px; padding: 2px 8px; letter-spacing: 0.08em; white-space: nowrap; }
.group-own-badge { font-family: var(--mono); font-size: 10px; background: rgba(0,229,160,0.1); color: var(--accent); border: 1px solid rgba(0,229,160,0.2); border-radius: 4px; padding: 2px 8px; letter-spacing: 0.08em; white-space: nowrap; }

/* ── Group switcher ── */
.group-switcher { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; }
.group-switcher-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-dim); white-space: nowrap; }
.group-select { background: transparent; border: none; outline: none; font-family: var(--mono); font-size: 12px; color: #4da6ff; cursor: pointer; padding: 0; appearance: none; -webkit-appearance: none; min-width: 80px; }
.group-select option { background: #1a1e2a; color: var(--text); }
.group-select-arrow { color: var(--text-dim); font-size: 10px; pointer-events: none; }

/* ── Tables ── */
.users-table { width: 100%; border-collapse: collapse; margin-bottom: 28px; }
.users-table th { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-dim); text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface); }
.users-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14px; background: var(--surface); vertical-align: middle; }
.users-table tr:last-child td { border-bottom: none; }
.users-table tr:hover td { background: var(--surface2); }
.mono { font-family: var(--mono); font-size: 12px; }
.tbl-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Collapsible panels ── */
.event-panel, .tokens-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 28px; overflow: hidden; }
.event-header, .tokens-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; cursor: pointer; user-select: none; }
.event-header-left, .tokens-header-left { display: flex; align-items: center; gap: 12px; }
.event-icon { width: 36px; height: 36px; border-radius: 8px; background: rgba(0,119,255,0.15); display: flex; align-items: center; justify-content: center; font-size: 16px; }
.event-title, .tokens-title { font-weight: 600; font-size: 15px; color: #fff; }
.event-subtitle, .tokens-subtitle { font-family: var(--mono); font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.chevron { color: var(--text-dim); font-size: 12px; transition: transform 0.25s; }
.chevron.open { transform: rotate(180deg); }
.event-body, .tokens-body { display: none; border-top: 1px solid var(--border); }
.event-body.open, .tokens-body.open { display: block; }
.tokens-body { padding: 20px 24px; }

/* ── Preview panel ── */
.preview-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 24px; transition: border-color 0.3s; }
.preview-panel.live { border-color: rgba(0,229,160,0.4); }
.preview-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.preview-header-left { display: flex; align-items: center; gap: 10px; }
.live-badge { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: 0.1em; }
.live-badge .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); position: relative; }
.live-badge.is-live .pulse { background: #ff3b3b; box-shadow: 0 0 6px #ff3b3b; animation: livepulse 1.4s ease-in-out infinite; }
.live-badge.is-live .live-text { color: #ff3b3b; }
.live-text { color: var(--text-dim); }
@keyframes livepulse { 0%,100% { box-shadow: 0 0 4px #ff3b3b; } 50% { box-shadow: 0 0 12px #ff3b3b, 0 0 20px rgba(255,59,59,0.4); } }

.stream-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.meta-pill { font-family: var(--mono); font-size: 10px; color: var(--text-dim); background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: 4px; padding: 2px 8px; }
.meta-pill.hi { color: var(--accent); border-color: rgba(0,229,160,0.2); }
.preview-toggle { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 5px 12px; font-family: var(--mono); font-size: 11px; color: var(--text-dim); cursor: pointer; transition: all 0.2s; white-space: nowrap; }
.preview-toggle:hover { border-color: var(--accent); color: var(--accent); }

.preview-body { display: none; }
.preview-body.open { display: block; }
.video-wrap { position: relative; background: #000; aspect-ratio: 16 / 9; max-height: 340px; overflow: hidden; }
.preview-video { width: 100%; height: 100%; display: block; object-fit: contain; }
.video-overlay {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 10px;
    background: rgba(0,0,0,0.45); font-family: var(--mono); font-size: 13px;
    color: var(--text-dim); transition: opacity 0.3s;
}
.video-overlay.hidden { opacity: 0; pointer-events: none; }
.overlay-icon { font-size: 32px; opacity: 0.4; }

/* Standby card — stands in for the picture when the relay runs elsewhere */
.standby-layer { position: absolute; inset: 0; background: #000; display: none; }
.standby-layer.show { display: block; }
.standby-layer img { width: 100%; height: 100%; object-fit: contain; display: block; }
.standby-note {
    position: absolute; left: 0; right: 0; bottom: 0; padding: 7px 10px;
    text-align: center; font-family: var(--mono); font-size: 10px;
    letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim);
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
}

.stream-stats { display: flex; border-top: 1px solid var(--border); background: rgba(0,0,0,0.3); }
.stat-cell { flex: 1; padding: 8px 14px; border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.stat-cell:last-child { border-right: none; }
.stat-label { font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em; color: var(--text-dim); text-transform: uppercase; }
.stat-value { font-family: var(--mono); font-size: 13px; color: var(--text); }
.stat-value.accent { color: var(--accent); }

.no-stream-placeholder { display: flex; align-items: center; gap: 14px; padding: 18px 20px; font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
.no-stream-icon { font-size: 22px; opacity: 0.35; }

/* ── Sign-in page ── */
.auth-wrap { width: 100%; max-width: 380px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 32px 28px; }
.auth-card h1 { font-size: 20px; margin-bottom: 22px; }
.auth-card .form-field { margin-bottom: 16px; }
.auth-card .banner { margin-bottom: 18px; }
.auth-footer { text-align: center; margin-top: 18px; font-family: var(--mono); font-size: 11px; color: var(--text-dim); }

/* ── Footer + misc ── */
footer { text-align: center; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border); font-family: var(--mono); font-size: 11px; color: var(--text-dim); }
footer a { color: var(--text-dim); text-decoration: none; }
footer a:hover { color: var(--accent); }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(0,0,0,0.3); border-top-color: #000; border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: middle; }
.spinner-w { border-color: rgba(255,255,255,0.2); border-top-color: #fff; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
