/* ===== Variables ===== */
:root {
  --bg: #080810;
  --bg-card: #0f0f1a;
  --accent: #7c3aed;
  --accent-blue: #3b82f6;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: rgba(124, 58, 237, 0.3);
  --font: 'Space Grotesk', sans-serif;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.6; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ===== Navbar ===== */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 2rem;
  background: rgba(8, 8, 16, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-logo { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; font-size: 1.1rem; }
.nav-links { display: flex; gap: 2rem; align-items: center; }
.nav-links a { color: var(--text-muted); font-size: 0.9rem; transition: color 0.2s; }
.nav-links a:hover { color: var(--text); }
.nav-btn-admin { background: var(--accent); color: #fff !important; padding: 0.3rem 0.9rem; border-radius: 6px; font-size: 0.82rem !important; font-weight: 600; transition: opacity 0.2s !important; }
.nav-btn-admin:hover { opacity: 0.85; color: #fff !important; }

/* ===== Hero ===== */
.hero {
  position: relative; height: 100vh; min-height: 600px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.stars { position: absolute; inset: 0; z-index: 0; }
#blackhole { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; }
.hero-top {
  position: absolute; top: 15%; left: 0; right: 0; z-index: 2;
  text-align: center;
  font-size: clamp(1rem, 2.5vw, 1.3rem); letter-spacing: 0.5em; font-weight: 700;
  color: var(--text-muted);
}
.hero-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 1.2rem;
  text-align: center; padding: 2rem;
  margin-top: 28vh;
}
.hero-brand-bottom {
  font-size: clamp(4rem, 11vw, 8rem); font-weight: 700; letter-spacing: 0.15em;
  line-height: 1;
  background: linear-gradient(135deg, #fff 0%, #c4b5fd 50%, var(--accent) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(0 0 30px rgba(124,58,237,0.6));
}
.hero-tagline {
  font-size: 0.8rem; letter-spacing: 0.2em; color: var(--text-muted);
  font-weight: 600;
}

/* ===== Buttons ===== */
.btn {
  display: inline-block; padding: 0.75rem 2rem; border-radius: 4px;
  font-family: var(--font); font-weight: 700; font-size: 0.9rem; letter-spacing: 0.05em;
  cursor: pointer; border: none; transition: all 0.2s;
}
.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 0 20px rgba(124,58,237,0.4);
}
.btn-primary:hover { background: #6d28d9; box-shadow: 0 0 30px rgba(124,58,237,0.6); }
.btn-outline {
  background: transparent; color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 0.4rem 1rem; font-size: 0.8rem; }
.btn-danger { background: #c0392b; color: #fff; border: none; }
.btn-danger:hover { background: #e74c3c; }

/* ===== Container ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }

/* ===== Stories section ===== */
.stories-section { padding: 5rem 0; }
.section-title {
  font-size: 2rem; font-weight: 700; margin-bottom: 2.5rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-blue));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}
.empty-state { color: var(--text-muted); font-size: 1.1rem; }

/* ===== Cards ===== */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; transition: transform 0.2s, box-shadow 0.2s;
  display: block;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 40px rgba(124,58,237,0.25);
  border-color: var(--accent);
}
.card-thumb { aspect-ratio: 16/9; overflow: hidden; }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.card:hover .card-thumb img { transform: scale(1.05); }
.card-body { padding: 1.25rem; }
.card-topic { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); font-weight: 600; }
.card-title { font-size: 1.05rem; font-weight: 700; margin: 0.4rem 0 0.5rem; line-height: 1.3; }
.card-date { font-size: 0.8rem; color: var(--text-muted); }

/* ===== Story hero ===== */
.story-hero {
  height: 60vh; min-height: 400px;
  background-size: cover; background-position: center;
  display: flex; align-items: flex-end;
}
.story-hero-overlay {
  width: 100%;
  background: linear-gradient(to top, rgba(8,8,16,1) 0%, rgba(8,8,16,0.6) 50%, transparent 100%);
  padding: 3rem 0;
}
.story-badge {
  display: inline-block; padding: 0.3rem 0.8rem; border-radius: 3px;
  background: var(--accent); font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.75rem;
}
.story-title { font-size: clamp(1.8rem, 4vw, 3rem); font-weight: 700; line-height: 1.2; margin-bottom: 0.5rem; }
.story-date { color: var(--text-muted); font-size: 0.9rem; }

/* ===== Story content ===== */
.story-content { padding: 4rem 0; }
.story-container { max-width: 860px; }
.video-wrapper {
  aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; margin-bottom: 2rem;
  border: 1px solid var(--border);
}
.video-wrapper iframe { width: 100%; height: 100%; }
.story-description { font-size: 1.05rem; color: var(--text-muted); line-height: 1.8; margin-bottom: 1.5rem; }
.story-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 2rem; }
.tag {
  padding: 0.3rem 0.8rem; border-radius: 20px;
  background: rgba(124,58,237,0.15); border: 1px solid var(--border);
  font-size: 0.8rem; color: var(--text-muted);
}

/* ===== Admin ===== */
.admin-login {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 1.5rem; padding: 2rem;
}
.admin-logo { width: 120px; margin-bottom: 0.5rem; }
.admin-form { display: flex; flex-direction: column; gap: 1rem; width: 100%; max-width: 340px; }
.admin-input {
  padding: 0.75rem 1rem; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); font-family: var(--font); font-size: 1rem;
  outline: none;
}
.admin-input:focus { border-color: var(--accent); }
.admin-error { color: #f87171; font-size: 0.9rem; }

.admin-dashboard { min-height: 100vh; padding: 6rem 0 4rem; }
.dashboard-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2rem; }
.dashboard-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  padding: 1.75rem; margin-bottom: 1.5rem;
}
.dashboard-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; }
.status-ok { color: #4ade80; }
.status-warn { color: #fb923c; }
.status-coming { color: var(--text-muted); }
.pipeline-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.6rem; }
.pipeline-btn { justify-content: center; }
.pipeline-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.social-list { list-style: none; display: flex; flex-direction: column; gap: 0.75rem; }
.social-list li { display: flex; align-items: center; gap: 0.75rem; color: var(--text-muted); }

/* ===== Footer ===== */
.footer {
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  gap: 0.75rem; padding: 2.5rem 1rem;
  border-top: 1px solid var(--border);
  text-align: center; color: var(--text-muted); font-size: 0.85rem;
}
.footer-social { display: flex; gap: 1.5rem; }
.footer-social a { color: var(--text-muted); transition: color 0.2s; }
.footer-social a:hover { color: var(--accent); }

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .navbar { padding: 0.75rem 1rem; }
  .nav-links { gap: 1rem; }
  .stories-grid { grid-template-columns: 1fr; }
}

