/* ── reset & base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0d0d0d;
  color: #e0e0e0;
  min-height: 100vh;
  font-size: 14px;
}

a { color: inherit; text-decoration: none; }

/* ── topbar ───────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  padding: 0 32px;
  height: 56px;
  background: #141414;
  border-bottom: 1px solid #222;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

/* ── main ─────────────────────────────────────────────────────────────── */
main { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }

/* ── page header ──────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
}
.page-title { font-size: 26px; font-weight: 700; color: #fff; }
.page-sub   { color: #666; margin-top: 4px; }
.header-actions { display: flex; gap: 10px; flex-shrink: 0; }

/* ── buttons ──────────────────────────────────────────────────────────── */
.btn {
  padding: 8px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn-primary   { background: #fff;    color: #000; }
.btn-secondary { background: #1e1e1e; color: #ccc; border: 1px solid #333; }
.btn-danger-sm { background: #2a0a0a; color: #f66; border: 1px solid #511; padding: 5px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.btn-sm { background: #222; color: #ccc; border: 1px solid #333; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background .15s;
  color: #888;
}
.btn-icon:hover  { background: #222; color: #fff; }
.btn-icon.btn-danger:hover { color: #f66; }
.btn-start { color: #5a5; }
.btn-stop  { color: #f88; }

/* ── card / table ─────────────────────────────────────────────────────── */
.card { background: #161616; border: 1px solid #222; border-radius: 12px; overflow: hidden; }

.table-header {
  display: grid;
  grid-template-columns: 1fr 100px 160px 120px;
  padding: 10px 20px;
  font-size: 12px;
  color: #555;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid #1e1e1e;
}

.table-row {
  display: grid;
  grid-template-columns: 1fr 100px 160px 120px;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid #1a1a1a;
  transition: background .15s;
}
.table-row:last-child { border-bottom: none; }
.table-row:hover      { background: #1a1a1a; }

.row-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #2a2a2a;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: #fff;
  flex-shrink: 0;
}
.row-name  { display: flex; align-items: center; gap: 12px; }
.row-title { font-weight: 600; color: #fff; }
.row-sub   { color: #555; font-size: 12px; margin-top: 2px; }

.row-viewers { color: #888; display: flex; align-items: center; gap: 4px; }
.viewers-icon { font-size: 12px; }

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

/* ── status badges ────────────────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.status-live       { background: #0d2e0d; color: #4caf50; border: 1px solid #1a4a1a; }
.status-stopped    { background: #1a1a1a; color: #666;    border: 1px solid #2a2a2a; }
.status-starting   { background: #1a1a2a; color: #88a;    border: 1px solid #2a2a4a; }
.status-connecting { background: #1a1a2a; color: #88a;    border: 1px solid #2a2a4a; }
.status-creating   { background: #1a1a2a; color: #88a;    border: 1px solid #2a2a4a; }
.status-waiting    { background: #1a1a2a; color: #88a;    border: 1px solid #2a2a4a; }
.status-resting    { background: #2a1a0a; color: #ca8;    border: 1px solid #4a2a0a; }
.status-error      { background: #2a0a0a; color: #f66;    border: 1px solid #511;    }

/* ── empty state ──────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: #555;
}
.empty-icon  { font-size: 48px; margin-bottom: 16px; opacity: .3; }
.empty-title { font-size: 20px; font-weight: 600; color: #888; margin-bottom: 8px; }
.empty-sub   { margin-bottom: 24px; }

/* ── modal ────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: #161616;
  border: 1px solid #2a2a2a;
  border-radius: 14px;
  padding: 28px;
  width: 440px;
  max-width: 95vw;
}
.modal-title  { font-size: 20px; font-weight: 700; color: #fff; margin-bottom: 20px; }
.modal-footer { display: flex; gap: 10px; margin-top: 24px; }

/* ── form elements ────────────────────────────────────────────────────── */
.form-group  { margin-bottom: 16px; }
.form-label  { display: block; color: #999; font-size: 12px; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
.form-hint   { color: #555; font-size: 12px; margin-top: 6px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: #1a1a1a;
  border: 1px solid #2e2e2e;
  border-radius: 8px;
  color: #e0e0e0;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: #555; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select option { background: #1a1a1a; }

/* ── toggle ───────────────────────────────────────────────────────────── */
.toggle { position: relative; display: inline-block; width: 48px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0;
  background: #2a2a2a;
  border-radius: 13px;
  cursor: pointer;
  transition: background .2s;
}
.slider::before {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.toggle input:checked + .slider              { background: #4caf50; }
.toggle input:checked + .slider::before     { transform: translateX(22px); }
.toggle input:disabled + .slider            { opacity: .5; cursor: default; }

/* ── settings layout ──────────────────────────────────────────────────── */
.settings-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0;
  background: #141414;
  border: 1px solid #222;
  border-radius: 14px;
  overflow: hidden;
  min-height: calc(100vh - 120px);
}

.settings-sidebar {
  border-right: 1px solid #1e1e1e;
  display: flex;
  flex-direction: column;
}

.settings-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid #1e1e1e;
}
.settings-avatar {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: #2a2a2a;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; color: #fff;
  flex-shrink: 0;
}
.settings-name { font-weight: 600; color: #fff; }
.settings-sub  { color: #555; font-size: 12px; margin-top: 2px; }

.settings-nav { padding: 8px 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: #888;
  cursor: pointer;
  border-radius: 0;
  transition: background .15s, color .15s;
  font-size: 14px;
  border-left: 2px solid transparent;
}
.nav-item:hover  { background: #1a1a1a; color: #ccc; }
.nav-item.active { background: #1e1e1e; color: #fff; border-left-color: #fff; }

/* ── settings content ─────────────────────────────────────────────────── */
.settings-content { display: flex; flex-direction: column; }

.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid #1e1e1e;
  background: #111;
}
.control-btns { display: flex; gap: 8px; }

.tab-panel { display: none; padding: 28px; flex: 1; }
.tab-panel.active { display: block; }

.panel-title { font-size: 18px; font-weight: 700; color: #fff; margin-bottom: 4px; }
.panel-sub   { color: #666; margin-bottom: 4px; }
.divider     { border: none; border-top: 1px solid #1e1e1e; margin: 20px 0; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.setting-row label:first-child { color: #ccc; }

.setting-row-double {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.info-box {
  background: #111;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 12px 16px;
  color: #888;
  font-size: 13px;
  line-height: 1.5;
  margin-top: 12px;
}

/* ── upload zone ──────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed #2a2a2a;
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  color: #666;
  transition: border-color .2s, background .2s;
  margin-bottom: 16px;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: #555;
  background: #1a1a1a;
  color: #aaa;
}
.upload-icon { font-size: 28px; margin-bottom: 8px; }
.upload-hint { font-size: 12px; color: #444; margin-top: 4px; }

/* ── file list ────────────────────────────────────────────────────────── */
.file-list { margin-bottom: 16px; }
.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #1a1a1a;
  border: 1px solid #222;
  border-radius: 8px;
  margin-bottom: 6px;
  transition: background .15s;
}
.file-row:hover { background: #202020; }

.file-thumb {
  width: 48px; height: 36px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.file-thumb-video { background: #1a1a2e; }
.file-thumb-img   { background: #1e1a1a; }

.file-info { flex: 1; min-width: 0; }
.file-name { font-weight: 500; color: #ddd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { color: #555; font-size: 12px; margin-top: 2px; }
.file-actions { display: flex; gap: 4px; flex-shrink: 0; }
.empty-list { color: #444; text-align: center; padding: 20px; font-size: 13px; }

/* ── progress bar ─────────────────────────────────────────────────────── */
.progress-bar-wrap { margin-bottom: 12px; }
.progress-label    { color: #888; font-size: 12px; margin-bottom: 6px; }
.progress-bar { background: #1a1a1a; border-radius: 4px; height: 6px; overflow: hidden; }
.progress-fill { background: #4caf50; height: 100%; width: 60%; animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:.6} 50%{opacity:1} }

/* ── save bar ─────────────────────────────────────────────────────────── */
.save-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 28px;
  border-top: 1px solid #1e1e1e;
  background: #111;
  margin-top: auto;
}
.save-msg { color: #6a8; font-size: 13px; }

/* ── channels modal ───────────────────────────────────────────────────── */
.channels-list { margin-bottom: 8px; }
.channel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid #222;
}
.channel-row:last-child { border-bottom: none; }
.channel-name { font-weight: 600; color: #fff; }
.channel-connected-box {
  background: #0d1a0d;
  border: 1px solid #1a3a1a;
  border-radius: 10px;
  padding: 16px 20px;
}

/* ── video processing additions ───────────────────────────────────────── */
.video-status-ready      { color: #69b86d; }
.video-status-queued     { color: #b79b68; }
.video-status-processing { color: #8aa1d1; }
.video-status-error      { color: #f66; }
.file-error {
  color: #b86666;
  font-size: 11px;
  margin-top: 4px;
  white-space: normal;
  overflow-wrap: anywhere;
  max-height: 42px;
  overflow: hidden;
}
.btn-disabled, .btn-icon:disabled {
  opacity: .35;
  cursor: not-allowed;
}
.stream-warning {
  padding: 9px 28px;
  background: #2a210c;
  border-bottom: 1px solid #4b3b16;
  color: #d5b76d;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.progress-fill {
  width: 0;
  transition: width .15s linear;
  animation: none;
}
