/* ==========================================================================
   Design System & Variable Declarations
   ========================================================================== */
:root {
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Premium Carbon & Amber Gold Palette */
  --bg-dark: hsl(222, 18%, 10%);
  --bg-darker: hsl(222, 18%, 6%);
  --glass-bg: rgba(22, 27, 37, 0.7);
  --glass-border: rgba(255, 255, 255, 0.05);
  --glass-glow: rgba(245, 158, 11, 0.03);

  --color-primary: hsl(38, 95%, 55%);     /* Premium Amber Gold */
  --color-primary-glow: rgba(245, 158, 11, 0.3);
  --color-secondary: hsl(212, 85%, 55%);   /* Professional Cobalt Blue */
  --color-success: hsl(142, 70%, 50%);     /* Clean Live Green */
  --color-danger: hsl(0, 80%, 55%);        /* Warm Red */
  
  --text-main: hsl(210, 20%, 98%);
  --text-muted: hsl(215, 15%, 75%);
  --text-inverse: hsl(222, 18%, 5%);

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --transition-smooth: all 0.25s ease;
  --transition-bounce: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.1);
}

/* ==========================================================================
   Reset & Base Styles
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-darker);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary-glow);
}

/* ==========================================================================
   Ambient Background Glows
   ========================================================================== */
.glow-orb {
  display: none; /* Disabled neon cyberpunk glow orbs for a clean titanium interface */
}

@keyframes floatOrb1 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-100px, 80px) scale(1.1); }
}
@keyframes floatOrb2 {
  0% { transform: translate(0, 0) scale(1.1); }
  100% { transform: translate(80px, -120px) scale(0.9); }
}

/* ==========================================================================
   App Layout
   ========================================================================== */
.app-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

/* ==========================================================================
   Header Styles
   ========================================================================== */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--glass-bg);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0 8px var(--color-primary-glow));
}

.brand-text h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  line-height: 1.2;
}

.accent-text {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.version {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-weight: 500;
}

.header-status {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Badges */
.badge {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.03);
}

.badge-room {
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.1);
  font-family: var(--font-mono);
}

.badge-role {
  color: var(--color-primary);
  border-color: rgba(245, 158, 11, 0.2);
  background: rgba(245, 158, 11, 0.04);
  text-transform: capitalize;
}

.badge-status {
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-smooth);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background-color: var(--text-muted);
}

.status-disconnected {
  color: var(--text-muted);
  border-color: var(--glass-border);
}
.status-disconnected .status-dot {
  background-color: var(--text-muted);
}

.status-connecting {
  color: var(--color-secondary);
  border-color: rgba(6, 182, 212, 0.3);
  background: rgba(6, 182, 212, 0.05);
}
.status-connecting .status-dot {
  background-color: var(--color-secondary);
  animation: pulse 1.5s infinite alternate ease-in-out;
}

.status-connected {
  color: var(--color-success);
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.05);
}
.status-connected .status-dot {
  background-color: var(--color-success);
  animation: pulse 1s infinite alternate ease-in-out;
}

/* ==========================================================================
   UI Components: Panels & Dashboard
   ========================================================================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.role-section {
  width: 100%;
  animation: fadeIn 0.4s ease-out;
}

.hidden {
  display: none !important;
}

/* Glassmorphic Panel Core */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 40px 0 rgba(0, 0, 0, 0.4);
  overflow: hidden;
  transition: var(--transition-smooth);
}

.glass-panel:hover {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 50px 0 rgba(0, 0, 0, 0.5), 0 0 20px 0 var(--glass-glow);
}

.panel-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-main);
}

/* Dashboard Grid for Host */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 24px;
  min-height: calc(100vh - 180px);
}

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

/* ==========================================================================
   Stream & Video Elements
   ========================================================================== */
.video-wrapper {
  position: relative;
  background: var(--bg-darker);
  height: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

@media (max-width: 768px) {
  .video-wrapper {
    height: 300px;
  }
}

video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--bg-darker);
}

.video-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
  text-align: center;
  padding: 24px;
}

.video-placeholder svg {
  color: var(--color-primary-glow);
  filter: drop-shadow(0 0 10px rgba(245, 158, 11, 0.15));
}

.video-placeholder p {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-main);
}

.video-placeholder .hint {
  font-size: 0.85rem;
  max-width: 250px;
}

.live-indicator {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background-color: var(--color-danger);
  color: white;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 1px;
  animation: pulse 1s infinite alternate ease-in-out;
}

/* ==========================================================================
   Button Elements
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 24px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-bounce);
  color: var(--text-main);
  outline: none;
  user-select: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, hsl(32, 95%, 45%) 100%);
  border-color: rgba(255, 255, 255, 0.05);
  box-shadow: 0 4px 12px 0 rgba(245, 158, 11, 0.15);
  color: var(--text-inverse);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px 0 rgba(245, 158, 11, 0.25), 0 0 10px 0 var(--color-primary);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--glass-border);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.btn-danger {
  background: linear-gradient(135deg, var(--color-danger) 0%, hsl(350, 89%, 50%) 100%);
  box-shadow: 0 4px 15px 0 rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px 0 rgba(239, 68, 68, 0.4), 0 0 12px 0 var(--color-danger);
}

.btn-unmute {
  background: var(--color-primary);
  color: var(--text-inverse);
  padding: 16px 32px;
  font-size: 1.1rem;
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(245, 158, 11, 0.2);
}
.btn-unmute:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 12px 35px rgba(245, 158, 11, 0.3), 0 0 15px var(--color-primary);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: var(--transition-smooth);
}
.btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

/* ==========================================================================
   Host Controls Layout
   ========================================================================== */