/* ===== Admin Studio Wizard ===== */
.studio-page { padding: 6rem 1rem 4rem; max-width: 900px; margin: 0 auto; }
.studio-page h2 { font-size: 1.8rem; margin-bottom: 2rem; color: var(--text); }

/* Step progress bar */
.step-bar { display: flex; gap: 0; margin-bottom: 2.5rem; border-radius: 8px; overflow: visible; align-items: stretch; }
.step-item {
  flex: 1; padding: 0.6rem 0.5rem; text-align: center; font-size: 0.72rem; font-weight: 600;
  background: var(--bg-card); color: var(--text-muted); border: 1px solid var(--border);
  transition: background 0.2s, color 0.2s;
}
.step-item.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.step-item.done { background: #1e3a1e; color: #4ade80; border-color: #166534; }
.btn-clear-cache {
  flex: 0 0 auto; font-size: 0.72rem; padding: 0.4rem 0.8rem;
  border-radius: 6px; border: 1px solid var(--border); margin-left: 0.8rem;
  background: var(--bg-card); color: var(--text-muted); cursor: pointer;
  white-space: nowrap; align-self: center; transition: color 0.2s, border-color 0.2s;
}
.btn-clear-cache:hover { color: var(--text); border-color: var(--accent); }
.btn-clear-cache:disabled { opacity: 0.6; cursor: default; }
.retry-block {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.7rem;
  padding: 1rem 1.2rem; background: rgba(248,113,113,0.08); border: 1px solid rgba(248,113,113,0.3);
  border-radius: 8px; margin: 0.5rem 0;
}
.retry-block .retry-msg { color: #f87171; margin: 0; font-size: 0.9rem; }

/* Format grid */
.format-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.format-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  padding: 1.2rem 1rem; text-align: center; cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, background 0.2s;
}
.format-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.format-card.selected { border-color: var(--accent); background: rgba(124,58,237,0.15); }
.format-card .format-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.format-card .format-name { font-weight: 700; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* Topic container scrollabile */
.topics-container {
  height: 440px; overflow-y: auto; border: 1px solid var(--border);
  border-radius: 10px; padding: 0.75rem; background: var(--bg-dark);
  margin-top: 0.4rem;
}
.topics-container::-webkit-scrollbar { width: 6px; }
.topics-container::-webkit-scrollbar-track { background: transparent; }
.topics-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Topic list */
.topic-list { display: flex; flex-direction: column; gap: 0.75rem; }
.topic-item {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.85rem 1rem; font-size: 0.9rem;
}
.topic-item .topic-text { flex: 1; line-height: 1.4; }

/* Script editor */
.script-editor { width: 100%; min-height: 280px; background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 1rem; font-family: var(--font);
  font-size: 0.9rem; line-height: 1.6; resize: vertical; }
.meta-field { width: 100%; background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 0.6rem 0.8rem;
  font-family: var(--font); font-size: 0.9rem; margin-bottom: 0.6rem; }
.field-label { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.3rem; display: block; }

/* Clip grid */
.clip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin-top: 1rem; }
.clip-card {
  position: relative; border-radius: 8px; overflow: hidden;
  border: 2px solid var(--border); cursor: pointer; transition: border-color 0.2s;
}
.clip-card.active { border-color: var(--accent); }
.clip-card.inactive { opacity: 0.4; border-color: transparent; }
.clip-thumb { width: 100%; height: 130px; object-fit: cover; display: block; background: var(--bg-card); }
.clip-hover-video { display: none; width: 100%; height: 130px; object-fit: cover; background: #000; }
.clip-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.25); font-size: 2rem; opacity: 0; transition: opacity 0.2s;
}
.clip-card:hover .clip-overlay { opacity: 1; }
.clip-badge {
  position: absolute; top: 6px; right: 6px; background: var(--accent); color: #fff;
  border-radius: 4px; padding: 2px 6px; font-size: 0.7rem; font-weight: 700;
}
.clip-card.inactive .clip-badge { background: #555; }

/* Badge fonte clip */
.clip-source-badge {
  position: absolute; top: 6px; left: 6px;
  background: rgba(0,0,0,0.72); color: #fff;
  font-size: 0.68rem; padding: 2px 6px; border-radius: 4px;
  pointer-events: none; backdrop-filter: blur(4px);
  font-weight: 600; letter-spacing: 0.02em;
}
.btn-replace-clip {
  position: absolute; top: 6px; right: 6px;
  background: rgba(0,0,0,0.72); color: #fff; border: none;
  font-size: 0.85rem; padding: 3px 7px; border-radius: 4px;
  cursor: pointer; backdrop-filter: blur(4px);
  opacity: 0; transition: opacity 0.15s;
  z-index: 10;
}
.clip-card:hover .btn-replace-clip,
.clip-card.replacing .btn-replace-clip { opacity: 1; }
.clip-keyword-badge {
  position: absolute; bottom: 6px; left: 6px; right: 36px;
  background: rgba(0,0,0,0.85); color: #c0c0e0;
  font-size: 0.68rem; padding: 2px 6px; border-radius: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: auto; cursor: pointer; z-index: 5;
}
.clip-keyword-badge:hover { background: rgba(124,58,237,0.85); color: #fff; }

/* ── Clip Picker Modal ── */
.clip-picker-modal {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.clip-picker-inner {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; width: min(92vw, 860px);
  max-height: 85vh; display: flex; flex-direction: column;
  overflow: hidden;
}
.clip-picker-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.2rem; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.picker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.9rem; padding: 1.2rem; overflow-y: auto;
}
.picker-card {
  border-radius: 8px; overflow: hidden; border: 2px solid var(--border);
  transition: border-color 0.15s; background: var(--bg);
}
.picker-card:hover { border-color: var(--accent); }
.picker-thumb-wrap {
  position: relative; width: 100%; aspect-ratio: 16/9;
  overflow: hidden; cursor: pointer;
}
.picker-thumb, .picker-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.picker-video { display: none; }
.picker-overlay {
  position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,0.3); font-size: 2rem;
  opacity: 0; transition: opacity 0.15s;
}
.picker-thumb-wrap:hover .picker-overlay { opacity: 1; }
.picker-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.55rem 0.7rem; gap: 0.5rem;
}
.picker-source { font-size: 0.75rem; color: var(--text-muted); }
.picker-loading {
  grid-column: 1 / -1; text-align: center;
  padding: 2rem; color: var(--text-muted); font-size: 0.9rem;
}

