/* ═══════════════════════════════════════════════════
   RTMP Stream Manager — Styles
   ═══════════════════════════════════════════════════ */

:root {
  --bg: #0f1117;
  --bg-card: #181b23;
  --bg-card-hover: #1e222d;
  --bg-input: #1e222d;
  --border: #2a2e3a;
  --text: #e4e6eb;
  --text-muted: #8b8fa3;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --danger: #ef4444;
  --success: #22c55e;
  --rec: #ef4444;
  --live: #22c55e;
  --radius: 10px;
  --radius-sm: 6px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ─── Header ──────────────────────────────────────── */
.header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 28px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-left h1 { font-size: 18px; font-weight: 600; }
.logo { font-size: 24px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.user-badge {
  font-size: 13px; color: var(--text-muted);
  padding: 4px 12px; background: var(--bg-input); border-radius: 20px;
}

/* ─── Tabs ────────────────────────────────────────── */
.tabs {
  display: flex; gap: 0;
  padding: 0 28px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.tab {
  padding: 12px 20px; border: none; background: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 14px; font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: all .2s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ─── Main ────────────────────────────────────────── */
.main { padding: 24px 28px; max-width: 1400px; margin: 0 auto; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Toolbar ─────────────────────────────────────── */
.toolbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 10px; }

.search-input, .select-input {
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-input);
  color: var(--text); font-size: 13px;
  transition: border-color .2s;
}
.search-input:focus, .select-input:focus { outline: none; border-color: var(--primary); }
.search-input { min-width: 200px; }

/* ─── Stream Grid ─────────────────────────────────── */
.stream-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.stream-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all .2s;
}
.stream-card:hover { border-color: #3a3e4a; transform: translateY(-1px); }
.stream-card.live { border-color: rgba(34, 197, 94, .3); }

.stream-card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: rgba(255,255,255,.02);
  border-bottom: 1px solid var(--border);
}
.stream-status { display: flex; align-items: center; gap: 8px; }

.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-live {
  background: var(--live);
  box-shadow: 0 0 8px rgba(34,197,94,.5);
  animation: pulse 2s infinite;
}
.dot-offline { background: var(--text-muted); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

.status-text { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.stream-card.live .status-text { color: var(--live); }
.stream-card.offline .status-text { color: var(--text-muted); }

.stream-card-body { padding: 16px; }
.stream-label { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.stream-meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-muted); }

/* ─── Video Player ────────────────────────────────── */
.stream-card-player {
  padding: 0;
  border-top: 1px solid var(--border);
}

.player-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
}

.stream-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
}

.player-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  z-index: 2;
  cursor: pointer;
  transition: opacity .3s;
}
.player-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.play-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.3);
  background: rgba(255,255,255,.1);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
  backdrop-filter: blur(8px);
}
.play-btn:hover {
  background: rgba(255,255,255,.2);
  border-color: rgba(255,255,255,.5);
  transform: scale(1.1);
}

.play-hint {
  font-size: 12px;
  color: rgba(255,255,255,.5);
}

.player-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: rgba(0,0,0,.4);
}
.player-bar-left, .player-bar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.player-status {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}
.player-status.status-live {
  color: var(--live);
}

/* ─── Offline Card ────────────────────────────────── */
.stream-card-offline {
  padding: 28px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border);
}
.offline-icon { font-size: 32px; opacity: .3; }

.stream-card-actions {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; align-items: center;
  min-height: 48px;
}

/* ─── Fullscreen Overlay ──────────────────────────── */
.fullscreen-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: #000;
  display: flex;
  flex-direction: column;
}
.fullscreen-overlay.hidden { display: none; }

.fullscreen-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: rgba(0,0,0,.8);
  border-bottom: 1px solid var(--border);
  z-index: 2;
}
.fullscreen-title {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}
.fullscreen-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.fullscreen-player-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}
.fullscreen-player-wrap video {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ─── Buttons ─────────────────────────────────────── */
.btn {
  padding: 8px 16px; border: none; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all .2s; display: inline-flex; align-items: center; gap: 6px;
}
.btn-xs { padding: 4px 8px; font-size: 14px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-rec { background: rgba(239,68,68,.15); color: var(--rec); border: 1px solid rgba(239,68,68,.3); }
.btn-rec:hover { background: rgba(239,68,68,.25); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: rgba(255,255,255,.05); }
.btn-full { width: 100%; justify-content: center; }
.btn-close { background: none; border: none; color: var(--text-muted); font-size: 18px; cursor: pointer; }
.btn-danger-text { color: var(--danger) !important; }

/* ─── Badges ──────────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 20px; font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,.08); color: var(--text-muted);
}
.badge-live { background: rgba(34,197,94,.15); color: var(--live); }
.badge-rec {
  background: rgba(239,68,68,.15); color: var(--rec);
  animation: pulse 1.5s infinite;
}
.badge-admin { background: rgba(99,102,241,.15); color: var(--primary); }

/* ─── Tables ──────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 10px 14px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.data-table tr:hover td { background: rgba(255,255,255,.02); }
.mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 12px; }
.small { font-size: 11px; color: var(--text-muted); }
.text-muted { color: var(--text-muted); font-size: 12px; }

/* ─── Modal ───────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); }
.modal-content {
  position: relative; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; width: 90%; max-width: 1500px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { font-size: 16px; }

/* ─── Forms ───────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 500; margin-bottom: 6px; color: var(--text-muted); }
.form-group input, .form-group select {
  width: 100%; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-input);
  color: var(--text); font-size: 14px;
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--primary); }

/* ─── Toast ───────────────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 20px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  animation: slideIn .3s ease, fadeOut .3s ease 3.5s forwards;
  backdrop-filter: blur(12px);
}
.toast-success { background: rgba(34,197,94,.2); color: var(--success); border: 1px solid rgba(34,197,94,.3); }
.toast-error { background: rgba(239,68,68,.2); color: var(--danger); border: 1px solid rgba(239,68,68,.3); }
.toast-info { background: rgba(99,102,241,.2); color: var(--primary); border: 1px solid rgba(99,102,241,.3); }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(10px); } }

/* ─── Login ───────────────────────────────────────── */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.login-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px; width: 100%; max-width: 400px;
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-icon { font-size: 48px; margin-bottom: 16px; }
.login-header h1 { font-size: 22px; margin-bottom: 8px; }
.login-header p { font-size: 13px; color: var(--text-muted); }
.error-msg { margin-top: 12px; padding: 10px; background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); border-radius: var(--radius-sm); color: var(--danger); font-size: 13px; text-align: center; }
.hidden { display: none !important; }

/* ─── Responsive ──────────────────────────────────── */
@media (max-width: 768px) {
  .header { padding: 12px 16px; }
  .tabs { padding: 0 16px; overflow-x: auto; }
  .main { padding: 16px; }
  .stream-grid { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-left, .toolbar-right { flex-wrap: wrap; }
  .search-input { min-width: 100%; }
}