/* ========================================================================= */
/* strmd — Design System & Styles                                             */
/* ========================================================================= */

/* ------- Tokens ---------------------------------------------------------- */
:root {
  /* Palette */
  --c-bg:            #0a0a0f;
  --c-bg-elevated:   #111119;
  --c-bg-panel:      rgba(17, 17, 25, 0.72);
  --c-bg-panel-solid:#14141e;
  --c-surface:       rgba(255, 255, 255, 0.04);
  --c-surface-hover: rgba(255, 255, 255, 0.07);
  --c-border:        rgba(255, 255, 255, 0.08);
  --c-border-strong: rgba(255, 255, 255, 0.14);

  --c-text:          #e2e2f0;
  --c-text-muted:    #8888a4;
  --c-text-faint:    #55556a;

  --c-primary:       #818cf8;
  --c-primary-vivid: #6366f1;
  --c-primary-glow:  rgba(99, 102, 241, 0.25);
  --c-accent:        #c084fc;
  --c-accent-glow:   rgba(192, 132, 252, 0.20);

  --c-success:       #34d399;
  --c-error:         #f87171;
  --c-warning:       #fbbf24;
  --c-live:          #ef4444;

  /* Gradients */
  --grad-primary:    linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  --grad-surface:    linear-gradient(135deg, rgba(99,102,241,0.08) 0%, rgba(168,85,247,0.04) 100%);

  /* Typography */
  --ff-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --ff-mono:  'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --fs-xs:    0.75rem;
  --fs-sm:    0.8125rem;
  --fs-base:  0.9375rem;
  --fs-md:    1.0625rem;
  --fs-lg:    1.25rem;
  --fs-xl:    1.625rem;
  --fs-2xl:   2rem;

  --fw-light:   300;
  --fw-regular: 400;
  --fw-medium:  500;
  --fw-semi:    600;
  --fw-bold:    700;

  /* Spacing */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 40px var(--c-primary-glow);

  /* Transitions */
  --t-fast:  150ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-base:  250ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow:  400ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--ff-sans);
  font-size: var(--fs-base);
  font-weight: var(--fw-regular);
  color: var(--c-text);
  background: var(--c-bg);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre { font-family: var(--ff-mono); }

/* ------- Background animations ------------------------------------------- */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 64px 64px;
  pointer-events: none;
}

.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  animation: glowFloat 18s ease-in-out infinite;
}

.bg-glow--1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(99,102,241,0.12), transparent 70%);
  top: -10%;
  right: -5%;
  animation-delay: 0s;
}

.bg-glow--2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(168,85,247,0.10), transparent 70%);
  bottom: -5%;
  left: -8%;
  animation-delay: -9s;
}

@keyframes glowFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(30px, -20px) scale(1.05); }
  66%      { transform: translate(-20px, 15px) scale(0.95); }
}

/* ------- App layout ------------------------------------------------------ */
.app {
  position: relative;
  z-index: 1;
  max-width: 920px;
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-5);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}

/* ------- Header ---------------------------------------------------------- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) 0;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.header__logo {
  display: flex;
  align-items: center;
  filter: drop-shadow(0 0 12px var(--c-primary-glow));
  transition: filter var(--t-base);
}

.header__logo:hover {
  filter: drop-shadow(0 0 20px var(--c-primary-glow));
}

.header__title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.header__badge {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--c-text-muted);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  padding: 2px 8px;
  border-radius: var(--r-full);
}

.header__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* ------- Panel ----------------------------------------------------------- */
.panel {
  background: var(--c-bg-panel);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  padding: var(--sp-8);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  transition: border-color var(--t-base), box-shadow var(--t-base);
  animation: panelIn 0.5s ease-out;
}

.panel:hover {
  border-color: var(--c-border-strong);
}

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

.panel__icon {
  margin-bottom: var(--sp-4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: var(--r-lg);
  background: var(--grad-surface);
  border: 1px solid var(--c-border);
}

.panel__title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-semi);
  color: var(--c-text);
  margin-bottom: var(--sp-2);
}

.panel__subtitle {
  color: var(--c-text-muted);
  font-size: var(--fs-sm);
  line-height: 1.7;
  max-width: 560px;
  margin-bottom: var(--sp-6);
}

/* ------- Input / Form ---------------------------------------------------- */
.extract-form {
  width: 100%;
}

.input-group {
  display: flex;
  gap: var(--sp-2);
}

.input {
  flex: 1;
  font-family: var(--ff-mono);
  font-size: var(--fs-sm);
  color: var(--c-text);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}

.input::placeholder {
  color: var(--c-text-faint);
}

.input:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-glow);
  background: rgba(255, 255, 255, 0.06);
}

