:root {
  --bg-dark: #090c14;
  --bg-card: rgba(18, 24, 38, 0.75);
  --bg-card-hover: rgba(26, 34, 54, 0.85);
  --bg-input: rgba(10, 14, 26, 0.8);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-bright: rgba(255, 255, 255, 0.16);

  --primary: #3b82f6;
  --primary-glow: rgba(59, 130, 246, 0.35);
  --primary-hover: #2563eb;
  --cyan: #06b6d4;
  --emerald: #10b981;
  --purple: #8b5cf6;
  --amber: #f59e0b;
  --rose: #f43f5e;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-subtle);
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Background glowing orbs */
.app-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
}

.orb-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #3b82f6, #06b6d4);
  top: -100px;
  right: -50px;
}

.orb-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, #8b5cf6, #ec4899);
  bottom: -200px;
  left: -100px;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 2rem 3rem 2rem;
}

/* Glass card styling */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding: 1rem 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

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

.brand-icon svg {
  width: 24px;
  height: 24px;
}

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

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

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all 0.3s ease;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-streaming {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

.status-streaming .status-dot {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.status-starting, .status-reconnecting {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

.status-starting .status-dot, .status-reconnecting .status-dot {
  background: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
  animation: pulse 1.5s infinite;
}

.status-idle {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.3);
}

.status-idle .status-dot {
  background: #94a3b8;
}

.status-error {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border-color: rgba(244, 63, 94, 0.3);
}

.status-error .status-dot {
  background: #f43f5e;
  box-shadow: 0 0 8px #f43f5e;
}

/* Dashboard Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.75rem;
  margin-bottom: 2rem;
}

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

/* Player Container */
.player-container {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#videoPlayer {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000000;
}

.video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(9, 12, 20, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 10;
  transition: opacity 0.3s ease;
}

.video-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-content {
  max-width: 80%;
}

.overlay-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(59, 130, 246, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1.25rem auto;
}

.overlay-content h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.overlay-content p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.stream-badge-overlay {
  position: absolute;
  top: 1rem;
  left: 1rem;
  display: flex;
  gap: 0.5rem;
  z-index: 5;
}

.live-pill {
  background: rgba(225, 29, 72, 0.85);
  backdrop-filter: blur(4px);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  letter-spacing: 0.05em;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 50%;
  animation: pulse 1s infinite;
}

.meta-pill {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  color: var(--text-main);
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

/* Player Toolbar */
.player-toolbar {
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: rgba(10, 14, 24, 0.5);
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.stream-url-box {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.25rem 0.5rem;
  flex: 1;
  min-width: 260px;
}

.url-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--cyan);
  padding: 0 0.5rem;
  border-right: 1px solid var(--border-subtle);
}

.stream-url-box input {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  width: 100%;
  outline: none;
}

.toolbar-actions {
  display: flex;
  gap: 0.75rem;
}

/* Sidebar Metrics */
.sidebar-metrics {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.metric-card {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.metric-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.metric-icon svg {
  width: 20px;
  height: 20px;
}

.icon-cyan {
  background: rgba(6, 182, 212, 0.15);
  color: var(--cyan);
}

.icon-emerald {
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald);
}

.icon-purple {
  background: rgba(139, 92, 246, 0.15);
  color: var(--purple);
}

.icon-amber {
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber);
}

.metric-data {
  overflow: hidden;
}

.metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.metric-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

/* Resilience Card */
.resilience-card {
  padding: 1.25rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.card-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
}

.tag-badge {
  background: rgba(255, 255, 255, 0.08);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.resilience-bars {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.bar-group .bar-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.progress-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #06b6d4);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.progress-emerald {
  background: linear-gradient(90deg, #10b981, #34d399);
}

.controls-card {
  padding: 1rem;
}

/* Logs Section */
.logs-section {
  padding: 1.25rem;
}

.logs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.logs-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
}

.logs-title h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.log-console {
  background: #06080e;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  height: 160px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.log-entry {
  line-height: 1.4;
  word-break: break-all;
}

.log-info { color: #94a3b8; }
.log-warn { color: #fbbf24; }
.log-error { color: #fb7185; }

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
}

.btn-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

.btn-warning:hover {
  background: rgba(245, 158, 11, 0.25);
}

.btn-icon {
  background: transparent;
  color: var(--text-muted);
  padding: 0.4rem;
  border-radius: var(--radius-sm);
}

.btn-icon:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.btn-text {
  background: transparent;
  color: var(--text-subtle);
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
}

.btn-text:hover {
  color: var(--text-main);
}

.full-width {
  width: 100%;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.25s ease;
}

.modal-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal {
  width: 90%;
  max-width: 580px;
  padding: 2rem;
  background: #111624;
  border: 1px solid var(--border-bright);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

input[type="text"], input[type="number"], input[type="password"], select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease;
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.helper-text {
  display: block;
  font-size: 0.75rem;
  color: var(--text-subtle);
  margin-top: 0.35rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

/* User Badge & Authentication Modal Styles */
.user-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0.25rem 0.5rem 0.25rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--cyan);
}

.auth-modal {
  max-width: 440px;
}

.auth-header {
  flex-direction: column;
  text-align: center;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.auth-icon {
  width: 48px;
  height: 48px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.25rem;
}

.alert-error {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.3);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 1.25rem;
  text-align: center;
}

/* Animations */
@keyframes spin {
  to { transform: rotate(360deg); }
}

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