/* SKOPA Training Pipeline — Dark Theme */

@font-face {
  font-family: 'Rajdhani';
  src: url('/fonts/Rajdhani-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal;
}
@font-face {
  font-family: 'Rajdhani';
  src: url('/fonts/Rajdhani-Medium.woff2') format('woff2');
  font-weight: 500; font-style: normal;
}
@font-face {
  font-family: 'Rajdhani';
  src: url('/fonts/Rajdhani-SemiBold.woff2') format('woff2');
  font-weight: 600; font-style: normal;
}
@font-face {
  font-family: 'Rajdhani';
  src: url('/fonts/Rajdhani-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Latin.woff2') format('woff2');
  font-weight: 400; font-style: normal;
}

:root {
  --bg: #111; --bg2: #1a1a1a; --bg3: #232323; --border: #333;
  --text: #ddd; --dim: #888; --cyan: #5ef; --green: #5e5; --red: #f55;
  --amber: #fa0; --font: 'Rajdhani', sans-serif; --mono: 'JetBrains Mono', monospace;
  --radius: 6px;
}

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

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

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────── */

.navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 48px;
  background: var(--bg2); border-bottom: 1px solid var(--border);
}
.navbar-brand {
  font-size: 18px; font-weight: 700; color: var(--cyan);
  letter-spacing: 2px; text-transform: uppercase;
}
.navbar-links { display: flex; gap: 16px; align-items: center; }
.navbar-links a { color: var(--dim); font-size: 14px; font-weight: 500; }
.navbar-links a:hover, .navbar-links a.active { color: var(--cyan); text-decoration: none; }

.container { max-width: 1200px; margin: 0 auto; padding: 24px; }
.page-title { font-size: 24px; font-weight: 600; margin-bottom: 20px; }

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

.auth-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
}
.auth-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px; width: 100%; max-width: 400px;
}
.auth-card h1 {
  text-align: center; font-size: 28px; font-weight: 700;
  color: var(--cyan); letter-spacing: 3px; margin-bottom: 8px;
}
.auth-card .subtitle {
  text-align: center; color: var(--dim); font-size: 14px; margin-bottom: 24px;
}
.auth-card .toggle { text-align: center; margin-top: 16px; font-size: 13px; color: var(--dim); }
.auth-card .toggle a { cursor: pointer; }

/* ── Forms ──────────────────────────────────────────────── */

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--dim); margin-bottom: 4px; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
select, textarea {
  width: 100%; padding: 8px 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-family: var(--font); font-size: 14px;
  outline: none; transition: border-color .2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--cyan); }
textarea { resize: vertical; min-height: 60px; }

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

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg3); color: var(--text); font-family: var(--font);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s;
  text-transform: uppercase; letter-spacing: 1px;
}
.btn:hover { border-color: var(--cyan); color: var(--cyan); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary { background: var(--cyan); color: #111; border-color: var(--cyan); }
.btn-primary:hover { background: #3cf; }

.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #111; }

.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-block { width: 100%; justify-content: center; }

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

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }

.card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; transition: border-color .2s; cursor: pointer;
}
.card:hover { border-color: var(--cyan); }
.card h3 { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.card .card-meta { color: var(--dim); font-size: 13px; margin-bottom: 12px; }
.card .card-stats { display: flex; gap: 16px; flex-wrap: wrap; }
.card .stat { font-size: 13px; color: var(--dim); }
.card .stat strong { color: var(--text); }

/* ── Badge ──────────────────────────────────────────────── */

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 3px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
}
.badge-green { background: rgba(85,238,85,.15); color: var(--green); }
.badge-amber { background: rgba(255,170,0,.15); color: var(--amber); }
.badge-red { background: rgba(255,85,85,.15); color: var(--red); }
.badge-dim { background: rgba(136,136,136,.15); color: var(--dim); }
.badge-cyan { background: rgba(85,238,255,.15); color: var(--cyan); }

/* ── Tabs ───────────────────────────────────────────────── */

.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 10px 20px; font-size: 14px; font-weight: 500; color: var(--dim);
  cursor: pointer; border-bottom: 2px solid transparent; transition: all .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--cyan); border-bottom-color: var(--cyan); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Tables ─────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--border); }
th { color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; font-size: 11px; }
tr:hover td { background: rgba(85,238,255,.03); }

/* ── Progress bar ───────────────────────────────────────── */

.progress-bar {
  height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin-top: 6px;
}
.progress-bar .fill {
  height: 100%; border-radius: 3px; transition: width .3s;
  background: var(--cyan);
}
.progress-bar .fill.green { background: var(--green); }
.progress-bar .fill.amber { background: var(--amber); }
.progress-bar .fill.red { background: var(--red); }

/* ── Stage Stepper ──────────────────────────────────────── */

.stage-stepper {
  display: flex; gap: 0; overflow-x: auto; padding-bottom: 8px;
}
.stage-card {
  flex: 1; min-width: 150px; padding: 16px;
  background: var(--bg2); border: 1px solid var(--border); position: relative;
}
.stage-card:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.stage-card:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.stage-card + .stage-card { border-left: none; }
.stage-card.complete { border-color: rgba(85,238,85,.3); }
.stage-card.running { border-color: rgba(255,170,0,.3); }
.stage-card.failed { border-color: rgba(255,85,85,.3); }

