/* ============================================
   StreamVault — CSS Design System
   ============================================ */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(18, 18, 30, 0.7);
  --bg-card-hover: rgba(25, 25, 42, 0.8);
  --bg-input: rgba(15, 15, 25, 0.9);
  --border: rgba(139, 92, 246, 0.15);
  --border-focus: rgba(139, 92, 246, 0.5);
  --text-primary: #e8e6f0;
  --text-secondary: #8b8aa0;
  --text-muted: #5a5970;
  --accent: #8b5cf6;
  --accent-light: #a78bfa;
  --accent-glow: rgba(139, 92, 246, 0.25);
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 30px rgba(139,92,246,0.15);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Ambient Background */
.ambient {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
}
.blob {
  position: absolute; border-radius: 50%; filter: blur(120px); opacity: 0.12;
}
.blob-1 {
  width: 500px; height: 500px; top: -100px; left: -100px;
  background: radial-gradient(circle, #8b5cf6, transparent 70%);
  animation: float1 20s ease-in-out infinite;
}
.blob-2 {
  width: 400px; height: 400px; top: 50%; right: -80px;
  background: radial-gradient(circle, #6366f1, transparent 70%);
  animation: float2 25s ease-in-out infinite;
}
.blob-3 {
  width: 350px; height: 350px; bottom: -50px; left: 30%;
  background: radial-gradient(circle, #a78bfa, transparent 70%);
  animation: float3 22s ease-in-out infinite;
}

@keyframes float1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(80px, 60px) scale(1.1); }
}
@keyframes float2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-60px, -40px) scale(1.15); }
}
@keyframes float3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, -50px) scale(1.05); }
}

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

/* Header */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; margin-bottom: 32px;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { width: 36px; height: 36px; }
.logo-icon svg { width: 100%; height: 100%; }
.logo-text {
  font-size: 1.3rem; font-weight: 700;
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Panels */
.config-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-md), var(--shadow-glow);
  margin-bottom: 24px;
  transition: var(--transition);
}
.panel-header { margin-bottom: 24px; }
.panel-title {
  font-size: 1.25rem; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.panel-subtitle { color: var(--text-secondary); font-size: 0.875rem; }

/* Form */
.form { display: flex; flex-direction: column; gap: 20px; }

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

.label {
  font-size: 0.8rem; font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.08em;
  display: flex; align-items: center; gap: 6px;
}

.input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 0.95rem;
  color: var(--text-primary);
  font-family: var(--font);
  transition: var(--transition);
  outline: none;
}
.input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.input::placeholder { color: var(--text-muted); }

/* Header rows */
.add-header-btn {
  margin-left: auto;
  background: rgba(139,92,246,0.15);
  border: 1px solid rgba(139,92,246,0.3);
  color: var(--accent-light);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  font-family: var(--font);
}
.add-header-btn:hover {
  background: rgba(139,92,246,0.25);
  border-color: var(--accent);
}

.headers-container {
  display: flex; flex-direction: column; gap: 8px;
}

.header-row {
  display: flex; gap: 8px; align-items: center;
  animation: slideIn 0.2s ease-out;
}
.header-row .input { flex: 1; padding: 10px 14px; font-size: 0.875rem; }
.header-row .input:first-child { flex: 0.4; }

.remove-header-btn {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.2);
  color: var(--danger);
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  cursor: pointer; transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.remove-header-btn:hover {
  background: rgba(239,68,68,0.2);
  border-color: var(--danger);
}

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

/* Buttons */
.actions { display: flex; gap: 12px; padding-top: 4px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  border: none; font-family: var(--font);
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: white;
  box-shadow: 0 4px 16px rgba(139,92,246,0.3);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(139,92,246,0.4);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-secondary:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}

.btn-small {
  padding: 8px 16px; font-size: 0.8rem;
  background: var(--accent); color: white;
  border-radius: var(--radius-sm);
}

/* Player */
.player-section { margin-bottom: 24px; }

.player-wrapper {
  position: relative;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,0.05);
}

.video-player {
  width: 100%; height: 100%;
  display: none;
  background: #000;
}
.video-player.active { display: block; }

/* Player Overlays */
.player-idle,
.player-loading,
.player-error {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px;
  background: rgba(10,10,15,0.95);
  color: var(--text-secondary);
}
.player-idle { display: flex; }
.player-idle.hidden { display: none; }
.player-loading.active { display: flex; }
.player-error.active { display: flex; }

.idle-text { font-size: 0.95rem; color: var(--text-muted); }

.spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(139,92,246,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.player-error { color: var(--danger); }
.player-error p { color: var(--text-secondary); font-size: 0.875rem; max-width: 80%; text-align: center; }

/* Stream Info */
.stream-info {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  background: var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: 12px;
}
.info-item {
  background: var(--bg-card);
  padding: 12px 16px;
  display: flex; flex-direction: column; gap: 4px;
  backdrop-filter: blur(10px);
}
.info-label { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); }
.info-value { font-size: 0.85rem; font-weight: 500; color: var(--text-primary); display: flex; align-items: center; gap: 6px; }

.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.status-dot.live { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.error { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.status-dot.loading { background: var(--warning); animation: pulse 1s ease-in-out infinite; }

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

/* Footer */
.footer {
  margin-top: auto;
  text-align: center;
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.footer a {
  color: var(--accent-light);
  text-decoration: none;
}
.footer a:hover { text-decoration: underline; }

/* Responsive */
@media (max-width: 640px) {
  .app { padding: 16px 12px; }
  .config-panel { padding: 20px 16px; }
  .stream-info { grid-template-columns: repeat(2, 1fr); }
  .header-row { flex-wrap: wrap; }
  .header-row .input:first-child { flex: 1 1 100%; }
  .actions { flex-direction: column; }
  .btn { justify-content: center; }
}
