/* --- DESIGN SYSTEM & CSS VARIABLES --- */
:root {
  --bg-primary: #080916;
  --bg-secondary: #0d0f27;
  --bg-card: rgba(16, 19, 39, 0.55);
  --bg-card-hover: rgba(25, 29, 58, 0.7);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-active: rgba(168, 85, 247, 0.4);
  
  --text-main: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  
  --neon-purple: #c084fc;
  --neon-blue: #60a5fa;
  --neon-pink: #f472b6;
  --neon-green: #34d399;
  --neon-red: #f87171;
  
  --font-sans: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --glass-blur: blur(16px);
  --glass-saturate: saturate(180%);
}

/* --- RESET & BASIC STYLES --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

/* --- BG GLOW EFFECT --- */
.glow-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}

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

.glow-1 {
  background: radial-gradient(circle, var(--neon-purple) 0%, transparent 70%);
  width: 600px;
  height: 600px;
  top: -150px;
  right: -100px;
}

.glow-2 {
  background: radial-gradient(circle, var(--neon-blue) 0%, transparent 70%);
  width: 700px;
  height: 700px;
  bottom: -200px;
  left: -150px;
}

/* --- APP CONTAINER LAYOUT --- */
.app-container {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100vh;
}

/* --- HEADER --- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  backdrop-filter: var(--glass-blur) var(--glass-saturate);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

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

.logo-icon {
  font-size: 26px;
  color: var(--neon-purple);
  background: rgba(192, 132, 252, 0.1);
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid rgba(192, 132, 252, 0.2);
  box-shadow: 0 0 15px rgba(192, 132, 252, 0.15);
}

.logo-text h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logo-text h1 span {
  color: var(--neon-purple);
}

.logo-text p {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.header-stats {
  display: flex;
  gap: 12px;
}

.stat-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
}

.stat-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--neon-red);
  display: inline-block;
  box-shadow: 0 0 8px var(--neon-red);
}

.stat-badge .dot.streaming {
  background-color: var(--neon-green);
  box-shadow: 0 0 10px var(--neon-green);
  animation: pulse-green 1.5s infinite;
}

.stat-badge i {
  color: var(--text-muted);
}

/* --- WORKSPACE GRID --- */
.app-workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 968px) {
  .app-workspace {
    grid-template-columns: 1fr;
  }
}

.workspace-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* --- GLASS CARD COMPONENT --- */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  backdrop-filter: var(--glass-blur) var(--glass-saturate);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.25);
  overflow: hidden;
  transition: var(--transition-smooth);
}

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

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.2px;
}

.card-header h3 i {
  font-size: 18px;
}

/* --- NEON UTILITIES --- */
.text-neon-blue { color: var(--neon-blue); text-shadow: 0 0 10px rgba(96, 165, 250, 0.3); }
.text-neon-purple { color: var(--neon-purple); text-shadow: 0 0 10px rgba(192, 132, 252, 0.3); }
.text-neon-pink { color: var(--neon-pink); text-shadow: 0 0 10px rgba(244, 114, 182, 0.3); }
.text-neon-green { color: var(--neon-green); text-shadow: 0 0 10px rgba(52, 211, 153, 0.3); }

/* --- MONITOR PANEL --- */
.live-tag {
  background: rgba(248, 113, 113, 0.1);
  color: var(--neon-red);
  border: 1px solid rgba(248, 113, 113, 0.2);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  display: none;
}

.live-tag.active {
  display: inline-block;
  background: rgba(248, 113, 113, 0.2);
  animation: pulse-red-badge 1.5s infinite;
}

.video-preview-container {
  position: relative;
  height: 250px;
  background: #04050b;
  margin: 24px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
}

.video-preview-container.active-stream {
  border-color: rgba(168, 85, 247, 0.3);
  box-shadow: 0 0 25px rgba(168, 85, 247, 0.1), inset 0 0 30px rgba(0, 0, 0, 0.9);
}

.noise-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3 PreservingAspectRatio='none'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  z-index: 1;
}

.preview-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  text-align: center;
}

.preview-badge {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: inline-block;
}

