/* ============================================================
   AVATIA — Panel de Vendedores
   Tokens de marca extraídos de avatia.app (ver spec técnico sección 2).
   Un único acento dorado. Verde SOLO para dinero cobrado / estados positivos.
   JetBrains Mono es una decisión práctica interna para alinear datos
   tabulares (teléfonos, montos, IDs) — no es parte de la marca pública.
   ============================================================ */

/* Auditoría B-10: antes esto era un @import de Google Fonts — una petición
   externa en CADA carga de página, y el panel se veía degradado sin salida
   a internet. Ahora los .woff2 viven en assets/fonts/ (subset "latin" nada
   más — cubre todo el español, incluyendo ñ/á/é/í/ó/ú/ü — así que pesan
   poco: los 10 archivos entre los 3 tipos suman ~200KB en total). */
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/cormorant-garamond-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/assets/fonts/cormorant-garamond-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/assets/fonts/cormorant-garamond-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/manrope-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/manrope-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/assets/fonts/manrope-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/assets/fonts/manrope-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('/assets/fonts/manrope-latin-800-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/jetbrains-mono-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/jetbrains-mono-latin-500-normal.woff2') format('woff2');
}

:root {
  --gold: #C9A84C;
  --gold-light: #E5C46F;
  --gold-dark: #8a6c28;
  --gold-soft: rgba(201, 168, 76, 0.18);

  --bg: #0a0a0a;
  --bg-card: #111111;
  --bg-card-2: #161616;

  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.12);

  --text: #f5f5f5;
  --text-soft: rgba(245, 245, 245, 0.62);
  --text-dim: rgba(245, 245, 245, 0.38);

  --green: #4ade80;
  --red: #e5484d;

  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Manrope', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

body { min-height: 100vh; }

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

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  color: var(--text);
  margin: 0 0 .4em;
  letter-spacing: 0.01em;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; color: var(--text-soft); font-weight: 600; }

.cifra { font-family: var(--serif); font-weight: 700; font-size: 2.2rem; color: var(--gold-light); }

.mono { font-family: var(--mono); font-size: 0.92em; letter-spacing: -0.01em; }

p { color: var(--text-soft); }