/* ------- Buttons --------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--ff-sans);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  border: none;
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-5);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--t-fast);
  position: relative;
  overflow: hidden;
}

.btn--primary {
  background: var(--grad-primary);
  color: white;
  box-shadow: 0 2px 12px var(--c-primary-glow);
}

.btn--primary:hover {
  box-shadow: 0 4px 24px var(--c-primary-glow), 0 0 0 1px rgba(255,255,255,0.1) inset;
  transform: translateY(-1px);
}

.btn--primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 8px var(--c-primary-glow);
}

.btn--primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn--ghost {
  background: transparent;
  color: var(--c-text-muted);
  padding: var(--sp-2);
  border-radius: var(--r-sm);
  position: relative;
}

.btn--ghost:hover {
  background: var(--c-surface-hover);
  color: var(--c-text);
}

.btn--sm {
  padding: var(--sp-1) var(--sp-2);
}

.btn--danger:hover {
  color: var(--c-error);
  background: rgba(248, 113, 113, 0.1);
}

.btn__icon {
  flex-shrink: 0;
}

/* Badge */
.badge {
  font-size: 10px;
  font-weight: var(--fw-bold);
  background: var(--c-primary-vivid);
  color: white;
  min-width: 18px;
  height: 18px;
  border-radius: var(--r-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  position: absolute;
  top: -4px;
  right: -4px;
}

/* ------- Status & Error bars --------------------------------------------- */
.status-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
  padding: var(--sp-3) var(--sp-4);
  background: var(--grad-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  animation: statusIn 0.3s ease-out;
}

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

.status-bar__spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--c-border-strong);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.status-bar__text {
  font-size: var(--fs-sm);
  color: var(--c-text-muted);
}

.error-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
  padding: var(--sp-3) var(--sp-4);
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.2);
  border-radius: var(--r-md);
  color: var(--c-error);
  font-size: var(--fs-sm);
  animation: statusIn 0.3s ease-out;
}

/* ------- Player ---------------------------------------------------------- */
.player-panel {
  padding: 0;
  overflow: hidden;
}

.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--c-border);
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.player-header__info {
  flex: 1;
  min-width: 0;
}

.player-header__url {
  font-family: var(--ff-mono);
  font-size: var(--fs-xs);
  color: var(--c-text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 380px;
  margin-top: var(--sp-1);
}

.player-header__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.viewer-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--c-text-muted);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  padding: 3px 10px;
  border-radius: var(--r-full);
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-live);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  padding: 3px 10px;
  border-radius: var(--r-full);
}

.live-indicator__dot {
  width: 7px;
  height: 7px;
  background: var(--c-live);
  border-radius: 50%;
  animation: livePulse 1.5s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  50%      { opacity: 0.6; box-shadow: 0 0 0 4px rgba(239, 68, 68, 0); }
}

.player-container {
  position: relative;
  width: 100%;
  background: #000;
  aspect-ratio: 16 / 9;
}

.video-player {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}

.player-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  color: var(--c-text-muted);
  font-size: var(--fs-sm);
  transition: opacity var(--t-base);
  pointer-events: none;
}

.player-overlay.hidden {
  opacity: 0;
}

.player-overlay__spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Stream metadata */
.stream-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px;
  background: var(--c-border);
  border-top: 1px solid var(--c-border);
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-bg-panel-solid);
}

.meta-item__label {
  font-size: 10px;
  font-weight: var(--fw-semi);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--c-text-faint);
}

.meta-item__value {
  font-family: var(--ff-mono);
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta-item__value--url {
  cursor: pointer;
}

.meta-item__value--url:hover {
  color: var(--c-primary);
}

/* ------- Sessions Drawer ------------------------------------------------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.drawer {
  position: fixed;
  top: 0;
  right: -400px;
  width: 380px;
  max-width: 90vw;
  height: 100vh;
  z-index: 100;
  background: var(--c-bg-elevated);
  border-left: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  transition: right var(--t-slow);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.5);
}

.drawer.open {
  right: 0;
}

.drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-5);
  border-bottom: 1px solid var(--c-border);
}

.drawer__header h2 {
  font-size: var(--fs-md);
  font-weight: var(--fw-semi);
}

.drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4);
}

.drawer__empty {
  color: var(--c-text-faint);
  font-size: var(--fs-sm);
  text-align: center;
  padding: var(--sp-8) 0;
}

.session-card {
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-3);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}

.session-card:hover {
  border-color: var(--c-primary);
  background: var(--c-surface-hover);
}

.session-card__url {
  font-family: var(--ff-mono);
  font-size: var(--fs-xs);
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: var(--sp-2);
}

.session-card__meta {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: 11px;
  color: var(--c-text-faint);
}

.session-card__status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.session-card__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.session-card__dot--ready { background: var(--c-success); }
.session-card__dot--extracting { background: var(--c-warning); animation: livePulse 1.5s ease-in-out infinite; }
.session-card__dot--error { background: var(--c-error); }

/* ------- Toast ----------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: var(--sp-6);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 200;
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-5);
  font-size: var(--fs-sm);
  color: var(--c-text);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base), transform var(--t-base);
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* ------- Responsive ------------------------------------------------------ */
@media (max-width: 640px) {
  .app {
    padding: var(--sp-4) var(--sp-3);
  }

  .panel {
    padding: var(--sp-5);
    border-radius: var(--r-lg);
  }

  .input-group {
    flex-direction: column;
  }

  .btn--primary {
    justify-content: center;
  }

  .player-header {
    padding: var(--sp-4);
  }

  .player-header__url {
    max-width: 200px;
  }

  .stream-meta {
    grid-template-columns: 1fr 1fr;
  }

  .header__title {
    font-size: var(--fs-lg);
  }
}