.preview-info h4 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-info p {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 280px;
}

/* Sound Wave Animation */
.sound-wave {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 35px;
  margin-bottom: 16px;
  opacity: 0.4;
  transition: var(--transition-smooth);
}

.sound-wave.active {
  opacity: 1;
}

.sound-wave span {
  display: block;
  width: 4px;
  background-color: var(--neon-purple);
  border-radius: 2px;
  height: 5px;
}

.sound-wave.active span {
  animation: wave 1.2s ease-in-out infinite;
}

.sound-wave.active span:nth-child(1) { animation-delay: 0.1s; height: 15px; }
.sound-wave.active span:nth-child(2) { animation-delay: 0.3s; height: 25px; }
.sound-wave.active span:nth-child(3) { animation-delay: 0.6s; height: 35px; }
.sound-wave.active span:nth-child(4) { animation-delay: 0.2s; height: 20px; }
.sound-wave.active span:nth-child(5) { animation-delay: 0.4s; height: 10px; }

.stream-progress-info {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--border-color);
  padding: 16px 24px;
  background: rgba(0, 0, 0, 0.1);
}

.progress-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.progress-item .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.progress-item .value {
  font-size: 13px;
  font-weight: 600;
}

/* --- SETTINGS FORM --- */
#stream-config-form {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-size: 15px;
}

.input-wrapper input,
.input-wrapper select {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 12px 14px 12px 42px;
  border-radius: 10px;
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  transition: var(--transition-smooth);
}

.input-wrapper input:focus,
.input-wrapper select:focus {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-active);
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.15);
}

.input-wrapper select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  cursor: pointer;
}

.input-action-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 15px;
  transition: var(--transition-smooth);
}

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

.help-text {
  font-size: 11px;
  color: var(--text-muted);
}

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

/* BUTTONS */
.btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition-smooth);
}

.btn-primary {
  background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
  color: #fff;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(124, 58, 237, 0.5);
  background: linear-gradient(135deg, #b55fe6 0%, #8b4bf2 100%);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary.stop-btn {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 4px 20px rgba(220, 38, 38, 0.35);
}

.btn-primary.stop-btn:hover {
  background: linear-gradient(135deg, #f87171 0%, #e11d48 100%);
  box-shadow: 0 6px 25px rgba(220, 38, 38, 0.5);
}

/* --- MEDIA MANAGEMENT --- */
.media-panel {
  display: flex;
  flex-direction: column;
  height: 604px; /* Matches control column height roughly */
}

.counter-badge {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 12px;
  font-weight: 600;
}

/* Dropzone styling */
.upload-dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  margin: 20px 24px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.01);
  transition: var(--transition-smooth);
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
  border-color: var(--neon-purple);
  background: rgba(168, 85, 247, 0.04);
  box-shadow: inset 0 0 15px rgba(168, 85, 247, 0.05);
}

.dropzone-icon {
  font-size: 32px;
  color: var(--text-muted);
  margin-bottom: 12px;
  transition: var(--transition-smooth);
}

.upload-dropzone:hover .dropzone-icon {
  color: var(--neon-purple);
  transform: translateY(-3px);
}

.dropzone-content h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.dropzone-content p {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.info-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(255, 255, 255, 0.03);
  padding: 3px 8px;
  border-radius: 4px;
  color: var(--text-muted);
}

/* Upload Queue (Transcoding) */
.upload-queue {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 24px;
  max-height: 120px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: 8px;
}

.queue-spinner {
  color: var(--neon-purple);
  font-size: 14px;
  animation: spin 1s linear infinite;
}

.queue-info {
  flex-grow: 1;
  min-width: 0;
}

.queue-name {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-status {
  font-size: 10px;
  color: var(--text-muted);
}

/* Video Grid and Scroll container */
.video-grid-container {
  flex-grow: 1;
  overflow-y: auto;
  padding: 0 24px 20px 24px;
  max-height: 280px;
}

.video-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.empty-media {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.empty-media i {
  font-size: 36px;
  color: rgba(255, 255, 255, 0.05);
}

.empty-media p {
  font-size: 14px;
  font-weight: 500;
}

.empty-media span {
  font-size: 11px;
  max-width: 250px;
}

/* Video Card (Horizontal Layout) */
.video-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 8px;
  transition: var(--transition-smooth);
}

.video-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateX(4px);
}