.control-panel {
  display: flex;
  flex-direction: column;
  padding-bottom: 24px;
}

.control-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
}

/* Console Log Box */
.console-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin: 0 24px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  overflow: hidden;
}

.console-header {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.viewer-count {
  color: var(--color-secondary);
}

.console-lines {
  padding: 16px;
  overflow-y: auto;
  max-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.log-line {
  line-height: 1.4;
  color: var(--text-muted);
  word-break: break-all;
}
.log-line.system {
  color: var(--color-primary);
}
.log-line.success {
  color: var(--color-success);
}
.log-line.danger {
  color: var(--color-danger);
}
.log-line.info {
  color: var(--color-secondary);
}

/* ==========================================================================
   Viewer Components
   ========================================================================== */
.viewer-standby {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 40px;
  text-align: center;
  min-height: 500px;
}

.viewer-standby h2 {
  font-size: 1.6rem;
  margin-bottom: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.standby-subtext {
  color: var(--text-muted);
  max-width: 480px;
  margin-bottom: 40px;
}

.connection-stats-standby {
  display: flex;
  gap: 16px;
  color: var(--color-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.bullet {
  opacity: 0.4;
}

/* Loading Spinners */
.loading-spinner-container {
  position: relative;
  width: 90px;
  height: 90px;
  margin-bottom: 36px;
}

.pulsing-circle {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 4px solid var(--color-primary);
  opacity: 0.1;
  animation: pulseRing 1.8s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

.spinner-core {
  position: absolute;
  top: 15px;
  left: 15px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--color-primary);
  border-bottom-color: var(--color-secondary);
  animation: spin 1.2s cubic-bezier(0.53, 0.21, 0.29, 0.67) infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes pulseRing {
  0% { transform: scale(0.6); opacity: 0.8; }
  80%, 100% { transform: scale(1.3); opacity: 0; }
}

/* ==========================================================================
   Viewer Custom Player Overlay & Controls
   ========================================================================== */
.viewer-stream-panel {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.viewer-video-container {
  position: relative;
  background: var(--bg-darker);
  border-radius: var(--radius-lg);
  overflow: hidden;
  height: calc(100vh - 280px);
  min-height: 450px;
}

/* Click to Unmute Overlay */
.unmute-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(14, 11, 26, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(8px);
}

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

/* Custom Controls Bar */
.player-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 20px 24px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  display: flex;
  justify-content: space-between;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 5;
}

.viewer-video-container:hover .player-controls {
  opacity: 1;
}

.controls-left, .controls-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.control-btn {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  transition: var(--transition-smooth);
}

.control-btn:hover {
  background: var(--color-primary);
  transform: scale(1.1);
  box-shadow: 0 0 12px var(--color-primary-glow);
}

/* Volume Slider styling */
.volume-slider-container {
  display: flex;
  align-items: center;
  width: 80px;
  transition: width 0.3s ease;
}

.volume-slider-container input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.2);
  outline: none;
  cursor: pointer;
}

.volume-slider-container input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-secondary);
  cursor: pointer;
  box-shadow: 0 0 5px var(--color-secondary);
  transition: transform 0.1s;
}

.volume-slider-container input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.3);
}

/* ==========================================================================
   Stream Statistics Panel
   ========================================================================== */
.stats-panel {
  margin-top: 24px;
}

.stats-header {
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.stats-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  color: var(--color-secondary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  padding: 24px;
  border-top: 1px solid var(--glass-border);
  animation: slideDown 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.stats-grid.collapsed {
  display: none;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
  padding: 12px;
  transition: var(--transition-smooth);
}

.stat-card:hover {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
}

.toast {
  background: rgba(14, 11, 26, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 250px;
  animation: slideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.toast-success {
  border-left: 3px solid var(--color-success);
}
.toast.toast-error {
  border-left: 3px solid var(--color-danger);
}
.toast.toast-info {
  border-left: 3px solid var(--color-secondary);
}

/* ==========================================================================
   Keyframe Animations
   ========================================================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.1); opacity: 1; }
}

/* ==========================================================================
   Stream Settings Panel Layout
   ========================================================================== */
.host-sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.settings-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-group label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-primary);
}

.form-select {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 10px 14px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
  transition: var(--transition-smooth);
  width: 100%;
}

.form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 8px var(--color-primary-glow);
}

.form-select option {
  background-color: var(--bg-darker);
  color: var(--text-main);
}

.setting-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.settings-actions {
  margin-top: 8px;
}

.btn-full {
  width: 100%;
}
