/* ════════════════════════════════════════════════════════════════════
   KortClip Studio — identidade "sala de corte"
   Tema escuro único e deliberado (ferramenta de vídeo).
   Acento #0088F8 = o azul do destaque das legendas do próprio produto.
   ════════════════════════════════════════════════════════════════════ */

@font-face {
  font-family: "CCPowerPop";
  src: url("../assets/CCPowerPop-Wide.ttf") format("truetype");
  font-display: swap;
}

:root {
  --ink-0: #0A0E1A;      /* fundo profundo */
  --ink-1: #0E1322;      /* fundo da página */
  --ink-2: #151C31;      /* superfícies */
  --ink-3: #1D2540;      /* superfícies elevadas / hover */
  --line: #26304F;
  --text: #EEF1F8;
  --muted: #8B94AC;
  --accent: #0088F8;     /* azul-legenda */
  --accent-soft: #39C4FF;
  --accent-ink: #062A4C;
  --good: #3DDC84;
  --warn: #FFC24B;
  --bad: #FF5D73;

  --font-display: "Bricolage Grotesque", "Segoe UI Variable Display", "Avenir Next", system-ui, sans-serif;
  --font-ui: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "Spline Sans Mono", "Cascadia Mono", "Consolas", monospace;

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
}

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

body {
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(0, 136, 248, 0.14), transparent 60%),
    radial-gradient(800px 420px at -10% 110%, rgba(57, 196, 255, 0.07), transparent 55%),
    var(--ink-1);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 96px; /* espaço da renderbar fixa */
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 14px 28px;
  background: color-mix(in srgb, var(--ink-0) 78%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 9px;
  color: #fff;
  background: linear-gradient(140deg, var(--accent-soft), var(--accent) 65%);
  box-shadow: 0 4px 18px rgba(0, 136, 248, 0.35);
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 800; font-size: 1.15rem; letter-spacing: -0.01em;
}
.brand-name em { font-style: normal; color: var(--accent-soft); }
.brand-tag {
  font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; margin-left: 6px;
  vertical-align: 3px;
}

.topnav { display: flex; gap: 4px; }
.topnav a {
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: 0.9rem;
  padding: 8px 14px; border-radius: 999px;
  transition: color 0.2s, background 0.2s;
}
.topnav a:hover { color: var(--text); background: var(--ink-2); }
.topnav a.active { color: var(--text); background: var(--ink-3); }
.topnav a[data-soon]::after {
  content: "em breve"; font-family: var(--font-mono); font-size: 0.55rem;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--warn);
  margin-left: 6px; vertical-align: 2px;
}

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

.gpu-pill {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted);
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; cursor: pointer; transition: border-color 0.2s;
}
.gpu-pill:hover { border-color: var(--accent); color: var(--text); }
.gpu-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.gpu-dot.on  { background: var(--good); box-shadow: 0 0 8px var(--good); }
.gpu-dot.off { background: var(--bad); }
.gpu-dot.busy { background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* Botão de energia da VM (ligar quando off / desligar quando on) */
#vmPowerBtn.is-on:hover { border-color: var(--bad); color: var(--bad); }
#vmPowerBtn:disabled { opacity: 0.55; cursor: default; }

.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px;
  color: var(--muted); background: var(--ink-2);
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }

/* ── Workspace ──────────────────────────────────────────── */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 40px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 40px 28px 24px;
}