.video-card.active-play {
  border-color: rgba(168, 85, 247, 0.3);
  background: rgba(168, 85, 247, 0.04);
}

.card-thumb-wrapper {
  position: relative;
  width: 80px;
  height: 48px;
  border-radius: 6px;
  overflow: hidden;
  background-color: #000;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.card-thumb-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-duration {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.85);
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  color: #fff;
}

.video-card-info {
  flex-grow: 1;
  min-width: 0;
}

.video-card-title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.video-card-meta {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 600;
}

.status-badge.ready { background: rgba(52, 211, 153, 0.1); color: var(--neon-green); }
.status-badge.normalizing { background: rgba(192, 132, 252, 0.1); color: var(--neon-purple); }
.status-badge.failed { background: rgba(248, 113, 113, 0.1); color: var(--neon-red); }

.video-card-actions {
  flex-shrink: 0;
}

.delete-vid-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.delete-vid-btn:hover {
  color: var(--neon-red);
  background: rgba(248, 113, 113, 0.1);
}

/* --- BOTTOM PANEL: TERMINAL CONSOLE --- */
.app-console {
  margin-top: 10px;
}

.console-panel {
  display: flex;
  flex-direction: column;
}

.console-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.console-status {
  font-size: 11px;
  color: var(--text-muted);
}

.console-actions {
  display: flex;
  gap: 8px;
}

.console-btn {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

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

.console-btn.active {
  color: var(--neon-purple);
  border-color: rgba(168, 85, 247, 0.2);
  background: rgba(168, 85, 247, 0.05);
}

.console-terminal-wrapper {
  padding: 16px 24px;
  background: #04050a;
}

.console-terminal {
  height: 150px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: #a7f3d0; /* Emerald green tint for console */
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.log-line {
  word-break: break-all;
  white-space: pre-wrap;
}

.log-line.system-line {
  color: var(--neon-blue);
}

.log-line.error-line {
  color: var(--neon-red);
}

/* Custom Scrollbar for modern feel */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.01);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(168, 85, 247, 0.3);
}

/* --- ANIMATIONS & KEYFRAMES --- */
@keyframes wave {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.2); }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes pulse-green {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

@keyframes pulse-red-badge {
  0% { opacity: 0.6; }
  50% { opacity: 1; box-shadow: 0 0 8px var(--neon-red); }
  100% { opacity: 0.6; }
}

/* --- AUTH SCREENS STYLING --- */
.auth-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
  background: radial-gradient(circle at center, rgba(8, 9, 22, 0.7) 0%, rgba(4, 5, 11, 0.95) 100%);
  backdrop-filter: blur(10px);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 36px 30px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-color: rgba(192, 132, 252, 0.2);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 40px rgba(168, 85, 247, 0.05);
}

.auth-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.auth-header h2 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.auth-header h2 span {
  color: var(--neon-purple);
}

.auth-header p {
  font-size: 13px;
  color: var(--text-muted);
}

.auth-form {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.auth-form.active {
  display: flex;
}

.auth-toggle-text {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

.auth-toggle-text span {
  color: var(--neon-purple);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.auth-toggle-text span:hover {
  text-shadow: 0 0 8px rgba(192, 132, 252, 0.6);
  color: #d8b4fe;
}

.auth-error-badge {
  display: none;
  background: rgba(248, 113, 113, 0.1);
  color: var(--neon-red);
  border: 1px solid rgba(248, 113, 113, 0.2);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  text-align: center;
  font-weight: 500;
}

.header-btn {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.15);
  color: var(--neon-red);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.header-btn:hover {
  background: rgba(248, 113, 113, 0.2);
  box-shadow: 0 0 10px rgba(248, 113, 113, 0.2);
}

.user-badge {
  color: var(--neon-purple);
  border-color: rgba(192, 132, 252, 0.2);
  background: rgba(192, 132, 252, 0.05);
}
