/* Modern Dark Theme CSS for RTMP Restream Studio */
:root {
  --bg-dark: #0b0f19;
  --bg-card: #131b2e;
  --bg-card-hover: #18233c;
  --bg-input: #0a0e17;
  --border-color: #1e293b;
  --border-focus: #3b82f6;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  --accent-green: #10b981;
  --accent-green-hover: #059669;
  --accent-red: #ef4444;
  --accent-red-hover: #dc2626;
  --accent-yellow: #f59e0b;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: var(--font-mono);
}

.app-layout {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  gap: 24px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

.app-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Status Pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 9999px;
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--accent-red);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  transition: all 0.3s ease;
}

.status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.status-pill.live {
  background-color: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--accent-green);
}

.status-pill.live .dot {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.2); }
  100% { opacity: 1; transform: scale(1); }
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.metric-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.metric-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.metric-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 20px;
  align-items: stretch;
}

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

.grid-col {
  display: flex;
  flex-direction: column;
}

.flex-col { display: flex; flex-direction: column; }
.gap-6 { gap: 20px; }
.flex-1 { flex: 1; }
.padding-0 { padding: 0 !important; }

/* Cards */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-title h2 {
  font-size: 1rem;
  font-weight: 700;
}

.card-body {
  padding: 20px;
  flex: 1;
}

/* WebRTC Player Container */
.player-container {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 Aspect Ratio */
  background-color: #000;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  overflow: hidden;
}

.player-container iframe,
.player-container video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  object-fit: contain;
}

.header-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  outline: none;
  font-family: inherit;
}

.btn-primary {
  background-color: var(--accent-blue);
  color: white;
}

.btn-primary:hover {
  background-color: var(--accent-blue-hover);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.4);
}

.btn-primary.btn-stop {
  background-color: var(--accent-red);
}

.btn-primary.btn-stop:hover {
  background-color: var(--accent-red-hover);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
}

.btn-secondary {
  background-color: #1e293b;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: #334155;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  color: var(--text-primary);
}

.btn-lg {
  padding: 10px 20px;
  font-size: 1rem;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.825rem;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 0.75rem;
}

