/* ---------------------------------------------------------------------------
   Respuestas ricas del chat: tablas, graficas, exportar a PDF y dictado
   ---------------------------------------------------------------------------
   Va en su propia hoja para no crecer styles.css, que ya es enorme.
   --------------------------------------------------------------------------- */

.assistant-table-wrap {
  max-width: 100%;
  margin: 10px 0;
  overflow-x: auto;
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 8px;
  background: #ffffff;
}

.assistant-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.assistant-table th,
.assistant-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.assistant-table th {
  background: #f2fbf9;
  color: #0f766e;
  font-weight: 850;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.assistant-table tbody tr:last-child td {
  border-bottom: 0;
}

.assistant-table tbody tr:nth-child(even) td {
  background: #fbfdfe;
}

/* Numeros a la derecha: se comparan mucho mejor en columna. */
.assistant-table td:not(:first-child) {
  font-variant-numeric: tabular-nums;
}

.assistant-chart {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 8px;
  background: #ffffff;
}

.assistant-chart figcaption {
  margin-bottom: 10px;
  color: #0f172a;
  font-size: 12.5px;
  font-weight: 850;
}

.assistant-chart svg {
  width: 100%;
  height: auto;
}

.assistant-chart-bars {
  display: grid;
  gap: 7px;
}

.assistant-chart-bar {
  display: grid;
  grid-template-columns: minmax(64px, 132px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.assistant-chart-label {
  overflow: hidden;
  color: #475467;
  font-size: 11.5px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assistant-chart-track {
  height: 12px;
  border-radius: 999px;
  background: #eef4f6;
  overflow: hidden;
}

.assistant-chart-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 320ms ease;
}

.assistant-chart-value {
  color: #0f172a;
  font-size: 11.5px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.assistant-bubble-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.assistant-bubble-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 999px;
  background: #ffffff;
  color: #475467;
  font-size: 11.5px;
  font-weight: 850;
}

.assistant-bubble-action:hover:not(:disabled) {
  border-color: rgba(20, 184, 166, 0.45);
  background: #f0fdfa;
  color: #0f766e;
}

.assistant-bubble-action:disabled {
  opacity: 0.55;
}

#assistantDictateBtn.is-recording {
  border-color: rgba(194, 66, 47, 0.5);
  background: #fdecea;
  color: #c2422f;
  animation: assistant-dictate-pulse 1.1s infinite;
}

#assistantDictateBtn.is-busy {
  opacity: 0.6;
}

@keyframes assistant-dictate-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(194, 66, 47, 0.32); }
  50% { box-shadow: 0 0 0 6px rgba(194, 66, 47, 0); }
}

@media (max-width: 720px) and (pointer: coarse) {
  .assistant-table {
    font-size: 12px;
  }

  .assistant-chart-bar {
    grid-template-columns: minmax(56px, 96px) minmax(0, 1fr) auto;
    gap: 7px;
  }

  .assistant-chart-value,
  .assistant-chart-label {
    font-size: 11px;
  }

  .assistant-bubble-action {
    min-height: 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #assistantDictateBtn.is-recording {
    animation: none;
  }

  .assistant-chart-fill {
    transition: none;
  }
}

/* El aviso de avance junto al indicador de carga: el paso en grande y el
   detalle (el motivo de la consulta, cuantas filas) debajo, mas tenue. La columna
   la arma .ai-loader-body, asi que aqui solo va el tono del texto. */
.ai-loader-detail {
  color: #7a8798;
  font-size: 11.5px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

@media (max-width: 720px) and (pointer: coarse) {
  .ai-loader-detail {
    font-size: 11px;
  }

  .ai-loader-step {
    font-size: 11.5px;
  }
}

/* --- Barra de dictado ----------------------------------------------------
   Mientras grabas se ve que esta grabando, cuanto llevas, y las dos salidas:
   descartar o mandar a transcribir. */
.assistant-dictation {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 2px;
  padding: 8px 10px;
  border: 1px solid rgba(194, 66, 47, 0.28);
  border-radius: 10px;
  background: #fef6f4;
}

.assistant-dictation[data-mode="transcribing"] {
  border-color: rgba(20, 184, 166, 0.32);
  background: #f1fbf8;
}

.assistant-dictation-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #c2422f;
  animation: assistant-dictation-blink 1.1s infinite;
}

.assistant-dictation[data-mode="transcribing"] .assistant-dictation-dot {
  background: #0f766e;
}