/* ---- Layout ---- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar .marca {
  font-family: var(--serif);
  font-size: 1.35rem;
  color: var(--gold-light);
  margin-bottom: 28px;
  padding: 0 8px;
}
.sidebar .marca span { color: var(--text-dim); font-size: 0.6em; display: block; font-family: var(--sans); letter-spacing: 0.08em; text-transform: uppercase; }

.sidebar a {
  color: var(--text-soft);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 500;
}
.sidebar a:hover { background: var(--bg-card-2); text-decoration: none; color: var(--text); }
.sidebar a.activa { background: var(--gold-soft); color: var(--gold-light); }

.sidebar .separador { border-top: 1px solid var(--line); margin: 14px 8px; }

.sidebar .usuario-actual {
  margin-top: auto;
  padding: 12px 8px 0;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--text-dim);
}
.sidebar .usuario-actual strong { color: var(--text-soft); display: block; }

.contenido { flex: 1; padding: 32px 40px; max-width: 1200px; }

@media (max-width: 800px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; padding: 12px; align-items: center; }
  .sidebar .marca { margin-bottom: 0; margin-right: 12px; }
  .sidebar .usuario-actual { display: none; }
  .contenido { padding: 20px; }
}

/* ---- Componentes ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

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

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.stat-card { text-align: left; }
.stat-card .etiqueta { color: var(--text-dim); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-2);
}
tbody td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: var(--bg-card-2); }
tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--bg-card-2);
  color: var(--text-soft);
  border: 1px solid var(--line-2);
  white-space: nowrap;
}
.badge-gold { background: var(--gold-soft); color: var(--gold-light); border-color: transparent; }
.badge-green { background: rgba(74, 222, 128, 0.14); color: var(--green); border-color: transparent; }
.badge-red { background: rgba(229, 72, 77, 0.14); color: var(--red); border-color: transparent; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--bg-card-2);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #1c1c1c; text-decoration: none; }
.btn-oro { background: var(--gold); border-color: var(--gold); color: #1a1400; }
.btn-oro:hover { background: var(--gold-light); }
.btn-peligro { border-color: rgba(229, 72, 77, 0.4); color: var(--red); background: transparent; }
.btn-peligro:hover { background: rgba(229, 72, 77, 0.1); }
.btn-verde { border-color: rgba(74,222,128,0.4); color: var(--green); background: transparent; }
.btn-verde:hover { background: rgba(74,222,128,0.1); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

label { display: block; font-size: 0.82rem; color: var(--text-soft); margin-bottom: 6px; font-weight: 500; }

input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=number], input[type=date], input[type=datetime-local],
select, textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-card-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.92rem;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--gold-dark);
  outline-offset: 1px;
  border-color: var(--gold);
}
textarea { resize: vertical; min-height: 90px; }

.campo { margin-bottom: 16px; }

.alerta {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alerta-error { background: rgba(229, 72, 77, 0.1); border-color: rgba(229, 72, 77, 0.3); color: #ff9a9d; }
.alerta-exito { background: rgba(74, 222, 128, 0.1); border-color: rgba(74, 222, 128, 0.3); color: var(--green); }
.alerta-info { background: var(--gold-soft); border-color: rgba(201,168,76,0.3); color: var(--gold-light); }

.vacio { color: var(--text-dim); text-align: center; padding: 40px 20px; font-size: 0.92rem; }

.paginacion { display: flex; gap: 6px; margin-top: 20px; align-items: center; flex-wrap: wrap; }
.paginacion .info { color: var(--text-dim); font-size: 0.82rem; margin-right: 8px; }

.filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 20px; }
.filtros .campo { margin-bottom: 0; min-width: 160px; }

.pipeline-columnas { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.pipeline-col { min-width: 240px; flex-shrink: 0; }
.pipeline-col h3 { display: flex; justify-content: space-between; align-items: center; }
.pipeline-col .contador { font-family: var(--mono); color: var(--text-dim); font-size: 0.8rem; }
.pipeline-lead {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 0.85rem;
}
.pipeline-lead .nombre { font-weight: 600; display: block; margin-bottom: 2px; }
.pipeline-lead .meta { color: var(--text-dim); font-size: 0.78rem; }

/* Widget de login */
.pantalla-centrada {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.panel-login {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 36px 32px;
}
.panel-login .marca {
  text-align: center;
  font-family: var(--serif);
  font-size: 1.7rem;
  color: var(--gold-light);
  margin-bottom: 4px;
}
.panel-login .subtitulo {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.82rem;
  margin-bottom: 28px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Copiar borrador IA */
.caja-ia {
  background: var(--bg-card-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.caja-ia textarea { background: var(--bg); }
.caja-ia .acciones { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

::selection { background: var(--gold-soft); color: var(--text); }

/* Auditoría ronda 3, N-2 (residual): página de error fatal de Logger.php —
 * se genera fuera del pipeline normal (puede dispararse incluso si algo más
 * está roto), así que no puede depender de clases condicionales, pero SÍ
 * puede enlazar este mismo archivo estático. Antes tenía 3 atributos
 * style="" inline que la CSP estricta (style-src 'self', sin
 * 'unsafe-inline') descartaba. */
.error-fatal-body {
  background: #0a0a0a;
  color: #f5f5f5;
  font-family: sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  margin: 0;
}
.text-dim { color: var(--text-dim); }
.error-fatal-caja { text-align: center; }
.error-fatal-titulo { color: #C9A84C; }
.text-soft { color: var(--text-soft); }
.text-verde { color: var(--green); }
.text-rojo { color: var(--red); }
.mt-0 { margin-top: 0; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-entre { display: flex; justify-content: space-between; align-items: center; }
.mb-20 { margin-bottom: 20px; }

/* ---------------------------------------------------------------------
 * Auditoría ronda 2, N-2: la CSP fija `style-src 'self'` (sin
 * 'unsafe-inline') porque ya no queda ningún <script> ni handler inline
 * en ninguna vista — pero 43 atributos style="" repartidos en 16 archivos
 * seguían ahí, y el navegador los descarta igual que un script inline.
 * Estas clases replican EXACTAMENTE los mismos valores que tenían esos
 * atributos — no es un rediseño, es moverlos a una hoja de estilos propia
 * para que la CSP pueda quedarse estricta.
 * --------------------------------------------------------------------- */
.text-centro { text-align: center; }
.no-decoration { text-decoration: none; }
.flex-1 { flex: 1; }
.gap-6 { gap: 6px; }
.min-w-140 { min-width: 140px; }
.inline-form { display: inline; }
.inline-block { display: inline-block; }
.checkbox-inline { width: auto; display: inline-block; margin-right: 6px; }
.w-full-center { width: 100%; justify-content: center; }

.mt-6  { margin-top: 6px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }

.fs-74  { font-size: 0.74rem; }
.fs-76  { font-size: 0.76rem; }
.fs-78  { font-size: 0.78rem; }
.fs-80  { font-size: 0.8rem; }
.fs-82  { font-size: 0.82rem; }
.fs-85  { font-size: 0.85rem; }
.fs-130 { font-size: 1.3rem; }

.titulo-403 { font-size: 1.3rem; }

/* Bloque de secreto/URL otpauth en admin/activar-2fa.php */
.caja-secreto {
  word-break: break-all;
  background: var(--bg-card-2);
  padding: 10px;
  border-radius: 6px;
}

/* Contraseña temporal generada al crear un usuario, admin/usuarios.php */
.destacado-mono {
  font-size: 1.1rem;
  margin-top: 6px;
  background: var(--bg-card-2);
  padding: 8px 12px;
  border-radius: 6px;
  display: inline-block;
}

/* Contador de "seguimientos vencidos" en vendedor/dashboard.php — antes era
 * un style="color:..." dinámico calculado en PHP; ahora es una clase
 * condicional, así el color sigue siendo dinámico sin salirse de la CSP. */
.cifra-alerta { color: var(--red); }
.cifra-ok { color: var(--green); }


/* ============================================================
   Añadido 2026-09-01 — copiloto flotante, bitácora, esperas
   ============================================================ */

/* ---- Utilidades que faltaban ---- */
.flex-wrap { flex-wrap: wrap; }

/* ---- Indicador de espera -------------------------------------------------
   Las llamadas al modelo tardaron hasta 17 segundos en producción. Un botón
   deshabilitado y nada más parece un cuelgue: el vendedor vuelve a apretar y
   se paga otra llamada. */
.cargando {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-soft);
  font-size: 0.88rem;
  padding: 12px 14px;
  background: var(--bg-card-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.puntos { display: inline-flex; gap: 4px; align-items: center; }
.puntos i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  display: inline-block;
  animation: latido 1.2s infinite ease-in-out;
}
.puntos i:nth-child(2) { animation-delay: 0.18s; }
.puntos i:nth-child(3) { animation-delay: 0.36s; }

@keyframes latido {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40%           { opacity: 1;    transform: translateY(-3px); }
}

/* Respeta a quien pidió menos animación en su sistema. */
@media (prefers-reduced-motion: reduce) {
  .puntos i { animation: none; opacity: 0.7; }
}

/* ---- Bitácora del lead ---- */
.bitacora { list-style: none; padding: 0; margin: 0; }
.bitacora li {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
.bitacora li:last-child { border-bottom: 0; }
.bitacora li > div { margin-top: 4px; color: var(--text-soft); }

/* ---- Chips (sugerencias del copiloto y adjuntos) ---- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card-2);
  border: 1px solid var(--line-2);
  color: var(--text-soft);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-family: var(--sans);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.chip:hover { border-color: var(--gold); color: var(--gold-light); }
.chip-quitar {
  background: none;
  border: 0;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0 0 0 2px;
  line-height: 1;
}
.chip-quitar:hover { color: var(--red); }

/* ---- Botón flotante ------------------------------------------------------
   Abajo a la derecha, por encima de todo. z-index alto pero no absurdo: nada
   más en el panel usa capas. */
.agente-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 20px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  background: var(--gold);
  color: #1a1400;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  transition: transform .15s, box-shadow .15s;
}
.agente-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(0,0,0,.55); }
.agente-fab-icono { font-size: 1rem; }

/* ---- Panel del copiloto ---- */
.agente-panel {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 61;
  width: 420px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 44px);
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.agente-panel[hidden] { display: none; }

.agente-cabecera {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-card-2);
  flex-shrink: 0;
}

.agente-mensajes {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.agente-msg {
  font-size: 0.88rem;
  line-height: 1.55;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  max-width: 92%;
}
.agente-msg p { margin: 0 0 8px; }
.agente-msg p:last-child { margin-bottom: 0; }

.agente-msg-bot {
  background: var(--bg-card-2);
  border: 1px solid var(--line);
  color: var(--text);
  align-self: flex-start;
}
.agente-msg-yo {
  background: var(--gold-soft);
  border: 1px solid rgba(201, 168, 76, 0.28);
  color: var(--text);
  align-self: flex-end;
}
.agente-pensando { display: flex; align-items: center; gap: 8px; color: var(--text-soft); }

.agente-sugerencias {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

.agente-borrador {
  width: 100%;
  margin-top: 6px;
  background: var(--bg);
  font-size: 0.85rem;
}

/* Caja del mini-análisis generado */
.agente-analisis {
  border: 1px solid rgba(201, 168, 76, 0.3);
  background: var(--gold-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.agente-analisis-titulo {
  font-weight: 600;
  color: var(--gold-light);
  margin-bottom: 4px;
}

.agente-adjuntos {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px 0;
  flex-shrink: 0;
}

.agente-form {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--line);
  background: var(--bg-card-2);
  flex-shrink: 0;
}
.agente-fila {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.agente-fila textarea {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 140px;
  margin: 0;
  font-size: 0.88rem;
}
.agente-fila label.btn { cursor: pointer; flex-shrink: 0; }
.agente-fila button { flex-shrink: 0; }

/* En móvil el panel ocupa la pantalla: un cuadro de 420px flotando en un
   teléfono no se puede usar. */
@media (max-width: 520px) {
  .agente-panel {
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }
  .agente-fab { right: 16px; bottom: 16px; }
  .agente-fab-texto { display: none; }
}
