/* CortesFlow — product-grade dark UI */
@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap");

:root {
  --bg: #080810;
  --bg-elevated: #111120;
  --bg-card: rgba(18, 18, 30, 0.9);
  --border: rgba(255, 255, 255, 0.07);
  --border-hover: rgba(255, 255, 255, 0.14);
  --text: #f0f0f8;
  --text-muted: #8888a8;
  --text-faint: #55557a;
  --accent: #7c3aed;
  --accent-light: #a78bfa;
  --accent-glow: rgba(124, 58, 237, 0.3);
  --youtube: #ff0033;
  --youtube-soft: rgba(255, 0, 51, 0.1);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --font: "Plus Jakarta Sans", system-ui, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 55% at 15% -5%, rgba(124, 58, 237, 0.22), transparent),
    radial-gradient(ellipse 50% 40% at 85% 5%, rgba(255, 0, 51, 0.06), transparent),
    radial-gradient(ellipse 60% 50% at 50% 110%, rgba(99, 102, 241, 0.1), transparent);
  pointer-events: none;
  z-index: 0;
}

/* ─── App shell ──────────────────────────────── */

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 20px 72px;
}

/* ─── Topbar ─────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 48px;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px var(--accent-glow);
  flex-shrink: 0;
}

.brand-name {
  display: block;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.brand-tag {
  font-size: 0.7rem;
  color: var(--text-faint);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.health-pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.health-pill.ok {
  border-color: rgba(34, 197, 94, 0.35);
  color: var(--success);
  background: rgba(34, 197, 94, 0.07);
}

/* ─── Hero ───────────────────────────────────── */

.hero {
  text-align: center;
  padding: 8px 0 44px;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-light);
  background: rgba(124, 58, 237, 0.12);
  border: 1px solid rgba(124, 58, 237, 0.25);
  padding: 5px 14px;
  border-radius: 999px;
  margin-bottom: 24px;
}

.hero-title {
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.08;
  margin-bottom: 18px;
}

.gradient-text {
  background: linear-gradient(135deg, var(--accent-light), #818cf8, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.65;
}

/* ─── Auth card ─────────────────────────────── */

.auth-card {
  max-width: 680px;
  margin: 0 auto 20px;
  border-radius: var(--radius);
  border: 1px solid rgba(66, 133, 244, 0.25);
  background: rgba(66, 133, 244, 0.05);
  backdrop-filter: blur(12px);
  overflow: hidden;
}

.auth-card-idle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  flex-wrap: wrap;
}

.auth-card-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-google-icon {
  width: 38px;
  height: 38px;
  background: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.auth-card-left strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
}

.auth-card-left span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.btn-google {
  background: #fff;
  color: #1f1f1f;
  border: none;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-google:hover { background: #f0f0f0; }


/* Connected state */
.auth-card-ok {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--success);
  flex-wrap: wrap;
}

.auth-card-ok span { flex: 1; }

/* ─── Form card ──────────────────────────────── */

.form-card {
  max-width: 680px;
  margin: 0 auto 16px;
}

.form-grid {
  display: grid;
  gap: 16px;
}

/* URL field */
.url-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.url-input-wrap {
  position: relative;
}

.url-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  pointer-events: none;
  opacity: 0.85;
}

.url-input-wrap input {
  padding-left: 44px;
  height: 52px;
  font-size: 1rem;
}

/* Quick settings row */
.quick-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

@media (max-width: 520px) {
  .quick-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 360px) {
  .quick-row { grid-template-columns: 1fr; }
}

/* Advanced toggle */
.advanced-toggle {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  overflow: hidden;
}

.advanced-toggle summary {
  padding: 12px 16px;
  cursor: pointer;
  font-size: 0.83rem;
  color: var(--text-muted);
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  user-select: none;
  transition: color 0.15s;
}

.advanced-toggle summary:hover { color: var(--text); }

.advanced-toggle summary::after {
  content: "▾";
  font-size: 0.75rem;
  transition: transform 0.2s;
  opacity: 0.6;
}

.advanced-toggle[open] summary::after { transform: rotate(180deg); }
.advanced-toggle summary::-webkit-details-marker { display: none; }

.advanced-body {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 12px;
}

/* Hero button */
.btn-hero {
  height: 52px;
  font-size: 1rem;
  letter-spacing: -0.01em;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 32px var(--accent-glow);
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.btn-hero:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 40px var(--accent-glow);
}

/* ─── How it works ───────────────────────────── */

.how-it-works {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0;
  padding: 36px 0 44px;
  max-width: 560px;
  margin: 0 auto;
}

.how-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  min-width: 120px;
}

.how-step-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(124, 58, 237, 0.12);
  border: 1px solid rgba(124, 58, 237, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-light);
}

.how-step strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
}

.how-step span {
  font-size: 0.75rem;
  color: var(--text-muted);
  max-width: 100px;
  line-height: 1.4;
}

.how-step-line {
  flex: 1;
  min-width: 24px;
  height: 1px;
  background: linear-gradient(90deg, rgba(124,58,237,0.3), rgba(124,58,237,0.1));
  margin: 0 4px;
  margin-bottom: 28px;
}

@media (max-width: 500px) {
  .how-step-line { display: none; }
  .how-it-works { gap: 20px; padding: 24px 0 32px; }
}

/* ─── Cards ──────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: blur(16px);
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.card-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.card-header .subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ─── Jobs card ──────────────────────────────── */

.jobs-card { max-width: 680px; margin: 0 auto 20px; }

/* Job list */
.job-list { list-style: none; }

.job-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  transition: opacity 0.15s;
}

.job-item:last-child { border-bottom: none; }
.job-item:hover { opacity: 0.9; }