.page-head { margin-bottom: 8px; }
.eyebrow {
  font-size: 0.68rem; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--accent-soft); margin: 0 0 10px;
}
.page-head h1 {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 3.4vw, 2.7rem);
  font-weight: 800; line-height: 1.06; letter-spacing: -0.02em;
  margin: 0; text-wrap: balance;
}
.accent-sweep {
  background: linear-gradient(92deg, var(--accent-soft), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ── Módulos (o "roteiro") ──────────────────────────────── */
.script-col { display: flex; flex-direction: column; gap: 22px; min-width: 0; }

.module {
  background: linear-gradient(180deg, color-mix(in srgb, var(--ink-2) 92%, transparent), var(--ink-2));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  display: flex; flex-direction: column; gap: 16px;
  transition: border-color 0.25s;
}
.module:focus-within { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }

.module-head { display: flex; align-items: center; gap: 14px; }
.module-head h2 {
  font-family: var(--font-display); font-size: 1.05rem; font-weight: 600;
  margin: 0; letter-spacing: -0.01em;
}
.tc {
  font-size: 0.68rem; color: var(--accent-soft);
  background: var(--accent-ink); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 6px; padding: 3px 8px;
}
.chip {
  font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--good); border: 1px solid color-mix(in srgb, var(--good) 45%, transparent);
  border-radius: 999px; padding: 3px 9px; margin-left: auto;
}
.module-note { margin: 0; font-size: 0.82rem; color: var(--muted); }

/* ── Campos ─────────────────────────────────────────────── */
.row { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 130px; }
.field.grow { flex: 1 1 240px; }
.field-label { font-size: 0.76rem; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; }
.field-label small { font-weight: 400; opacity: 0.7; }

input[type="text"], input[type="url"], input[type="password"], input[type="number"], select {
  font: inherit; color: var(--text);
  background: var(--ink-1);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 12px; outline: none; width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 136, 248, 0.18);
}
input::placeholder { color: #566078; }
select { cursor: pointer; }
input[type="color"] {
  width: 52px; height: 40px; padding: 4px; cursor: pointer;
  background: var(--ink-1); border: 1px solid var(--line); border-radius: var(--r-sm);
}
input[type="range"] { accent-color: var(--accent); width: 160px; }

.url-wrap { position: relative; }
.url-wrap svg { position: absolute; left: 12px; top: 50%; translate: 0 -50%; color: var(--muted); }
.url-wrap input { padding-left: 38px; }

.check {
  display: flex; align-items: center; gap: 9px;
  font-size: 0.88rem; color: var(--text); cursor: pointer; padding: 9px 0;
}
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ── Tabs de fonte ──────────────────────────────────────── */
.seg-tabs {
  display: flex; gap: 4px; background: var(--ink-1);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px; width: max-content; max-width: 100%;
}
.seg {
  font: inherit; font-size: 0.85rem; font-weight: 500;
  color: var(--muted); background: transparent; border: 0; border-radius: 999px;
  padding: 8px 16px; cursor: pointer; white-space: nowrap;
  transition: color 0.2s, background 0.2s;
}
.seg:hover { color: var(--text); }
.seg.active { color: #fff; background: var(--accent); }

.source-pane { display: flex; flex-direction: column; gap: 14px; }

/* ── Dropzone ───────────────────────────────────────────── */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: var(--r-md); padding: 34px 20px;
  color: var(--muted); text-align: center; cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent); background: rgba(0, 136, 248, 0.06); color: var(--text);
}
.dropzone p { margin: 0; }
.dropzone .hint { font-size: 0.76rem; opacity: 0.75; }
.dropzone svg { color: var(--accent-soft); }

.upload-progress { display: flex; align-items: center; gap: 12px; }
.upload-bar {
  flex: 1; height: 8px; border-radius: 999px; background: var(--ink-1); overflow: hidden;
}
.upload-bar span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent-soft), var(--accent));
  transition: width 0.2s;
}

/* ── Presets de legenda ─────────────────────────────────── */
.preset-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px;
}
.preset-card {
  font: inherit; text-align: left; cursor: pointer;
  background: var(--ink-1); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 12px 14px 10px;
  display: flex; flex-direction: column; gap: 8px;
  transition: border-color 0.2s, transform 0.2s;
}
.preset-card:hover { transform: translateY(-2px); }
.preset-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 136, 248, 0.16), 0 10px 26px -14px rgba(0, 136, 248, 0.5);
}
.preset-sample {
  font-weight: 800; font-size: 0.92rem; letter-spacing: 0.01em; line-height: 1.15;
  text-transform: uppercase;
}
.preset-name { font-size: 0.7rem; color: var(--muted); }
.preset-card.active .preset-name { color: var(--accent-soft); }

/* ── Coluna do preview (telefone) ───────────────────────── */
.preview-col { position: relative; }
.phone-stage {
  position: sticky; top: 92px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}