.stage-card .stage-name { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.stage-card .stage-info { font-size: 12px; color: var(--dim); margin-bottom: 8px; }
.stage-card .stage-actions { margin-top: 8px; }

/* Arrow connector between stages */
.stage-card + .stage-card::before {
  content: ''; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 0; height: 0;
  border-top: 8px solid transparent; border-bottom: 8px solid transparent;
  border-left: 8px solid var(--border);
}

/* ── Video list ─────────────────────────────────────────── */

.video-list { display: flex; flex-direction: column; gap: 8px; }
.video-item {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 16px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); transition: border-color .15s;
}
.video-item:hover { border-color: var(--cyan); cursor: pointer; }
.video-thumb {
  width: 80px; height: 60px; background: var(--bg3); border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  color: var(--dim); font-size: 11px; overflow: hidden; flex-shrink: 0;
}
.video-thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-info { flex: 1; }
.video-info .name { font-weight: 600; font-size: 14px; }
.video-info .meta { color: var(--dim); font-size: 12px; }
.video-badges { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Upload zone ────────────────────────────────────────── */

.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 40px; text-align: center; color: var(--dim); cursor: pointer;
  transition: all .2s; margin-bottom: 16px;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--cyan); color: var(--cyan);
}
.upload-zone p { margin-top: 8px; font-size: 13px; }

/* ── Dialog / Modal ─────────────────────────────────────── */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; width: 100%; max-width: 480px;
}
.modal h2 { font-size: 18px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── Job log ────────────────────────────────────────────── */

.job-log-viewer {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; max-height: 400px; overflow-y: auto;
  font-family: var(--mono); font-size: 12px; line-height: 1.6;
}
.job-log-viewer .log-line { white-space: pre-wrap; word-break: break-all; }
.job-log-viewer .log-line .ts { color: var(--dim); }
.job-log-viewer .log-line.warn { color: var(--amber); }
.job-log-viewer .log-line.error { color: var(--red); }

/* ── Video Browser (NLE) ───────────────────────────────── */

.vb-container { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }

.vb-viewer { position: relative; background: #000; border-radius: 4px; overflow: hidden; margin-bottom: 12px; }
.vb-viewer canvas { display: block; width: 100%; }

.vb-controls {
  display: flex; align-items: center; gap: 12px; padding: 8px 0;
  border-bottom: 1px solid var(--border); margin-bottom: 12px;
}
.vb-controls .frame-counter { font-family: var(--mono); font-size: 13px; color: var(--dim); }

.vb-filmstrip {
  height: 48px; overflow-x: auto; display: flex; gap: 1px;
  background: var(--bg); border-radius: 4px; margin-bottom: 12px;
}
.vb-filmstrip .fs-frame {
  width: 6px; flex-shrink: 0; position: relative; cursor: pointer;
}
.vb-filmstrip .fs-dot {
  width: 4px; height: 4px; border-radius: 50%;
  position: absolute; bottom: 2px; left: 1px;
}

.vb-timeline {
  height: 80px; background: var(--bg); border-radius: 4px;
  position: relative; overflow: hidden; cursor: pointer;
}
.vb-timeline .tl-bar {
  position: absolute; bottom: 0; width: 2px; min-width: 1px;
  background: var(--dim);
}
.vb-timeline .tl-exclusion {
  position: absolute; top: 0; bottom: 0;
  background: rgba(255,85,85,.2); border-left: 1px solid var(--red); border-right: 1px solid var(--red);
}
.vb-timeline .tl-target {
  position: absolute; top: 0; bottom: 0;
  background: rgba(255,170,0,.2); border-left: 1px solid var(--amber); border-right: 1px solid var(--amber);
}
.vb-timeline .tl-playhead {
  position: absolute; top: 0; bottom: 0; width: 2px; background: var(--cyan); z-index: 2;
}

.vb-shortcuts { display: flex; gap: 16px; flex-wrap: wrap; padding: 8px 0; font-size: 12px; color: var(--dim); }
.vb-shortcuts kbd {
  display: inline-block; padding: 1px 5px; background: var(--bg3);
  border: 1px solid var(--border); border-radius: 3px;
  font-family: var(--mono); font-size: 11px; color: var(--text);
}

/* ── Settings ───────────────────────────────────────────── */

.settings-section { margin-bottom: 32px; }
.settings-section h2 { font-size: 18px; font-weight: 600; margin-bottom: 12px; }

.api-key-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.api-key-row .key-name { font-weight: 600; }
.api-key-row .key-prefix { font-family: var(--mono); font-size: 12px; color: var(--dim); }
.api-key-row .key-scopes { font-size: 12px; color: var(--dim); flex: 1; }

/* ── Toasts ─────────────────────────────────────────────── */

.toast-container { position: fixed; top: 60px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 16px; border-radius: var(--radius); font-size: 13px;
  background: var(--bg2); border: 1px solid var(--border);
  animation: toast-in .2s ease-out;
}
.toast.error { border-color: var(--red); color: var(--red); }
.toast.success { border-color: var(--green); color: var(--green); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* ── Empty state ────────────────────────────────────────── */

.empty-state {
  text-align: center; padding: 48px 24px; color: var(--dim);
}
.empty-state .icon { font-size: 36px; margin-bottom: 12px; opacity: .5; }
.empty-state p { font-size: 14px; margin-bottom: 16px; }

/* ── Utility ────────────────────────────────────────────── */

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-dim { color: var(--dim); }
.text-sm { font-size: 13px; }
.hidden { display: none; }

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 768px) {
  .container { padding: 16px; }
  .card-grid { grid-template-columns: 1fr; }
  .stage-stepper { flex-direction: column; }
  .stage-card + .stage-card::before { display: none; }
  .stage-card, .stage-card:first-child, .stage-card:last-child { border-radius: var(--radius); }
  .stage-card + .stage-card { border-left: 1px solid var(--border); margin-top: 8px; }
  .navbar { padding: 0 12px; }
}
