/*
 * Se conserva la identidad visual de la version anterior (degradado violeta,
 * tarjetas blancas redondeadas) pero reescrita sobre variables CSS y sin
 * depender de FontAwesome por CDN: la politica de seguridad de contenido solo
 * permite recursos propios, asi que los iconos son SVG en linea.
 */

:root {
  --brand: #667eea;
  --brand-dark: #5a67d8;
  --brand-deep: #4c51bf;
  --accent: #764ba2;
  --ink: #2d3748;
  --ink-soft: #4a5568;
  --muted: #718096;
  --faint: #a0aec0;
  --line: #e2e8f0;
  --surface: #ffffff;
  --surface-alt: #f8f9ff;
  --ok: #38a169;
  --warn: #d69e2e;
  --danger: #e53e3e;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.55;
}

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.icon { width: 1em; height: 1em; vertical-align: -0.125em; fill: currentColor; flex: none; }

/* --- Acceso --------------------------------------------------------------- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px;
  width: min(400px, 100%);
}

.login-card h1 { font-size: 1.5rem; margin-bottom: 6px; }
.login-card p.sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 28px; }

/* --- Estructura ----------------------------------------------------------- */

.app { max-width: 1400px; margin: 0 auto; padding: 20px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  color: white;
  padding: 8px 4px 24px;
}

.topbar h1 { font-size: 1.35rem; font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 0.85rem; opacity: 0.85; }

.link-btn {
  color: white;
  text-decoration: underline;
  font-size: 0.85rem;
  opacity: 0.85;
}
.link-btn:hover { opacity: 1; }

.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.card + .card { margin-top: 20px; }

.card h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Formularios ---------------------------------------------------------- */

.field { margin-bottom: 16px; }

.field label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 7px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 13px;
  border: 2px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  transition: border-color 0.2s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand);
}

.field textarea { resize: vertical; min-height: 90px; font-family: inherit; }
.field .hint { font-size: 0.78rem; color: var(--muted); margin-top: 5px; }

.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: 600;
  background: var(--brand);
  color: white;
  transition: background 0.2s, transform 0.1s;
}
.btn:hover:not(:disabled) { background: var(--brand-dark); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface-alt); color: var(--brand-deep); border: 2px solid var(--line); }
.btn.ghost:hover:not(:disabled) { background: #eef0ff; border-color: var(--brand); }
.btn.small { padding: 7px 13px; font-size: 0.83rem; }

/* --- Zona de subida ------------------------------------------------------- */

.dropzone {
  border: 3px dashed var(--line);
  border-radius: var(--radius);
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--surface-alt);
  transition: border-color 0.2s, background 0.2s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--brand);
  background: #f0f2ff;
}
.dropzone .icon { width: 40px; height: 40px; color: var(--brand); margin-bottom: 10px; }
.dropzone strong { display: block; color: var(--ink-soft); margin-bottom: 4px; }
.dropzone span { font-size: 0.82rem; color: var(--faint); }

.file-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--surface-alt);
  border: 2px solid var(--line);
  border-radius: 10px;
}
.file-chip .meta { flex: 1; min-width: 0; }
.file-chip .name {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-chip .size { font-size: 0.78rem; color: var(--muted); }
.file-chip .remove { color: var(--danger); padding: 6px; border-radius: 6px; }
.file-chip .remove:hover { background: #fed7d7; }

audio { width: 100%; margin-top: 12px; }

/* --- Progreso ------------------------------------------------------------- */

.progress-box {
  background: var(--surface-alt);
  border-radius: 10px;
  padding: 18px;
  border: 2px solid var(--line);
}

.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.progress-head .label { font-weight: 600; font-size: 0.9rem; }
.progress-head .pct { font-weight: 700; color: var(--brand); }

.bar { height: 9px; background: var(--line); border-radius: 5px; overflow: hidden; }
.bar > div {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  border-radius: 5px;
  transition: width 0.4s ease;
}

.progress-detail { font-size: 0.8rem; color: var(--muted); margin-top: 9px; }

/* --- Historial ------------------------------------------------------------ */

.history { display: flex; flex-direction: column; gap: 8px; max-height: 460px; overflow-y: auto; }

.job {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 2px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
  width: 100%;
}
.job:hover { border-color: var(--brand); background: var(--surface-alt); }
.job.active { border-color: var(--brand); background: #f0f2ff; }

.job .meta { flex: 1; min-width: 0; }
.job .name {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.job .when { font-size: 0.75rem; color: var(--muted); }

.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot.queued { background: var(--faint); }
.dot.running { background: var(--warn); animation: pulse 1.2s infinite; }
.dot.done { background: var(--ok); }
.dot.error { background: var(--danger); }

@keyframes pulse { 50% { opacity: 0.35; } }

.empty { color: var(--faint); font-size: 0.85rem; text-align: center; padding: 24px 0; }

/* --- Resultado ------------------------------------------------------------ */

.result-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.result-head h2 { margin: 0; flex: 1; }

.output {
  width: 100%;
  min-height: 420px;
  padding: 18px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface-alt);
  font-family: 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.83rem;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-y: auto;
  resize: vertical;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 13px 16px;
  background: var(--surface-alt);
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 0.8rem;
}
.stats div { display: flex; flex-direction: column; }
.stats .k { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.stats .v { font-weight: 700; color: var(--ink); }

/* --- Avisos --------------------------------------------------------------- */

.alert {
  padding: 11px 14px;
  border-radius: 9px;
  font-size: 0.85rem;
  margin-bottom: 14px;
  border-left: 4px solid;
}
.alert.error { background: #fff5f5; border-color: var(--danger); color: #9b2c2c; }
.alert.info { background: #ebf8ff; border-color: #3182ce; color: #2c5282; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: white;
  padding: 13px 20px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 100;
  max-width: 380px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--ok); }

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .app { padding: 12px; }
  .card { padding: 18px; }
}