.phone {
  width: 300px; aspect-ratio: 9 / 19;
  border-radius: 42px; padding: 10px;
  background: linear-gradient(160deg, #232C4A, #12182B 70%);
  border: 1px solid var(--line);
  box-shadow:
    0 30px 70px -30px rgba(0, 0, 0, 0.8),
    0 0 60px -20px rgba(0, 136, 248, 0.25);
}
.phone-screen {
  position: relative; width: 100%; height: 100%;
  border-radius: 34px; overflow: hidden;
  background: linear-gradient(180deg, #101A30 0%, #0B1122 55%, #0A0E1A 100%);
}
.phone-gradient {
  position: absolute; inset: 0;
  background:
    radial-gradient(90% 55% at 50% -12%, rgba(0, 136, 248, 0.35), transparent 60%),
    radial-gradient(70% 40% at 50% 118%, rgba(57, 196, 255, 0.18), transparent 60%);
}

/* barras "waveform" ambiente: lembra o áudio sendo cortado */
.phone-waves {
  position: absolute; left: 0; right: 0; top: 42%;
  display: flex; justify-content: center; align-items: center; gap: 7px; height: 70px;
}
.phone-waves span {
  width: 5px; border-radius: 3px;
  background: color-mix(in srgb, var(--accent) 55%, transparent);
  animation: wave 1.6s ease-in-out infinite;
}
.phone-waves span:nth-child(odd) { animation-duration: 1.9s; }
.phone-waves span:nth-child(3n) { animation-delay: 0.25s; }
.phone-waves span:nth-child(4n) { animation-delay: 0.55s; height: 60%; }
.phone-waves span:nth-child(5n) { animation-delay: 0.8s; }
@keyframes wave {
  0%, 100% { height: 18%; opacity: 0.45; }
  50% { height: 92%; opacity: 0.95; }
}

/* a legenda ao vivo — o momento-herói */
.caption-live {
  position: absolute; left: 8%; right: 8%; bottom: 11%;
  margin: 0; text-align: center;
  font-family: "CCPowerPop", "Arial Black", sans-serif;
  font-size: 1.28rem; line-height: 1.18; letter-spacing: 0.01em;
  color: #fff; text-transform: uppercase;
  text-shadow:
    -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000,
    0 4px 10px rgba(0, 0, 0, 0.6);
}
.caption-live .hl { color: var(--accent); }

.phone-note { font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); text-align: center; }

/* ── Renderbar ──────────────────────────────────────────── */
.renderbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 14px 28px;
  background: color-mix(in srgb, var(--ink-0) 88%, transparent);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.render-status { display: flex; align-items: center; gap: 14px; font-size: 0.8rem; color: var(--muted); }
.render-actions { display: flex; align-items: center; gap: 12px; }

.cta {
  display: inline-flex; align-items: center; gap: 9px;
  font: inherit; font-weight: 600; font-size: 0.95rem; color: #fff;
  background: linear-gradient(135deg, var(--accent-soft), var(--accent) 60%);
  border: 0; border-radius: 999px; padding: 13px 28px; cursor: pointer;
  box-shadow: 0 8px 30px -8px rgba(0, 136, 248, 0.65);
  transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
}
.cta:hover { transform: translateY(-1px); box-shadow: 0 12px 36px -8px rgba(0, 136, 248, 0.8); }
.cta:disabled { filter: grayscale(0.6); opacity: 0.6; cursor: not-allowed; transform: none; }

.ghost-btn, .link-btn {
  font: inherit; font-size: 0.88rem; cursor: pointer;
  color: var(--text); background: transparent;
  border: 1px solid var(--line); border-radius: 999px; padding: 11px 20px;
  transition: border-color 0.2s;
}
.ghost-btn:hover { border-color: var(--bad); color: var(--bad); }
.link-btn { border: 0; padding: 4px 8px; color: var(--accent-soft); text-decoration: underline; }

/* ── Gaveta de logs/resultados ──────────────────────────── */
.drawer {
  position: fixed; right: 24px; bottom: 84px; z-index: 60;
  width: min(560px, calc(100vw - 48px));
  max-height: 62vh; display: flex; flex-direction: column;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.drawer-head h3 { margin: 0; font-family: var(--font-display); font-size: 0.98rem; font-weight: 600; }

.logs {
  margin: 0; padding: 14px 18px; overflow: auto; flex: 1;
  font-size: 0.72rem; line-height: 1.55; color: #A9B3C9;
  white-space: pre-wrap; word-break: break-word;
}

.results {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px;
  padding: 16px 18px; overflow: auto;
}
.results video {
  width: 100%; aspect-ratio: 9 / 16; object-fit: cover;
  border-radius: var(--r-sm); border: 1px solid var(--line); background: #000;
}

/* ── Modal de configurações ─────────────────────────────── */
.settings {
  background: var(--ink-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 26px; width: min(460px, 92vw);
}
.settings::backdrop { background: rgba(5, 8, 16, 0.7); backdrop-filter: blur(4px); }
.settings h3 { margin: 0 0 18px; font-family: var(--font-display); }
.settings form { display: flex; flex-direction: column; gap: 14px; }
.settings menu { display: flex; justify-content: end; gap: 10px; margin: 8px 0 0; padding: 0; }

/* ── Views (Criar novo / Biblioteca / Editor) ───────────── */
.workspace-single {
  max-width: 980px; margin: 0 auto; padding: 40px 28px 24px;
  display: flex; flex-direction: column; gap: 22px;
}
body[data-view="library"] .renderbar,
body[data-view="editor"] .renderbar { display: none; }

/* ── <details> de ajustes avançados ─────────────────────── */
details.adv {
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--ink-1); padding: 0;
}
details.adv summary {
  cursor: pointer; list-style: none;
  padding: 12px 16px; font-size: 0.85rem; font-weight: 600; color: var(--muted);
  display: flex; align-items: center; gap: 8px;
  transition: color 0.2s;
}
details.adv summary::before {
  content: "▸"; color: var(--accent-soft); transition: transform 0.2s;
}
details.adv[open] summary::before { transform: rotate(90deg); }
details.adv summary:hover { color: var(--text); }
details.adv > .row { padding: 4px 16px 16px; }
details.adv > .row + .row { padding-top: 0; }

/* ── Clipes (resultados, biblioteca) ────────────────────── */
.clip-card { display: flex; flex-direction: column; gap: 8px; }
.clip-card video {
  width: 100%; aspect-ratio: 9 / 16; object-fit: cover;
  border-radius: var(--r-sm); border: 1px solid var(--line); background: #000;
}
.clip-meta-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.clip-score {
  font-family: var(--font-display); font-size: 1.85rem; font-weight: 800; line-height: 1;
}
.clip-score.hi { color: #22C55E; }
.clip-score.mid { color: #EAB308; }
.clip-score.low { color: #EF4444; }
.clip-score.na { color: var(--muted); }
.clip-title {
  font-size: 0.8rem; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.clip-desc {
  margin: 0; font-size: 0.72rem; color: var(--muted); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* ── Cortes prontos (página principal) ──────────────────── */
.ready-section { grid-column: 1 / -1; }
.ready-proj {
  font-size: 0.68rem; color: var(--muted);
  max-width: 38%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ready-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
}
.dl-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 0.78rem; font-weight: 600; color: var(--text); text-decoration: none;
  background: var(--ink-3); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 12px; transition: border-color 0.2s, color 0.2s;
}
.dl-btn:hover { border-color: var(--accent); color: var(--accent-soft); }

/* ── Biblioteca ─────────────────────────────────────────── */
.library-list { display: flex; flex-direction: column; gap: 14px; }
.lib-project {
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--ink-2); overflow: hidden;
}
.lib-project summary {
  cursor: pointer; list-style: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px;
}
.lib-project summary::-webkit-details-marker { display: none; }
.lib-name { font-family: var(--font-display); font-weight: 600; }
.lib-count { font-size: 0.7rem; color: var(--muted); }
.lib-project[open] summary { border-bottom: 1px solid var(--line); }
.lib-project .results {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px; padding: 18px 20px;
}

/* ── Editor de legendas ─────────────────────────────────── */
.ed-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); }
.ed-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.ed-table th {
  text-align: left; font-family: var(--font-mono); font-size: 0.65rem;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--ink-1);
}
.ed-table td { padding: 4px 6px; border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent); }
.ed-table input {
  border: 1px solid transparent; background: transparent; padding: 7px 8px;
}
.ed-table input:hover { border-color: var(--line); }
.ed-table input:focus { background: var(--ink-1); }

/* ── Login ──────────────────────────────────────────────── */
.login-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--ink-0) 88%, transparent);
  backdrop-filter: blur(10px);
}
.login-card {
  display: flex; flex-direction: column; gap: 14px;
  width: min(380px, 92vw);
  background: var(--ink-2); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 30px 28px;
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.9), 0 0 60px -30px rgba(0, 136, 248, 0.4);
}
.login-card h3 {
  margin: 6px 0 2px; text-align: center;
  font-family: var(--font-display); font-weight: 600; font-size: 1.1rem;
}
.login-error { min-height: 1.2em; margin: 0; font-size: 0.72rem; color: var(--bad); text-align: center; }
.login-card .link-btn { align-self: center; }

/* ── Responsivo ─────────────────────────────────────────── */
@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .preview-col { order: -1; }
  .phone-stage { position: static; }
  .phone { width: 220px; }
  .topnav { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
