:root {
    --bg: #0f1115;
    --bg-elevated: #171a21;
    --bg-card: #1c1f28;
    --border: #2a2e39;
    --text: #e7e9ee;
    --text-muted: #9aa1b1;
    --accent: #5865f2;
    --accent-hover: #4752c4;
    --success: #3ba55d;
    --danger: #ed4245;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 60px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar .brand {
    font-weight: 700;
    font-size: 18px;
    color: var(--text);
}

.nav {
    display: flex;
    gap: 4px;
    align-items: center;
}

.nav a {
    color: var(--text-muted);
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    position: relative;
}

.nav a:hover { color: var(--text); background: rgba(255,255,255,0.05); text-decoration: none; }
.nav a.active { color: var(--text); background: rgba(88,101,242,0.15); }

.badge {
    display: inline-block;
    min-width: 18px;
    padding: 0 5px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    background: var(--danger);
    color: white;
    font-size: 11px;
    border-radius: 999px;
    margin-left: 6px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.user-chip img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

.container-wide { max-width: 1600px; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 16px; }
.subtitle { color: var(--text-muted); margin: 0 0 28px; font-size: 14px; }

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}

.stat .value { font-size: 26px; font-weight: 700; }
.stat .label { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

.dash-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.dash-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.dash-col .card, .dash-columns > .card { margin-bottom: 0; }

@media (max-width: 800px) {
    .dash-columns { grid-template-columns: 1fr; }
}

.scroll-list {
    max-height: 420px;
    overflow-y: auto;
}

.channel-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.channel-chip {
    flex: 1 1 150px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
}

.channel-chip.connected { border-color: rgba(59,165,93,0.35); }

.channel-chip-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
}

.channel-chip-name {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-chip form { margin-top: 10px; }

.btn-ghost {
    width: 100%;
    margin: 0;
    padding: 7px 10px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 13px;
}
.btn-ghost:hover { background: rgba(255,255,255,0.05); color: var(--text); }

/* Mur de lives (admin) : sélection multi-chaînes + chat */
.lives-layout {
    display: grid;
    grid-template-columns: 260px 1fr 340px;
    gap: 16px;
}

@media (max-width: 1100px) {
    .lives-layout { grid-template-columns: 1fr; }
    .lives-sidebar, .lives-chat-panel, .lives-main { max-height: none; }
}

.lives-sidebar, .lives-chat-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    overflow-y: auto;
    max-height: 75vh;
}

.lives-sidebar h2, .lives-chat-panel h2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
}

.lives-channel-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    margin-top: 0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
}
.lives-channel-row:hover { background: rgba(255,255,255,0.05); }
.lives-channel-row.selected { background: rgba(88,101,242,0.18); }
.lives-channel-row.disabled { opacity: 0.5; cursor: not-allowed; }
.lives-channel-row img { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; }
.lives-channel-row input { margin: 0; width: auto; flex-shrink: 0; }

.lives-channel-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.lives-channel-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lives-channel-sub { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.lives-live-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    color: #ff5c5c;
    white-space: nowrap;
    flex-shrink: 0;
}
.lives-live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ff3b3b;
    display: inline-block;
    flex-shrink: 0;
}

.lives-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 700;
    margin: 16px 0 6px;
}
.lives-section-label:first-child { margin-top: 0; }

.lives-main { max-height: 75vh; }

.lives-grid {
    display: grid;
    gap: 10px;
    height: 100%;
    min-height: 420px;
}
.lives-grid-1 { grid-template-columns: 1fr; }
.lives-grid-2 { grid-template-columns: repeat(2, 1fr); }
.lives-grid-3, .lives-grid-4 { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); }

.lives-video-tile {
    display: flex;
    flex-direction: column;
    background: var(--bg-elevated);
    border-radius: var(--radius);
    overflow: hidden;
}

.lives-video-frame {
    position: relative;
    flex: 1;
    min-height: 0;
    background: #000;
}
.lives-video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.lives-video-label {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(0,0,0,0.65);
    color: #fff;
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 999px;
}

.lives-video-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.lives-video-footer img { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; }
.lives-video-footer-text { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.lives-video-footer-text strong { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lives-video-footer-text span { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.lives-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    background: rgba(0,0,0,0.65);
    color: #fff;
    border: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    margin: 0;
    padding: 0;
}

.lives-chat-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}
.lives-chat-tabs button {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    margin: 0;
}
.lives-chat-tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.lives-chat-body iframe { width: 100%; height: 60vh; border: 0; display: block; }

label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
    margin-top: 14px;
}
label:first-child { margin-top: 0; }

input[type=text], input[type=url], input[type=number], select, textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}

textarea { resize: vertical; min-height: 70px; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
}

button, .btn {
    display: inline-block;
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 18px;
}

button:hover, .btn:hover { background: var(--accent-hover); text-decoration: none; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(88,101,242,0.15);
    color: #a3aefc;
    font-size: 12px;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-error { background: rgba(237,66,69,0.12); color: #ff8a8c; border: 1px solid rgba(237,66,69,0.3); }
.alert-success { background: rgba(59,165,93,0.12); color: #6fdc93; border: 1px solid rgba(59,165,93,0.3); }

.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
    text-align: center;
    padding: 24px;
}

.login-screen .btn { font-size: 15px; padding: 12px 28px; margin-top: 0; }

/* Requests / chat */
.requests-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    align-items: start;
}

.thread-list { padding: 0; }
.thread-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text);
}
.thread-item:hover { background: rgba(255,255,255,0.05); text-decoration: none; }
.thread-item.active { background: rgba(88,101,242,0.15); }
.thread-item img { width: 32px; height: 32px; border-radius: 50%; }
.thread-item .meta { flex: 1; min-width: 0; }
.thread-item .name { font-size: 14px; font-weight: 600; }
.thread-item .preview { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-box {
    display: flex;
    flex-direction: column;
    height: 60vh;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
}

.message {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--bg-elevated);
    font-size: 14px;
}
.message .meta { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.message.mine { align-self: flex-end; background: var(--accent); }
.message.mine .meta { color: rgba(255,255,255,0.75); }

.chat-form {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}
.chat-form textarea { flex: 1; min-height: 44px; }
.chat-form button { margin-top: 0; align-self: flex-end; }

.empty-state { color: var(--text-muted); text-align: center; padding: 40px 20px; }
