/* =========================================================================
   StreamCast — dynamic white theme
   Airy light UI with soft motion: animated aurora background, glass topbar,
   staggered card entrances, glowing LIVE pulse, tactile hovers.
   ========================================================================= */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #fbfcfe;
  --border: #e8ebf1;
  --border-strong: #d7dbe4;
  --text: #10131a;
  --text-2: #3a4150;
  --muted: #7a8394;
  --accent: #3b5bfd;
  --accent-2: #6a8bff;
  --accent-hover: #2a45e0;
  --live: #f0304a;
  --ok: #10b981;
  --warn: #f59e0b;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.04), 0 2px 6px rgba(16,24,40,.05);
  --shadow-md: 0 4px 12px rgba(16,24,40,.06), 0 12px 28px rgba(16,24,40,.07);
  --shadow-lg: 0 8px 24px rgba(16,24,40,.08), 0 24px 56px rgba(16,24,40,.10);
  --ease: cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Animated aurora background — soft drifting light blooms */
body::before {
  content: "";
  position: fixed;
  inset: -20vmax;
  z-index: -1;
  background:
    radial-gradient(38vmax 38vmax at 12% 8%, rgba(106,139,255,.20), transparent 60%),
    radial-gradient(32vmax 32vmax at 88% 12%, rgba(59,91,253,.14), transparent 62%),
    radial-gradient(40vmax 40vmax at 78% 92%, rgba(16,185,129,.10), transparent 60%),
    radial-gradient(30vmax 30vmax at 20% 96%, rgba(240,48,74,.07), transparent 60%);
  filter: blur(8px);
  animation: drift 26s var(--ease) infinite alternate;
}
@keyframes drift {
  0%   { transform: translate3d(0,0,0) scale(1); }
  50%  { transform: translate3d(2.5vmax,-2vmax,0) scale(1.06); }
  100% { transform: translate3d(-2vmax,2.5vmax,0) scale(1.02); }
}
@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
  * { animation: none !important; scroll-behavior: auto; }
}

a { color: var(--accent); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--accent-hover); }

/* ---- Topbar (glass) ---- */
.topbar {
  background: rgba(255,255,255,.72);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid rgba(232,235,241,.9);
  padding: 0 28px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand {
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -.03em;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  background: none;
}
.brand .dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--live);
  position: relative;
}
.brand .dot::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: var(--live);
  animation: ring 1.8s var(--ease) infinite;
}
@keyframes ring {
  0%   { transform: scale(1); opacity: .55; }
  100% { transform: scale(3); opacity: 0; }
}
.topbar nav a { color: var(--muted); margin-left: 22px; font-weight: 600; font-size: 14px; }
.topbar nav a:hover { color: var(--text); }

.container { max-width: 1120px; margin: 0 auto; padding: 40px 28px 72px; }

h1 { font-size: 28px; font-weight: 800; letter-spacing: -.03em; margin: 0 0 4px; }
h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 16px; }
.subtitle { color: var(--muted); margin: 0 0 28px; font-size: 15px; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 32px; gap: 16px;
  animation: rise .5s var(--ease) both;
}

/* ---- Buttons ---- */
.btn {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 10px 17px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: transform .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease), border-color .15s var(--ease);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); border-color: var(--muted); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  border-color: transparent; color: #fff;
  box-shadow: 0 4px 14px rgba(59,91,253,.32);
}
.btn-primary:hover { box-shadow: 0 8px 22px rgba(59,91,253,.40); }
/* sheen sweep on primary */
.btn-primary::after {
  content: ""; position: absolute; top: 0; left: -60%; width: 40%; height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255,255,255,.5), transparent);
  transform: skewX(-20deg); transition: left .55s var(--ease);
}
.btn-primary:hover::after { left: 130%; }
.btn-live {
  background: linear-gradient(135deg, #ff5a70, var(--live));
  border-color: transparent; color: #fff;
  box-shadow: 0 4px 14px rgba(240,48,74,.35);
}
.btn-live:hover { box-shadow: 0 8px 22px rgba(240,48,74,.45); }
.btn-danger { color: var(--live); border-color: var(--border); }
.btn-danger:hover { background: #fff1f3; border-color: #ffc9d2; }
.btn-sm { padding: 7px 12px; font-size: 13px; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 22px;
  animation: rise .55s var(--ease) both;
  transition: box-shadow .2s var(--ease);
}
.card:hover { box-shadow: var(--shadow-md); }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Dashboard grid ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.stream-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
  animation: rise .5s var(--ease) both;
  overflow: hidden;
}
/* gradient top accent that reveals on hover */
.stream-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transform: scaleX(0); transform-origin: left;
  transition: transform .3s var(--ease);
}
.stream-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.stream-card:hover::before { transform: scaleX(1); }
.grid .stream-card:nth-child(1) { animation-delay: .04s; }
.grid .stream-card:nth-child(2) { animation-delay: .08s; }
.grid .stream-card:nth-child(3) { animation-delay: .12s; }
.grid .stream-card:nth-child(4) { animation-delay: .16s; }
.grid .stream-card:nth-child(5) { animation-delay: .20s; }
.grid .stream-card:nth-child(n+6) { animation-delay: .24s; }
.stream-card .name { font-weight: 700; font-size: 17px; margin-top: 14px; letter-spacing: -.01em; display:block; color: var(--text); }
.stream-card .name:hover { color: var(--accent); }
.stream-meta { color: var(--muted); font-size: 13px; display: flex; gap: 16px; margin-top: 12px; }

