/* Faceswap web UI.  Single stylesheet, no build step, no external fonts. */

:root {
  --bg: #0f1116;
  --surface: #171a21;
  --surface-2: #1f2430;
  --border: #2a3040;
  --text: #e6e9ef;
  --muted: #939cb0;
  --accent: #5b8cff;
  --accent-strong: #7aa2ff;
  --success: #3fb950;
  --danger: #f26d6d;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

/* The UA `[hidden] { display: none }` rule loses to any author `display` rule of
   equal specificity (`.auth-overlay`, `.layout`, `.auth-status` all set one), so
   toggling `element.hidden` in JS would not actually hide those elements -- the
   login overlay stayed up over the app after a successful sign-in. Make `hidden`
   authoritative everywhere. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  padding: 0 0 4rem;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* -- chrome ------------------------------------------------------------- */

.topbar {
  padding: 1.75rem 2rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.01em;
}

.subtitle {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 1.25rem;
  align-items: start;
  max-width: 1400px;
  margin: 1.5rem auto 0;
  padding: 0 2rem;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    padding: 0 1rem;
  }
}

.column {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
}

/* Mode-gated controls. The server's --mode (prod / pilot / debug) is reported
   by /api/config; app.js stamps the matching `mode-<name>` class on <body>. The
   advanced options are `.debug-only`: shown only in debug, hidden in the trimmed
   prod/pilot layout (pilot looks identical to prod -- it differs only in that
   the server logs each upload). */
body:not(.mode-debug) .debug-only {
  display: none;
}

.card h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 600;
}

.step {
  display: grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--accent);
  color: #0b0e14;
  font-size: 0.8rem;
  font-weight: 700;
}

.hint {
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.hint strong {
  color: var(--text);
  font-weight: 600;
}

/* -- file slots --------------------------------------------------------- */

.faces {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.75rem;
  align-items: start;
}

@media (max-width: 560px) {
  .faces {
    grid-template-columns: 1fr;
  }
  .faces .arrow {
    transform: rotate(90deg);
  }
}

.arrow {
  align-self: center;
  padding-top: 1.5rem;
  color: var(--muted);
  font-size: 1.3rem;
}

.slot-label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
}

.required,
.optional {
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.required {
  background: rgba(91, 140, 255, 0.18);
  color: var(--accent-strong);
}

.optional {
  background: rgba(147, 156, 176, 0.16);
  color: var(--muted);
}

.dropzone {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  width: 100%;
  padding: 1.4rem 1rem;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.slot.dragging .dropzone {
  border-color: var(--accent);
  background: rgba(91, 140, 255, 0.08);
}

.dropzone-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.dropzone-sub {
  color: var(--muted);
  font-size: 0.78rem;
}

.preview {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.thumb {
  width: 100%;
  max-height: 190px;
  object-fit: contain;
  background: #0b0e14;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.preview-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.preview-meta .link {
  flex-shrink: 0;
}

.filename {
  /* min-width:0 lets this flex item shrink below its content width so the
     ellipsis engages, instead of a long name stretching .preview-meta. */
  min-width: 0;
  flex: 1;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-progress {
  height: 3px;
  margin-top: 0.5rem;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.upload-bar {
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.12s linear;
}

/* -- advanced options --------------------------------------------------- */

summary {
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
}

.options {
  display: grid;
  gap: 0.85rem;
  margin-top: 0.9rem;
}

.options label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.options small {
  color: var(--muted);
  font-weight: 400;
}

.options input[type="number"] {
  width: 100%;
  max-width: 180px;
  padding: 0.4rem 0.55rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font: inherit;
}

.options .checkbox {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.5rem;
}

.options .checkbox small {
  grid-column: 2;
}

/* -- actions ------------------------------------------------------------ */

.actions {
  display: flex;
  gap: 0.65rem;
}

button.primary,
button.danger {
  padding: 0.65rem 1.3rem;
  border: none;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  color: #0b0e14;
}

button.primary:disabled {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}

button.danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}

.link {
  padding: 0;
  background: none;
  border: none;
  color: var(--accent-strong);
  font: inherit;
  font-size: 0.8rem;
  text-decoration: none;
  cursor: pointer;
}

.link:hover {
  text-decoration: underline;
}

.error {
  margin: 0.75rem 0 0;
  padding: 0.6rem 0.75rem;
  background: rgba(242, 109, 109, 0.1);
  border: 1px solid rgba(242, 109, 109, 0.35);
  border-radius: 8px;
  color: var(--danger);
  font-size: 0.85rem;
  white-space: pre-wrap;
}

/* -- progress ----------------------------------------------------------- */

.status-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0.6rem 0 0.5rem;
}

.badge {
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge[data-state="queued"] {
  background: rgba(230, 179, 71, 0.16);
  color: #e6b347;
}

.badge[data-state="running"] {
  background: rgba(91, 140, 255, 0.16);
  color: var(--accent-strong);
}

.badge[data-state="succeeded"] {
  background: rgba(63, 185, 80, 0.16);
  color: var(--success);
}

.badge[data-state="failed"],
.badge[data-state="cancelled"] {
  background: rgba(242, 109, 109, 0.14);
  color: var(--danger);
}

.percent {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.bar {
  height: 9px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  border-radius: 999px;
  transition: width 0.25s ease-out;
}

.bar-fill.indeterminate {
  width: 35%;
  animation: slide 1.4s ease-in-out infinite;
}

@keyframes slide {
  0% { margin-left: -35%; }
  100% { margin-left: 100%; }
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 1rem 0 0;
}

.stats dt {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stats dd {
  margin: 0.15rem 0 0;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

/* -- output ------------------------------------------------------------- */

.live-tag {
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: rgba(242, 109, 109, 0.16);
  color: var(--danger);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#output {
  width: 100%;
  max-height: 60vh;
  margin-top: 0.6rem;
  background: #000;
  border-radius: var(--radius);
}

.video-actions {
  display: flex;
  gap: 1rem;
  margin-top: 0.6rem;
}

#log {
  max-height: 320px;
  margin: 0.75rem 0 0;
  padding: 0.75rem;
  overflow: auto;
  background: #0b0e14;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

/* -- auth ------------------------------------------------------------------ */

.auth-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.55);
}

.auth-card {
  width: 100%;
  max-width: 22rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.75rem;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.auth-card h2 {
  margin: 0;
}

.auth-card label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.auth-card input {
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
}

.auth-switch {
  margin: 0.25rem 0 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.auth-message {
  margin: 0;
  color: var(--success);
  font-size: 0.85rem;
}
