/* ── Fonts ───────────────────────────────────────────────────────────────── */
@font-face {
  font-family: "VisbyCF";
  src: url("../fonts/VisbyCF-Medium.otf") format("opentype");
  font-weight: 500;
  font-style: normal;
}
@font-face {
  font-family: "STIXTwo";
  src: url("../fonts/STIXTwoText-VariableFont_wght.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
}

/* ── Tokens ──────────────────────────────────────────────────────────────── */
:root {
  --bg:          #0e1120;
  --surface:     #151929;
  --surface-2:   #1b2036;
  --surface-3:   #222845;
  --border:      #2a3254;
  --border-soft: #1e2640;
  --accent:      #c9a96e;
  --accent-dim:  rgba(201,169,110,.12);
  --accent-glow: rgba(201,169,110,.06);
  --blue:        #6b9fd4;
  --blue-dim:    rgba(107,159,212,.12);
  --green:       #6dc48a;
  --green-dim:   rgba(109,196,138,.12);
  --red:         #d46b6b;
  --red-dim:     rgba(212,107,107,.12);
  --yellow:      #d4b86b;
  --yellow-dim:  rgba(212,184,107,.12);
  --text:        #dde2f0;
  --text-muted:  #6e7a9a;
  --text-dim:    #3d4a6a;
  --logo-navy:   #2d3455;
  --radius:      10px;
  --radius-lg:   14px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: "VisbyCF", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  height: 140px;
  width: auto;
  filter: brightness(0) invert(1) opacity(.85);
}

.nav-label {
  font-family: "STIXTwo", serif;
  font-size: .9rem;
  font-style: italic;
  color: var(--text-muted);
  letter-spacing: .02em;
}

.btn-ghost {
  font-family: "VisbyCF", sans-serif;
  font-size: .82rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: color .15s, border-color .15s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }

/* ── Main layout ─────────────────────────────────────────────────────────── */
.main {
  padding: 32px;
  max-width: 1100px;
  margin: 0 auto;
}

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 64px - 64px);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 52px 48px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(201,169,110,.07) 0%, transparent 70%);
  pointer-events: none;
}

.login-icon {
  margin-bottom: 28px;
  display: flex;
  justify-content: center;
}

.login-title {
  font-family: "STIXTwo", serif;
  font-size: 2rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
  margin-bottom: 14px;
}
.login-title em {
  color: var(--accent);
  font-style: italic;
}

.login-sub {
  font-size: .9rem;
  color: var(--text-muted);
  margin-bottom: 36px;
  line-height: 1.6;
}

/* ── Dashboard grid ──────────────────────────────────────────────────────── */
.dashboard {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}

.col-left, .col-right {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color .2s;
}
.card:hover { border-color: var(--border); }

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

.card-title {
  font-family: "STIXTwo", serif;
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .1em;
}

/* ── Status card ─────────────────────────────────────────────────────────── */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  transition: background .3s;
}
.status-dot.dot-idle     { background: var(--text-dim); }
.status-dot.dot-scheduled { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }
.status-dot.dot-streaming {
  background: var(--blue);
  box-shadow: 0 0 8px var(--blue);
  animation: pulse 1.5s ease-in-out infinite;
}
.status-dot.dot-done  { background: var(--green); }
.status-dot.dot-error { background: var(--red); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .5; transform: scale(1.4); }
}

.status-content { padding: 20px 24px; }

.status-idle-msg {
  font-size: .88rem;
  color: var(--text-muted);
  font-style: italic;
}

.status-block { display: flex; flex-direction: column; gap: 12px; }

.status-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px;
  align-items: start;
}
.status-lbl {
  font-size: .78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding-top: 2px;
}
.status-val {
  font-size: .9rem;
  color: var(--text);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .82rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 20px;
}
.badge-idle        { background: var(--surface-3); color: var(--text-muted); }
.badge-scheduled   { background: var(--yellow-dim); color: var(--yellow); }
.badge-downloading { background: var(--blue-dim); color: var(--blue); }
.badge-ready       { background: var(--green-dim); color: var(--green); }
.badge-streaming   { background: var(--blue-dim); color: var(--blue); }
.badge-done        { background: var(--green-dim); color: var(--green); }
.badge-error       { background: var(--red-dim); color: var(--red); }

.status-spinner {
  display: inline-block;
  width: 10px; height: 10px;
  border: 1.5px solid var(--blue);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.status-link a {
  color: var(--accent);
  font-size: .88rem;
  text-decoration: none;
  word-break: break-all;
}
.status-link a:hover { text-decoration: underline; }

.status-error-msg {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--red-dim);
  border: 1px solid rgba(212,107,107,.2);
  border-radius: var(--radius);
  font-size: .85rem;
  color: var(--red);
  line-height: 1.5;
}

.status-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}

/* ── Form card ───────────────────────────────────────────────────────────── */
.form-body { padding: 24px; display: flex; flex-direction: column; gap: 20px; }

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

label {
  font-size: .78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
}
.field-hint {
  font-size: .75rem;
  color: var(--text-dim);
  text-transform: none;
  letter-spacing: 0;
}

