/* Nexus Council — estilos. Oscuro, sobrio, alto contraste. Sin emojis en la UI. */

:root {
  --bg: #0e0e13;
  --bg-elev: #16161d;
  --bg-elev2: #1c1c26;
  --border: #262631;
  --text: #f3f3f6;
  --text-dim: #9a9aa8;
  --text-faint: #6a6a78;
  --accent-tunix: #E8C56B;
  --accent-gemini: #2DC6EA;
  --accent-deepseek: #8B7CF6;
  --accent-humano: #4ADE80;
  --danger: #f26161;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  height: 100%;
  overflow: hidden;
}

body { display: flex; flex-direction: column; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
}
button:disabled { cursor: not-allowed; opacity: 0.45; }

input, textarea {
  font-family: inherit;
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
}
input:focus, textarea:focus { border-color: var(--accent-gemini); }

/* ── Login ── */
#pantalla-login {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-top: calc(24px + var(--safe-top));
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
}
.login-card h1 {
  font-size: 20px;
  margin: 0 0 6px;
  letter-spacing: 0.02em;
}
.login-card p.sub {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 22px;
}
.login-card input {
  width: 100%;
  margin-bottom: 12px;
  font-size: 15px;
}
.btn-primario {
  width: 100%;
  background: linear-gradient(135deg, var(--accent-gemini), var(--accent-deepseek));
  color: #0a0a0c;
  font-weight: 600;
  padding: 11px;
  border-radius: 8px;
  font-size: 14px;
}
.login-msg {
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-dim);
  min-height: 18px;
}
.login-msg.error { color: var(--danger); }
.login-msg.ok { color: var(--accent-humano); }

/* ── App shell ── */
#app {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}
#app.on { display: flex; }

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  padding-top: calc(14px + var(--safe-top));
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  flex-shrink: 0;
}
header.topbar .marca {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
header.topbar .marca .punto {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-gemini);
}
header.topbar button.icon-btn {
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  padding: 6px 10px;
}
header.topbar button.icon-btn:hover { color: var(--text); }

main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Vista lista ── */
#vista-lista { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.lista-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px 10px;
}
.lista-header h2 { margin: 0; font-size: 16px; }
.lista-scroll { flex: 1; overflow-y: auto; padding: 4px 18px 24px; }

.debate-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.debate-card:hover { border-color: var(--accent-gemini); }
.debate-card .fila1 {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.debate-card .tema { font-size: 14px; font-weight: 600; line-height: 1.35; }
.debate-card .meta {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim);
  flex-wrap: wrap;
}
.badge-estado {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
  font-weight: 600;
}
.badge-estado.abierto { background: #2a2a1c; color: #e8c56b; }
.badge-estado.en_ronda { background: #1c2a2a; color: var(--accent-gemini); }
.badge-estado.cerrado { background: #1c2a1e; color: var(--accent-humano); }

.vacio {
  text-align: center;
  color: var(--text-faint);
  padding: 60px 20px;
  font-size: 14px;
}

.fab {
  position: fixed;
  right: 20px;
  bottom: calc(20px + var(--safe-bottom));
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-gemini), var(--accent-deepseek));
  color: #0a0a0c;
  font-size: 26px;
  font-weight: 300;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

/* ── Modal nuevo debate ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 50;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.on { display: flex; }
.modal-card {
  width: 100%;
  max-width: 480px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 20px 20px calc(20px + var(--safe-bottom));
  max-height: 88vh;
  overflow-y: auto;
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal-card { border-radius: var(--radius); max-height: 80vh; }
}
.modal-card h3 { margin: 0 0 16px; font-size: 16px; }
.campo { margin-bottom: 14px; }
.campo label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.campo input, .campo textarea { width: 100%; }
.campo textarea { min-height: 100px; resize: vertical; }
.checks { display: flex; gap: 14px; }
.check-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px;
  background: var(--bg-elev2);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.modal-acciones {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.btn-secundario {
  flex: 1;
  background: var(--bg-elev2);
  color: var(--text-dim);
  padding: 11px;
  border-radius: 8px;
  font-size: 14px;
}
.modal-acciones .btn-primario { flex: 2; }

/* ── Vista sala ── */
#vista-sala { flex: 1; min-height: 0; display: none; flex-direction: column; }
#vista-sala.on { display: flex; }

.sala-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  flex-shrink: 0;
}
.sala-header .volver {
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  padding: 0 0 8px;
}
.sala-header h2 {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.35;
}
.sala-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-dim);
  align-items: center;
}
.freno-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  background: #2a1c1c;
  color: var(--danger);
}

.transcript {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.turno {
  border-radius: var(--radius);
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  max-width: 92%;
}
.turno.actor-tunix { border-left: 3px solid var(--accent-tunix); align-self: stretch; max-width: 100%; }
.turno.actor-gemini { border-left: 3px solid var(--accent-gemini); align-self: flex-start; }
.turno.actor-deepseek { border-left: 3px solid var(--accent-deepseek); align-self: flex-end; }
.turno.actor-patricio { border-left: 3px solid var(--accent-humano); align-self: stretch; background: var(--bg-elev2); }
.turno.con-error { border-left-color: var(--danger); }

.turno-cab {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 8px;
}
.turno-actor {
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.turno-actor .dot { width: 7px; height: 7px; border-radius: 50%; }
.dot.tunix { background: var(--accent-tunix); }
.dot.gemini { background: var(--accent-gemini); }
.dot.deepseek { background: var(--accent-deepseek); }
.dot.patricio { background: var(--accent-humano); }

.turno-info {
  font-size: 10.5px;
  color: var(--text-faint);
  white-space: nowrap;
}
.turno-cuerpo {
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  color: var(--text);
}
.turno-error {
  font-size: 12.5px;
  color: var(--danger);
  margin-top: 6px;
}

.conclusion-block {
  border: 1px solid var(--accent-tunix);
  background: #1c1808;
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 4px;
}
.conclusion-block h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--accent-tunix);
}
.conclusion-block .cuerpo {
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.indicador-debatiendo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-dim);
  padding: 8px 14px;
  align-self: center;
}
.indicador-debatiendo .spin {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent-gemini);
  animation: girar 0.8s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

/* ── Controles de la sala (fijos abajo) ── */
.controles {
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 12px 14px calc(12px + var(--safe-bottom));
  flex-shrink: 0;
}
.controles-fila {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.controles-fila:last-child { margin-bottom: 0; }
.btn-control {
  flex: 1;
  min-width: 90px;
  background: var(--bg-elev2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
}
.btn-control.principal {
  background: linear-gradient(135deg, var(--accent-gemini), var(--accent-deepseek));
  color: #0a0a0c;
  flex: 2;
}
.btn-control.peligro {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
  flex: 1;
}
.fila-humano {
  display: flex;
  gap: 8px;
}
.fila-humano input { flex: 1; font-size: 13px; }
.fila-humano button {
  background: var(--accent-humano);
  color: #0a0a0c;
  padding: 0 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}

.toast {
  position: fixed;
  bottom: calc(90px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 30px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 100;
  max-width: 88vw;
  text-align: center;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 480px) {
  .turno.actor-gemini, .turno.actor-deepseek { max-width: 96%; }
}