/* ---- Status pills ---- */
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 800; letter-spacing: .05em;
  padding: 5px 12px; border-radius: 999px;
}
.pill .pdot { width: 7px; height: 7px; border-radius: 50%; position: relative; }
.pill-live { background: #fff0f2; color: var(--live); box-shadow: inset 0 0 0 1px rgba(240,48,74,.15); }
.pill-live .pdot { background: var(--live); }
.pill-live .pdot::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--live);
  animation: ring 1.6s var(--ease) infinite;
}
.pill-off { background: #f1f3f7; color: var(--muted); }
.pill-off .pdot { background: #a3aab8; }

/* ---- Forms ---- */
label { display: block; font-weight: 600; font-size: 13px; margin: 0 0 7px; color: var(--text-2); }
input[type=text], input[type=password], input[type=url], input[type=datetime-local] {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface-2);
  color: var(--text);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
input::placeholder { color: #aab1bf; }
input:focus {
  outline: none;
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(59,91,253,.14);
}
.field { margin-bottom: 20px; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 6px; line-height: 1.45; }
.checkbox-row { display: flex; align-items: center; gap: 10px; }
.checkbox-row label { margin: 0; }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

/* ---- Video queue ---- */
.queue { list-style: none; margin: 0; padding: 0; }
.qitem {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  background: var(--surface);
  transition: box-shadow .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease);
  animation: rise .4s var(--ease) both;
}
.qitem:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.qitem.dragging { opacity: .45; transform: scale(.99); }
.qitem.drag-over { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(59,91,253,.12); }
.qhandle { cursor: grab; color: #c3c9d4; font-size: 18px; user-select: none; transition: color .15s var(--ease); }
.qhandle:active { cursor: grabbing; }
.qitem:hover .qhandle { color: var(--accent); }
.qname { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qdur { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

/* now-playing (on air) */
.qitem.on-air {
  border-color: var(--accent);
  background: linear-gradient(180deg, #f5f8ff, #eef3ff);
  box-shadow: 0 0 0 3px rgba(59,91,253,.10);
}
.qitem.on-air .qname { color: var(--accent); font-weight: 700; }
.nowtag {
  font-size: 11px; font-weight: 800; letter-spacing: .06em;
  color: #fff; background: linear-gradient(135deg, #ff5a70, var(--live));
  padding: 4px 10px; border-radius: 7px; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(240,48,74,.3);
  animation: airpulse 1.6s var(--ease) infinite;
}
@keyframes airpulse { 0%,100% { opacity: 1; } 50% { opacity: .6; } }
.nowbar {
  height: 4px; border-radius: 999px; background: rgba(59,91,253,.15);
  margin-top: 8px; overflow: hidden;
}
.nowbar-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 1s linear;
}

.status-tag { font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 7px; white-space: nowrap; letter-spacing: .01em; }
.st-waiting_encode { background: #f1f3f7; color: var(--muted); }
.st-encoding {
  background: linear-gradient(90deg, #eaf0ff, #dbe6ff, #eaf0ff);
  background-size: 200% 100%;
  color: var(--accent);
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.st-completed { background: #e7faf2; color: var(--ok); }
.st-error { background: #fff0f2; color: var(--live); cursor: help; }

/* ---- Upload dropzone ---- */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .2s var(--ease), background .2s var(--ease), color .2s var(--ease), transform .2s var(--ease);
  background: var(--surface-2);
}
.dropzone:hover, .dropzone.hover {
  border-color: var(--accent);
  background: linear-gradient(180deg, #f3f7ff, #eef3ff);
  color: var(--accent);
  transform: translateY(-2px);
}
.dropzone.hover { border-style: solid; box-shadow: 0 0 0 4px rgba(59,91,253,.10); }
.dropzone.dropzone-disabled { pointer-events: none; opacity: .55; }

/* ---- Upload progress ---- */
.upload-progress { margin-top: 14px; animation: rise .3s var(--ease) both; }
.upload-progress-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12.5px; color: var(--muted); margin-bottom: 6px;
}
.upload-progress-head b { color: var(--text-2); font-weight: 700; }
.upload-progress .nowbar { height: 7px; background: rgba(59,91,253,.12); }
.upload-progress .nowbar-fill { transition: width .2s linear; }
.upload-progress.is-error .nowbar-fill { background: linear-gradient(90deg, #ff8a97, var(--live)); }
.upload-progress.is-error .upload-progress-head { color: var(--live); }

/* ---- Danger zone ---- */
.danger-zone { border-color: #ffd7dd; background: linear-gradient(180deg, #fffafb, var(--surface)); }

/* ---- Flash ---- */
.flash {
  padding: 12px 18px; border-radius: var(--radius-sm); margin-bottom: 18px;
  font-size: 14px; font-weight: 600;
  animation: rise .4s var(--ease) both;
}
.flash-ok { background: #e7faf2; color: #0a7f5b; border: 1px solid #a9ecd2; }
.flash-error { background: #fff0f2; color: #c31832; border: 1px solid #ffc9d2; }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; letter-spacing: -.01em; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); animation: rise .5s var(--ease) both; }
.empty svg { opacity: .35; margin-bottom: 14px; }

/* ---- Login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: rgba(255,255,255,.85);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%; max-width: 400px;
  animation: rise .55s var(--ease) both;
}
.login-card .brand { justify-content: center; margin-bottom: 6px; font-size: 24px; }
.login-card .subtitle { text-align: center; }