input[type="text"],
input[type="datetime-local"],
textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  color: var(--text);
  font-family: "VisbyCF", sans-serif;
  font-size: .92rem;
  outline: none;
  transition: border-color .15s, background .15s;
  -webkit-appearance: none;
}
input:focus, textarea:focus {
  border-color: var(--accent);
  background: var(--surface-3);
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }
textarea { resize: vertical; line-height: 1.6; }

input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(.4);
  cursor: pointer;
}

/* ── Drive picker ────────────────────────────────────────────────────────── */
.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0;
}
.field-label-row label { margin-bottom: 0; }

.toggle-label {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-size: .82rem;
  color: var(--text-muted);
}
.toggle-label input[type="checkbox"] {
  width: 32px;
  height: 18px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  transition: background .2s, border-color .2s;
  flex-shrink: 0;
  padding: 0;
}
.toggle-label input[type="checkbox"]::after {
  content: "";
  position: absolute;
  width: 12px; height: 12px;
  background: var(--text-muted);
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: transform .2s, background .2s;
}
.toggle-label input[type="checkbox"]:checked {
  background: var(--accent-dim);
  border-color: var(--accent);
}
.toggle-label input[type="checkbox"]:checked::after {
  transform: translateX(14px);
  background: var(--accent);
}

.drive-area { display: flex; flex-direction: column; gap: 10px; }

.drive-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface-2);
}
.drive-list::-webkit-scrollbar { width: 4px; }
.drive-list::-webkit-scrollbar-track { background: transparent; }
.drive-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.drive-item {
  padding: 11px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
  transition: background .1s;
}
.drive-item:last-child { border-bottom: none; }
.drive-item:hover { background: var(--surface-3); }
.drive-item .file-name { font-size: .9rem; color: var(--text); }
.drive-item .file-meta { font-size: .76rem; color: var(--text-muted); margin-top: 3px; }

.selected-file {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--green-dim);
  border: 1px solid rgba(109,196,138,.2);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: .88rem;
  color: var(--green);
}
.btn-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: .85rem;
  margin-left: auto;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 3px;
  transition: color .1s;
}
.btn-clear:hover { color: var(--red); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #0e1120;
  font-family: "VisbyCF", sans-serif;
  font-size: .9rem;
  font-weight: 500;
  padding: 12px 24px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  text-decoration: none;
  letter-spacing: .03em;
  transition: opacity .15s, transform .1s;
}
.btn-primary:hover { opacity: .88; }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}
.btn-full { width: 100%; }

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  color: var(--text-muted);
  font-family: "VisbyCF", sans-serif;
  font-size: .85rem;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.btn-outline:hover { color: var(--text); border-color: var(--text-muted); }
.btn-outline:disabled { opacity: .5; cursor: not-allowed; }

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--red-dim);
  color: var(--red);
  font-family: "VisbyCF", sans-serif;
  font-size: .85rem;
  padding: 9px 16px;
  border: 1px solid rgba(212,107,107,.2);
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity .15s;
}
.btn-danger:hover { opacity: .8; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface-3);
  color: var(--text-muted);
  font-family: "VisbyCF", sans-serif;
  font-size: .85rem;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: color .15s;
}
.btn-secondary:hover { color: var(--text); }

/* ── Alert ───────────────────────────────────────────────────────────────── */
.alert {
  padding: 11px 14px;
  border-radius: var(--radius);
  font-size: .86rem;
  line-height: 1.5;
}
.alert-error {
  background: var(--red-dim);
  border: 1px solid rgba(212,107,107,.2);
  color: var(--red);
}

/* ── Info card / steps ───────────────────────────────────────────────────── */
.steps {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.step-num {
  font-family: "STIXTwo", serif;
  font-size: 1.25rem;
  font-weight: 300;
  color: var(--accent);
  opacity: .6;
  min-width: 28px;
  line-height: 1.3;
}

.step-text strong {
  display: block;
  font-size: .9rem;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 3px;
}
.step-text p {
  font-size: .83rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* ── Next live card ──────────────────────────────────────────────────────── */
.next-content {
  padding: 20px 24px;
}

/* ── Source tabs ─────────────────────────────────────────────────────────── */
.source-tabs, .drive-sub-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 10px;
}
.drive-sub-tabs { margin-top: 0; }

.source-tab {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 7px 12px;
  font-family: "VisbyCF", sans-serif;
  font-size: .82rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.source-tab.active {
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border);
}
.source-tab:hover:not(.active) { color: var(--text); }

/* ── Upload zone ─────────────────────────────────────────────────────────── */
.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 20px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s;
  background: var(--surface-2);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.upload-zone span { font-size: .88rem; color: var(--text-muted); }
.upload-hint { font-size: .76rem !important; color: var(--text-dim) !important; }

/* ── Progress bar ────────────────────────────────────────────────────────── */
.upload-progress { display: flex; flex-direction: column; gap: 6px; }

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: .8rem;
  color: var(--text-muted);
}

.progress-bar {
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width .2s;
}

/* ── Utilities ───────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  .dashboard {
    grid-template-columns: 1fr;
  }
  .col-right {
    order: -1;
  }
  .main { padding: 20px 16px; }
  .topbar { padding: 0 20px; }
}