/* SSE Log */
.publish-log {
  background: #0a0a14; border: 1px solid var(--border); border-radius: 8px;
  padding: 1.2rem; min-height: 200px; font-family: 'Courier New', monospace;
  font-size: 0.85rem; line-height: 1.8;
}
.log-entry { display: flex; align-items: center; gap: 0.6rem; }
.log-entry.done { color: #4ade80; }
.log-entry.start { color: var(--text-muted); }
.log-entry.error { color: #f87171; }
.log-spinner { display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--text-muted); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Progress bar SSE */
.publish-progress { height: 6px; background: var(--border); border-radius: 3px; margin-bottom: 0.5rem; overflow: hidden; }
.publish-progress-bar { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.8s ease; width: 0%; }
.publish-eta { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 1rem; font-variant-numeric: tabular-nums; }
.preview-actions { display: flex; gap: 0.8rem; margin-top: 1rem; justify-content: center; flex-wrap: wrap; }

/* Shared */
.studio-section { display: none; }
.studio-section.active { display: block; }
.studio-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; flex-wrap: wrap; }
.spinner-wrap { text-align: center; padding: 2rem; color: var(--text-muted); }
.spinner-large { display: inline-block; width: 32px; height: 32px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite; }
.success-banner { background: #1e3a1e; border: 1px solid #166534; border-radius: 8px;
  padding: 1.5rem; text-align: center; }
.success-banner h3 { color: #4ade80; margin-bottom: 0.5rem; }