.assistant-dictation-time {
  color: #0f172a;
  font-size: 13px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.assistant-dictation-wave {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 3px;
  height: 20px;
  overflow: hidden;
}

.assistant-dictation-wave i {
  width: 3px;
  height: 30%;
  border-radius: 999px;
  background: rgba(194, 66, 47, 0.55);
  animation: assistant-dictation-wave 1s infinite ease-in-out;
}

.assistant-dictation-wave i:nth-child(2) { animation-delay: 0.12s; }
.assistant-dictation-wave i:nth-child(3) { animation-delay: 0.24s; }
.assistant-dictation-wave i:nth-child(4) { animation-delay: 0.36s; }
.assistant-dictation-wave i:nth-child(5) { animation-delay: 0.18s; }
.assistant-dictation-wave i:nth-child(6) { animation-delay: 0.3s; }
.assistant-dictation-wave i:nth-child(7) { animation-delay: 0.06s; }

.assistant-dictation[data-mode="transcribing"] .assistant-dictation-wave i {
  background: rgba(15, 118, 110, 0.45);
}

.assistant-dictation-label {
  color: #7a4034;
  font-size: 11.5px;
  font-weight: 800;
  white-space: nowrap;
}

.assistant-dictation[data-mode="transcribing"] .assistant-dictation-label {
  color: #0f766e;
}

.assistant-dictation-cancel,
.assistant-dictation-stop {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 9px;
  background: #ffffff;
  color: #64748b;
  font-size: 14px;
}

.assistant-dictation-cancel:hover:not(:disabled) {
  border-color: rgba(194, 66, 47, 0.45);
  color: #c2422f;
}

.assistant-dictation-stop {
  border-color: #0f766e;
  background: #0f766e;
  color: #ffffff;
}

.assistant-dictation-stop:disabled,
.assistant-dictation-cancel:disabled {
  opacity: 0.5;
}

@keyframes assistant-dictation-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

@keyframes assistant-dictation-wave {
  0%, 100% { height: 30%; }
  50% { height: 100%; }
}

@media (max-width: 720px) and (pointer: coarse) {
  .assistant-dictation-label {
    display: none;
  }

  .assistant-dictation-cancel,
  .assistant-dictation-stop {
    width: 38px;
    height: 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .assistant-dictation-dot,
  .assistant-dictation-wave i {
    animation: none;
  }
}

/* --- Lienzo de la conversacion ---------------------------------------------
   Todo era blanco sobre blanco: las burbujas se disolvian en el fondo. Ahora
   el lienzo baja un tono (con un halo suave de la marca) y las burbujas van
   en blanco puro con sombra: se leen como tarjetas sobre una superficie, no
   como manchas del mismo color. */
.assistant-messages {
  background:
    radial-gradient(1100px 360px at 82% -10%, rgba(20, 184, 166, 0.10), transparent 68%),
    radial-gradient(900px 320px at 8% 104%, rgba(99, 102, 241, 0.07), transparent 70%),
    linear-gradient(180deg, rgba(236, 243, 246, 0.94) 0%, rgba(244, 249, 251, 0.96) 55%, rgba(240, 246, 249, 0.94) 100%);
  border-color: rgba(15, 118, 110, 0.14);
}

/* --- La respuesta ----------------------------------------------------------
   Tarjeta blanca con sombra suave y un filo de color a la izquierda, para que
   se distinga del lienzo y del mensaje propio de un vistazo. */
.assistant-bubble.assistant {
  margin-top: 6px;
  border: 1px solid rgba(15, 118, 110, 0.16) !important;
  border-left: 3px solid rgba(20, 184, 166, 0.85) !important;
  border-radius: 4px 14px 14px 14px;
  background: #ffffff !important;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.07);
}

.assistant-bubble.assistant::after {
  border-color: transparent;
}

/* --- Mensajes propios ------------------------------------------------------
   Contorno completo en el color de la marca: se ve el limite del mensaje sin
   necesidad de rellenarlo de color. */
.assistant-bubble.user {
  position: relative;
  align-self: flex-end;
  max-width: min(74%, 600px);
  margin-top: 20px;
  padding: 11px 15px;
  border: 1.5px solid rgba(13, 148, 136, 0.55);
  border-radius: 14px 14px 4px 14px;
  background: #f7fdfb;
  color: #123b46;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.10);
}

.assistant-bubble.user::before {
  content: "Tú";
  position: absolute;
  top: -15px;
  right: 4px;
  color: #79929c;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

html[lang="en"] .assistant-bubble.user::before { content: "You"; }
html[lang="zh"] .assistant-bubble.user::before { content: "你"; }

.assistant-bubble.user a {
  color: #0f766e;
}

.assistant-bubble.user .assistant-attachment-label,
.assistant-bubble.user .assistant-attachment-names {
  color: #5b7480;
}

/* La burbuja de carga tambien es tarjeta, para que el avance se lea igual. */
.assistant-bubble.is-loading {
  background: #ffffff !important;
}

@media (max-width: 720px) and (pointer: coarse) {
  .assistant-bubble.user {
    max-width: 86%;
    margin-top: 18px;
  }

  .assistant-messages {
    border-radius: 12px;
  }
}

/* --- Enviar / cancelar -----------------------------------------------------
   Mientras el chat responde, el boton de enviar se vuelve un stop: se puede
   seguir escribiendo, pero no encimar otra pregunta. */
.assistant-mobile-send.is-cancel {
  background: #c2422f !important;
  border-color: #c2422f !important;
  color: #ffffff !important;
  animation: assistant-cancel-pulse 1.6s ease-in-out infinite;
}

.assistant-mobile-send.is-cancel:hover {
  background: #a63524 !important;
  border-color: #a63524 !important;
}

.assistant-bubble.is-cancelled {
  border-style: dashed !important;
  color: #7a8798;
  font-style: italic;
}

@keyframes assistant-cancel-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(194, 66, 47, 0.34); }
  50% { box-shadow: 0 0 0 7px rgba(194, 66, 47, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .assistant-mobile-send.is-cancel {
    animation: none;
  }
}

/* --- Panel lateral de la IA ------------------------------------------------
   En el lateral no habia forma de empezar un chat nuevo: el boton estaba
   oculto. Se muestra compacto, del tamano de los otros iconos del encabezado.
   Y las sugerencias se quedan con un solo texto (antes salia el largo y el
   corto, que decian casi lo mismo). */
@media (min-width: 821px) {
  .workspace-slot[data-section="assistant"][data-slot="side"] .new-chat-button {
    display: inline-grid !important;
    place-items: center;
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    border-radius: 10px;
  }

  .workspace-slot[data-section="assistant"][data-slot="side"] .new-chat-button span {
    display: none !important;
  }

  .workspace-slot[data-section="assistant"][data-slot="side"] .new-chat-button svg {
    width: 17px;
    height: 17px;
  }

  .workspace-slot[data-section="assistant"][data-slot="side"] .assistant-suggestion-label-default {
    display: -webkit-box !important;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    min-width: 0;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.25;
    /* Dos renglones en vez de cortar con puntos suspensivos: el panel es
       angosto y "Buscar en m..." no dice nada. */
    white-space: normal;
    text-align: left;
  }
}

/* --- Bienvenida del panel lateral ------------------------------------------
   Con los atajos fuera, el bloque se centra y respira: saludo, una linea de
   apoyo y dos sugerencias. Nada mas. */
@media (min-width: 821px) {
  /* La bienvenida se pegaba arriba con un hueco enorme debajo. Se centra en el
     alto disponible y se le da ritmo: saludo, apoyo y accesos, con aire. */
  .workspace-slot[data-section="assistant"][data-slot="side"] .assistant-welcome {
    justify-content: center !important;
    gap: 0;
    padding: 24px 18px 32px !important;
  }

  .workspace-slot[data-section="assistant"][data-slot="side"] .assistant-welcome-kicker {
    margin: 0 0 10px !important;
    font-size: 10.5px;
    letter-spacing: 0.14em;
  }

  .workspace-slot[data-section="assistant"][data-slot="side"] .assistant-welcome-title {
    margin: 0;
    font-size: 21px;
    line-height: 1.24;
    letter-spacing: -0.015em;
  }

  .workspace-slot[data-section="assistant"][data-slot="side"] .assistant-side-welcome-text {
    margin: 8px 0 0;
    max-width: 260px;
    color: #6b7c8c;
    font-size: 12.5px;
    line-height: 1.5;
  }

  /* Dos sugerencias, una debajo de otra y a todo lo ancho: en el panel angosto
     leerlas completas vale mas que ponerlas en fila y cortarlas. */
  .workspace-slot[data-section="assistant"][data-slot="side"] .assistant-welcome-suggestions--desktop {
    /* La hoja de paneles la fija en dos columnas; aqui se pasa a una sola. */
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 8px;
    width: 100%;
    max-width: 300px;
    margin: 22px auto 0;
  }

  .workspace-slot[data-section="assistant"][data-slot="side"] .assistant-welcome-suggestions--desktop button {
    width: 100%;
    justify-content: flex-start;
    padding: 10px 12px;
  }

  /* A todo lo ancho ya no hace falta recortar: el texto entra en un renglon. */
  .workspace-slot[data-section="assistant"][data-slot="side"] .assistant-suggestion-label-default {
    display: block !important;
    overflow: visible;
    white-space: normal;
    text-overflow: clip;
  }

  .workspace-slot[data-section="assistant"][data-slot="side"] .assistant-welcome-suggestions--desktop button {
    border-color: rgba(15, 118, 110, 0.22);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
  }

  .workspace-slot[data-section="assistant"][data-slot="side"] .assistant-welcome-suggestions--desktop button:hover {
    border-color: rgba(15, 118, 110, 0.45);
    background: #ffffff;
  }
}