/* Forms & Inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  width: 100%;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.sm-input {
  width: 60px;
  padding: 4px 8px;
  text-align: center;
}

.input-with-button {
  display: flex;
  gap: 8px;
}

.help-text {
  font-size: 0.775rem;
  color: var(--text-muted);
}

.options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-secondary);
}

.input-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.825rem;
  color: var(--text-secondary);
}

/* Console Box */
.console-box {
  background-color: #060911;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  padding: 12px;
  height: 280px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.log-line {
  line-height: 1.4;
  word-break: break-all;
  color: #cbd5e1;
}

.log-line .log-time {
  color: #64748b;
  margin-right: 6px;
}

.log-line.info { color: #94a3b8; }
.log-line.success { color: #34d399; }
.log-line.warning { color: #fbbf24; }
.log-line.error { color: #f87171; }
.log-line.debug { color: #64748b; }

/* Destinations List */
.destinations-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dest-card {
  background-color: #0d1424;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: all 0.2s ease;
}

.dest-card:hover {
  border-color: #334155;
  background-color: var(--bg-card-hover);
}

.dest-card.disabled {
  opacity: 0.6;
}

.dest-info {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.dest-platform-badge {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  background-color: #1e293b;
  flex-shrink: 0;
}

.dest-platform-badge.youtube { background-color: rgba(255, 0, 0, 0.15); color: #ff4d4d; }
.dest-platform-badge.twitch { background-color: rgba(145, 70, 255, 0.15); color: #a970ff; }
.dest-platform-badge.facebook { background-color: rgba(24, 119, 242, 0.15); color: #1877f2; }
.dest-platform-badge.kick { background-color: rgba(83, 252, 24, 0.15); color: #53fc18; }
.dest-platform-badge.custom { background-color: rgba(148, 163, 184, 0.15); color: #94a3b8; }

.dest-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.dest-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dest-title {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dest-url-preview {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dest-stats {
  display: flex;
  gap: 12px;
  font-size: 0.775rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.badge {
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.725rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-idle { background-color: #1e293b; color: #94a3b8; }
.badge-connecting { background-color: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.badge-streaming { background-color: rgba(16, 185, 129, 0.2); color: #10b981; }
.badge-reconnecting { background-color: rgba(239, 68, 68, 0.2); color: #ef4444; }
.badge-error { background-color: rgba(239, 68, 68, 0.3); color: #f87171; }

.dest-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #1e293b;
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent-green);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* Dialog / Modal */
.app-dialog {
  border: none;
  border-radius: var(--radius-md);
  background-color: var(--bg-card);
  color: var(--text-primary);
  padding: 0;
  max-width: 500px;
  width: 90%;
  margin: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
}

.app-dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.dialog-content {
  padding: 24px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}
.btn-close:hover { color: var(--text-primary); }

.preset-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-preset {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-preset.active, .btn-preset:hover {
  border-color: var(--accent-blue);
  color: var(--text-primary);
  background-color: rgba(59, 130, 246, 0.1);
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state svg {
  margin-bottom: 12px;
  opacity: 0.4;
}

/* Credentials Breakdown Box */
.credentials-box {
  background-color: #090e18;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin: 14px 0;
}

.cred-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.8rem;
}

.cred-title {
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cred-sub {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.775rem;
}

.sm-text {
  font-size: 0.825rem;
}

.margin-b-8 { margin-bottom: 8px; }
.margin-b-0 { margin-bottom: 0; }
.margin-t-16 { margin-top: 16px; }

.badge-streaming {
  background-color: rgba(16, 185, 129, 0.2);
  color: #10b981;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

/* Compact broadcast-console treatment */
:root {
  --bg-dark: #060a12;
  --bg-card: #0c1423;
  --bg-card-hover: #111c30;
  --bg-input: #070d18;
  --border-color: #18263b;
  --border-focus: #2878e8;
  --text-primary: #e7edf7;
  --text-secondary: #8b9ab0;
  --text-muted: #5e6e85;
  --accent-blue: #2e78ed;
  --accent-blue-hover: #3b87ff;
  --accent-green: #19c992;
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --shadow-md: 0 5px 18px rgba(0, 0, 0, 0.25);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
  background: #060a12;
  background-image: linear-gradient(rgba(25, 44, 75, 0.08) 1px, transparent 1px), linear-gradient(90deg, rgba(25, 44, 75, 0.08) 1px, transparent 1px);
  background-size: 32px 32px;
  font-size: 12px;
}

.app-layout {
  max-width: 1440px;
  padding: 12px 16px 20px;
  gap: 12px;
}

.app-header {
  min-height: 62px;
  padding: 10px 14px;
  border-radius: 0;
  background: rgba(8, 14, 26, 0.94);
  border-color: #17243a;
}

.logo-area { gap: 10px; }
.logo-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #0e203d;
  color: #438eff;
  box-shadow: inset 0 0 0 1px #1e4a86;
}
.logo-icon svg { width: 18px; height: 18px; }
.app-header h1 { font-size: 0.92rem; letter-spacing: 0; }
.subtitle { font-size: 0.61rem; color: #71819a; margin-top: 1px; }
.header-actions { gap: 8px; }
.status-pill { padding: 4px 8px; border-radius: 5px; font-size: 0.6rem; gap: 5px; }
.status-pill .dot { width: 6px; height: 6px; }

.btn { padding: 6px 10px; border-radius: 5px; font-size: 0.68rem; gap: 5px; }
.btn-lg { padding: 7px 12px; font-size: 0.72rem; }
.btn-sm { padding: 5px 9px; font-size: 0.65rem; }
.btn-xs { padding: 3px 7px; font-size: 0.6rem; }
.btn-primary { box-shadow: 0 0 12px rgba(46, 120, 237, 0.18); }
.btn-secondary { background: #17243a; border-color: #223452; }

.metrics-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.metric-card { padding: 11px 12px; border-radius: 8px; background: #0b1423; }
.metric-header { margin-bottom: 5px; font-size: 0.58rem; text-transform: uppercase; letter-spacing: 0.05em; }
.metric-header svg { width: 13px; height: 13px; color: #3987f5; }
.metric-value { font-size: 1.18rem; letter-spacing: 0; }
.metric-sub { font-size: 0.6rem; margin-top: 2px; }

.dashboard-grid { grid-template-columns: minmax(280px, 312px) minmax(0, 1fr); gap: 12px; }
.gap-6 { gap: 12px; }
.card { border-radius: 8px; background: #0b1423; border-color: #17253a; box-shadow: none; }
.card-header { padding: 9px 11px; min-height: 39px; border-color: #17253a; }
.card-title { gap: 7px; }
.card-title svg { width: 15px; height: 15px; color: #5f8ed2; }
.card-title h2 { font-size: 0.7rem; letter-spacing: 0.02em; text-transform: uppercase; }
.card-body { padding: 11px; }

.player-container { padding-top: 64%; background: #02050a; }
.player-container::after {
  content: 'AWAITING INGEST FEED';
  position: absolute;
  inset: 50% 0 auto;
  transform: translateY(-50%);
  text-align: center;
  color: #38506e;
  font: 0.57rem var(--font-mono);
  letter-spacing: 0.08em;
  pointer-events: none;
}
.player-status {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: calc(50% + 22px);
  transform: translateX(-50%);
  width: 90%;
  color: #627692;
  font: 0.54rem var(--font-mono);
  text-align: center;
  letter-spacing: 0.04em;
  pointer-events: none;
}
.player-status.live { color: #1bcf96; }
.player-status.warning { color: #e9b84b; }
.player-status.error { color: #ef7272; }

.form-group { gap: 4px; margin-bottom: 11px; }
.form-group label { font-size: 0.61rem; text-transform: uppercase; letter-spacing: 0.04em; }
.form-control { padding: 7px 9px; border-radius: 4px; font-size: 0.66rem; }
.help-text { font-size: 0.58rem; }
.credentials-box { padding: 9px; margin: 10px 0; border-radius: 5px; }
.cred-header { margin-bottom: 7px; font-size: 0.6rem; }
.cred-title { font-size: 0.58rem; }
.cred-sub { font-size: 0.58rem; }
.sm-text { font-size: 0.62rem; }
.options-row { margin-top: 8px; gap: 8px; }
.checkbox-label, .input-inline { font-size: 0.62rem; }
.sm-input { width: 42px; padding: 3px 5px; }

.destinations-list { gap: 8px; }
.dest-card { padding: 9px 10px; gap: 10px; border-radius: 8px; background: #0b1423; }
.dest-card:hover { border-color: #2d5b91; }
.dest-info { gap: 9px; }
.dest-platform-badge { width: 28px; height: 28px; border-radius: 7px; font-size: 0.8rem; }
.dest-details { gap: 1px; }
.dest-title { font-size: 0.68rem; }
.dest-name-row { gap: 5px; }
.dest-url-preview { font-size: 0.57rem; }
.dest-stats { gap: 8px; font-size: 0.58rem; margin-top: 3px; }
.badge { padding: 1px 5px; font-size: 0.52rem; border-radius: 3px; }
.dest-actions { gap: 4px; }
.switch { width: 27px; height: 15px; }
.slider:before { width: 11px; height: 11px; left: 2px; bottom: 2px; }
input:checked + .slider:before { transform: translateX(12px); }
.dest-actions .btn-toggle-stream { min-width: 34px; }

.console-box { height: 180px; padding: 9px; font-size: 0.62rem; }
.log-line { line-height: 1.35; }
.empty-state { padding: 28px 16px; font-size: 0.7rem; }
.empty-state small { font-size: 0.6rem; }

.dialog-content { padding: 18px; }
.app-dialog { max-width: 440px; }
.dialog-header { margin-bottom: 15px; }
.preset-buttons { gap: 5px; }
.btn-preset { padding: 5px 8px; font-size: 0.62rem; }
.dialog-footer { margin-top: 18px; }

@media (max-width: 760px) {
  .app-layout { padding: 8px; }
  .app-header { align-items: flex-start; gap: 10px; flex-direction: column; }
  .header-actions { width: 100%; justify-content: space-between; }
  .metrics-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dest-card { align-items: flex-start; }
  .dest-actions { flex-wrap: wrap; justify-content: flex-end; }
}
