/* ── Reset y base ─────────────────────────────────────────────────────────── */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: #1f2937;
  background: #f0f2f5;
  min-height: 100vh;
}

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

.app-header {
  background: #1e3a5f;
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-header h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.app-header .subtitulo {
  font-size: 12px;
  color: #93c5fd;
  margin-left: auto;
}

.app-body {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  padding: 16px;
  max-width: 1100px;
  margin: 0 auto;
}

/* ── Panel genérico ───────────────────────────────────────────────────────── */

.panel {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
}

.panel + .panel {
  margin-top: 12px;
}

.panel-titulo {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #64748b;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f1f5f9;
}

/* ── Estado del backend ───────────────────────────────────────────────────── */

.estado-fila {
  display: flex;
  align-items: center;
  gap: 8px;
}

.estado-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d1d5db;
  flex-shrink: 0;
  transition: background 0.3s;
}

.estado-dot.ok       { background: #22c55e; box-shadow: 0 0 0 3px #dcfce7; }
.estado-dot.error    { background: #ef4444; box-shadow: 0 0 0 3px #fee2e2; }
.estado-dot.cargando { background: #f59e0b; box-shadow: 0 0 0 3px #fef3c7; }

.estado-texto {
  font-size: 13px;
  color: #374151;
}

.btn-refrescar {
  margin-left: auto;
  font-size: 12px;
  color: #2563eb;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.btn-refrescar:hover { background: #eff6ff; }

/* ── Formulario upload ────────────────────────────────────────────────────── */

.upload-area {
  border: 2px dashed #cbd5e1;
  border-radius: 6px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 10px;
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: #2563eb;
  background: #eff6ff;
}

.upload-area input[type="file"] {
  display: none;
}

.upload-area .icono {
  font-size: 28px;
  margin-bottom: 6px;
}

.upload-area .label-upload {
  font-size: 13px;
  color: #475569;
}

.upload-area .label-upload span {
  color: #2563eb;
  font-weight: 600;
}

.upload-area .archivo-seleccionado {
  font-size: 12px;
  color: #1f2937;
  margin-top: 6px;
  font-weight: 500;
  word-break: break-all;
}

/* ── Botones ──────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  width: 100%;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primario {
  background: #2563eb;
  color: #fff;
}

.btn-primario:hover:not(:disabled) { background: #1d4ed8; }

.btn-peligro {
  background: #fff;
  color: #dc2626;
  border: 1px solid #fca5a5;
}

.btn-peligro:hover:not(:disabled) { background: #fef2f2; }

.btn-secundario {
  background: #f1f5f9;
  color: #374151;
}

.btn-secundario:hover:not(:disabled) { background: #e2e8f0; }

/* ── Mensajes ─────────────────────────────────────────────────────────────── */

.mensaje {
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 5px;
  margin-top: 8px;
  line-height: 1.5;
}

.mensaje.exito  { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.mensaje.error  { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.mensaje.info   { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.mensaje.aviso  { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }

/* ── Lista de documentos ──────────────────────────────────────────────────── */

.lista-docs {
  list-style: none;
  margin-bottom: 12px;
}

.lista-docs li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
}

.lista-docs li:last-child { border-bottom: none; }

.doc-icono { font-size: 16px; flex-shrink: 0; }

.doc-nombre {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #1f2937;
}

.doc-chips {
  font-size: 11px;
  color: #64748b;
  background: #f1f5f9;
  padding: 2px 7px;
  border-radius: 12px;
  flex-shrink: 0;
}

.docs-vacio {
  font-size: 13px;
  color: #94a3b8;
  text-align: center;
  padding: 12px 0;
}

/* Botón de borrado individual por documento */
.btn-doc-borrar {
  background: none;
  border: none;
  color: #cbd5e1;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.btn-doc-borrar:hover {
  color: #dc2626;
  background: #fef2f2;
}

/* ── Columna derecha: consulta ────────────────────────────────────────────── */

.columna-derecha {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pregunta-textarea {
  width: 100%;
  min-height: 90px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: #1f2937;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  resize: vertical;
  transition: border-color 0.2s;
  outline: none;
  margin-bottom: 10px;
}

.pregunta-textarea:focus { border-color: #2563eb; }

/* ── Bloque de respuesta ──────────────────────────────────────────────────── */

.respuesta-bloque {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 14px;
  min-height: 80px;
  font-size: 14px;
  line-height: 1.7;
  color: #1f2937;
  white-space: pre-wrap;
  word-break: break-word;
}

.respuesta-placeholder {
  color: #94a3b8;
  font-style: italic;
}

.respuesta-meta {
  margin-top: 8px;
  font-size: 12px;
  color: #64748b;
  display: flex;
  gap: 16px;
}

.respuesta-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Spinner (loading) ────────────────────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.spinner.oscuro {
  border-color: rgba(37,99,235,0.2);
  border-top-color: #2563eb;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Separador visual ─────────────────────────────────────────────────────── */

hr.sep {
  border: none;
  border-top: 1px solid #f1f5f9;
  margin: 12px 0;
}

/* ── Responsive básico ────────────────────────────────────────────────────── */

@media (max-width: 700px) {
  .app-body {
    grid-template-columns: 1fr;
  }
}