.job-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.job-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-faint);
}

.job-status-dot.dot-done { background: var(--success); box-shadow: 0 0 8px rgba(34,197,94,0.5); }
.job-status-dot.dot-running { background: var(--warning); box-shadow: 0 0 8px rgba(245,158,11,0.5); animation: pulse-dot 1.5s infinite; }
.job-status-dot.dot-failed { background: var(--danger); }
.job-status-dot.dot-queued { background: var(--text-faint); }

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

.job-meta {
  min-width: 0;
}

.job-meta strong {
  font-size: 0.88rem;
  font-weight: 600;
  display: block;
  font-family: ui-monospace, monospace;
  color: var(--text);
  letter-spacing: -0.01em;
}

.job-meta small {
  color: var(--text-muted);
  font-size: 0.75rem;
  display: block;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

.job-item-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Empty state */
.job-empty-li { padding: 0; border: none !important; }

.job-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 20px;
  color: var(--text-faint);
  font-size: 0.88rem;
  text-align: center;
}

.job-empty-icon {
  font-size: 2rem;
  opacity: 0.4;
}

/* ─── Form inputs (shared) ───────────────────── */

label {
  display: block;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

input[type="text"],
input[type="number"],
input[type="url"],
select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: inherit;
  font-size: 0.93rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238888a8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  gap: 12px;
}

.toggle-row > label:first-child {
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.88rem;
  color: var(--text);
  font-weight: 500;
}

.toggle {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle span {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 24px;
  transition: background 0.2s;
}

.toggle span::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::before { transform: translateX(18px); }

/* ─── Buttons ────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s, opacity 0.15s, background 0.15s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: #fff;
  width: 100%;
}

.btn-primary:hover:not(:disabled) { opacity: 0.92; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.btn-ghost:hover { border-color: var(--border-hover); color: var(--text); background: rgba(255,255,255,0.04); }

.btn-download {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  width: 100%;
  font-size: 0.83rem;
}

.btn-download:hover { border-color: var(--accent); color: var(--accent-light); }

.btn-sm {
  padding: 7px 14px;
  font-size: 0.8rem;
}

/* ─── Badges ─────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge-queued  { background: rgba(136,136,168,0.12); color: var(--text-muted); }
.badge-running { background: rgba(245,158,11,0.12); color: var(--warning); }
.badge-done    { background: rgba(34,197,94,0.12); color: var(--success); }
.badge-failed  { background: rgba(239,68,68,0.12); color: var(--danger); }

/* ─── Job page ───────────────────────────────── */

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 28px;
  transition: color 0.15s;
}

.back-link:hover { color: var(--text); }

.job-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.job-hero h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.job-hero code {
  font-size: 0.78rem;
  color: var(--text-faint);
  font-family: ui-monospace, monospace;
  background: var(--bg-elevated);
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* Pipeline steps */
.pipeline-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 24px;
  overflow-x: auto;
  padding: 4px 0;
}

.pstep {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 72px;
  opacity: 0.3;
  transition: opacity 0.3s;
}

.pstep span {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  white-space: nowrap;
}

.pstep-dot {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  background: var(--bg-elevated);
  transition: all 0.3s;
}

.pstep.pstep-done {
  opacity: 0.7;
}

.pstep.pstep-done .pstep-dot {
  background: rgba(34,197,94,0.1);
  border-color: rgba(34,197,94,0.5);
  color: var(--success);
}

.pstep.pstep-active {
  opacity: 1;
}

.pstep.pstep-active .pstep-dot {
  background: rgba(124,58,237,0.15);
  border-color: var(--accent);
  color: var(--accent-light);
  box-shadow: 0 0 16px var(--accent-glow);
  animation: pulse-step 1.8s infinite;
}

.pstep.pstep-active span { color: var(--text); }

@keyframes pulse-step {
  0%, 100% { box-shadow: 0 0 16px var(--accent-glow); }
  50% { box-shadow: 0 0 28px var(--accent-glow); }
}

.pstep-line {
  flex: 1;
  min-width: 20px;
  height: 1px;
  background: var(--border);
  margin: 0 2px;
  margin-bottom: 22px;
}

/* Progress */
.progress-wrap {
  background: var(--bg-elevated);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light), #818cf8);
  transition: width 0.5s ease;
  border-radius: 999px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* Log box collapsible */
.log-details {
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  overflow: hidden;
}

.log-details summary {
  padding: 10px 14px;
  font-size: 0.78rem;
  color: var(--text-faint);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  user-select: none;
}

.log-details summary::-webkit-details-marker { display: none; }
.log-details summary:hover { color: var(--text-muted); }

.log-box {
  background: #06060c;
  color: #9898b8;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.76rem;
  padding: 14px 16px;
  max-height: 220px;
  overflow-y: auto;
  line-height: 1.7;
  border-top: 1px solid var(--border);
}

/* ─── Shorts grid ────────────────────────────── */

.shorts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
}

.short-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  position: relative;
}

.short-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.5);
  border-color: var(--border-hover);
}

.short-card-num {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  z-index: 2;
  letter-spacing: 0.04em;
}

.short-card video {
  width: 100%;
  display: block;
  aspect-ratio: 9/16;
  object-fit: cover;
  background: #000;
}

.short-card .meta {
  padding: 14px;
}

.short-card h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.short-card .duration {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

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

/* ─── Misc ───────────────────────────────────── */

.form-error {
  color: var(--danger);
  font-size: 0.83rem;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  padding: 10px 14px;
  border-radius: var(--radius-xs);
}

.hidden { display: none !important; }

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 480px) {
  .row-2 { grid-template-columns: 1fr; }
}
