/* Panel de sugerencias · pasos de la IA y filas de cambio.
   Troceado de `original_suggestions.css` (lote C3). Carga en `head_extra` de
   editor/editor.html y api_tester/analytics.html, detrás de los módulos 02-editor-* y
   ANTES del núcleo: ante una regla del núcleo con la misma especificidad,
   pierde. El orden entre módulos lo fija tests/css_manifest.py. */
/* ── Pasos de la IA ────────────────────────────────────────────────────────
   Rediseño de la clarificación, N2 (`editor/ai_steps.js`). La portada del
   subnivel de IA del carril: un paso por fragmento del texto, con su estado en
   palabras y una sola acción. Un color de acción (RD18): los botones son azules;
   el índigo solo marca «esto es IA» y aquí solo lo lleva el paso en marcha. No
   depende de `.sg-panel`: el contenedor lo pone quien aloja la lista. */
.ai-steps {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  color: var(--text-main, #0f172a);
  font-size: 12.5px;
  line-height: 1.45;
}
.ai-steps-intro { margin: 0; color: #475569; }
.ai-steps-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ai-step {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
}
.ai-step-name { font: 600 13px/1.35 var(--font-heading, inherit); color: var(--text-main); overflow-wrap: anywhere; }
.ai-step-name:focus { outline: none; }
/* El nombre recibe el foco al volver de un paso sin acción en su fila (N3). */
.ai-step-name:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: 4px; }
.ai-step-sub { grid-column: 1; color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.ai-step-act { grid-row: 1 / span 2; grid-column: 2; }
/* El estado no depende solo del color: lo dice el texto de la fila. */
.ai-step.is-applied { background: #fbfdfc; border-color: #d5ecdf; }
.ai-step.is-working .ai-step-sub { color: var(--ai, #4338ca); }
.ai-step.is-fold { background: var(--bg-app); border-style: dashed; }
.ai-step-bar {
  grid-column: 1 / -1;
  height: 4px;
  margin-top: 4px;
  overflow: hidden;
  background: #e0e7f1;
  border-radius: 9px;
}
/* Sin avance por lote: una barra que va y viene dice «en marcha» sin inventar
   una cifra. Con movimiento reducido, quieta a media barra. */
.ai-step-bar i {
  display: block;
  width: 40%;
  height: 100%;
  background: var(--brand);
  border-radius: inherit;
  animation: ai-step-working 1.4s ease-in-out infinite alternate;
}
@keyframes ai-step-working {
  from { transform: translateX(-10%); }
  to { transform: translateX(160%); }
}
.ai-step-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  color: #334155;
  background: var(--bg-card);
  border: 1px solid #cfd9e6;
  border-radius: 9px;
  font: 650 12px var(--font-heading, inherit);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.ai-step-btn:hover:not(:disabled) { background: #f1f5f9; border-color: #94a3b8; }
.ai-step-btn.is-primary { color: var(--text-inverse); background: var(--brand); border-color: var(--brand); box-shadow: 0 3px 9px rgba(0, 111, 192, 0.22); }
.ai-step-btn.is-primary:hover:not(:disabled) { background: var(--brand-dark); border-color: var(--brand-dark); }
.ai-step-btn.is-ghost { color: #475569; background: transparent; border-color: transparent; }
.ai-step-btn.is-ghost:hover:not(:disabled) { background: #f1f5f9; border-color: transparent; }
.ai-step-btn.is-danger { color: #b91c1c; }
.ai-step-btn.is-danger:hover:not(:disabled) { background: #fdeeee; }
.ai-step-btn.is-danger.is-confirming { color: var(--text-inverse); background: #b42318; border-color: #912018; }
.ai-step-btn:disabled { cursor: not-allowed; opacity: 0.55; }
.ai-step-btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.ai-steps-rest { width: 100%; min-height: 36px; }
.ai-steps-error { margin: 0; color: #b42318; }
.ai-steps-error[hidden] { display: none; }
.ai-steps-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; padding-top: 4px; }
/* El paso abierto (N3, `renderStep`): cabecera con ‹ rótulo › e «Índice», el
   texto del fragmento, los cambios con casilla, lo plegado y el pie. */
.ai-step-view {
  display: grid;
  gap: 10px;
  padding: 10px 14px 14px;
  color: var(--text-main, #0f172a);
  font-size: 12.5px;
  line-height: 1.45;
}
.ai-step-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eef2f7;
}
.ai-step-title {
  margin: 0;
  text-align: center;
  font: 600 13.5px/1.3 var(--font-heading, inherit);
  color: var(--text-main);
  overflow-wrap: anywhere;
}
.ai-step-title small { display: block; margin-top: 1px; color: var(--text-muted); font: 500 11.5px/1.3 var(--font-body, inherit); }
.ai-step-title:focus { outline: none; }
.ai-step-title:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: 4px; }
.ai-step-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  color: #334155;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.ai-step-arrow:hover:not(:disabled) { background: #f1f5f9; }
.ai-step-arrow:disabled { color: #cbd5e1; cursor: default; }
.ai-step-arrow:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.ai-step-text {
  max-height: 11em;
  overflow: auto;
  padding: 8px 10px;
  color: #334155;
  background: var(--bg-app);
  border: 1px solid #eef2f7;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.55;
}
.ai-step-text p { margin: 0; }
.ai-step-text p + p { margin-top: 0.5em; }
/* El párrafo compuesto (N4): lo que se quita, tachado; lo que se escribe,
   subrayado. Se lee sin color y los dos tonos pasan AA sobre su fondo. */
.ai-compose-change { border-radius: 3px; transition: box-shadow 0.12s ease, background-color 0.12s ease; }
.ai-compose-del,
.ai-compose-ins { padding: 0 2px; border-radius: 3px; }
.ai-compose-del { color: #9b1c1c; background: #fdecec; text-decoration: line-through; text-decoration-thickness: 1.5px; }
.ai-compose-ins { color: #05603a; background: #e3f7ec; text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
.ai-compose-change.is-lit { background: #e3effa; box-shadow: 0 0 0 2px var(--brand); }
.change-row.is-lit { border-color: var(--brand); }
/* Lo que aborda cada cambio, bajo su nombre, con el punto de su nivel (D5): la
   reescritura, todas las recomendaciones de su oración; una ficha, lo que cubre
   además de la suya. */
.change-row-resolves {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 10px;
  margin: 0;
  color: #334155;
  font: 500 11px/1.35 var(--font-body, inherit);
}
.change-row-resolve { display: inline-flex; align-items: center; gap: 5px; }
.ai-step-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-muted);
  font: 650 11px/1.4 var(--font-heading, inherit);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.ai-step-note { margin: 0; color: var(--text-muted); }
.ai-step-fold { color: #475569; }
.ai-step-fold summary { cursor: pointer; padding: 2px 0; }
.ai-step-fold summary:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: 4px; }
.ai-step-fold ul { display: grid; gap: 6px; margin: 6px 0 0; padding: 0 0 0 16px; list-style: none; }
.ai-step-fold-item { display: flex; align-items: baseline; gap: 6px; }
.ai-step-fold-item .layer-dot { flex: 0 0 auto; transform: translateY(-1px); }
.ai-step-fold-why { display: block; color: var(--text-muted); }
/* El pie queda a la vista al desplazar las filas (N7): pegado al fondo del
   carril, con su fondo para que lo de debajo no se lea a través. */
.ai-step-foot {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 -14px -14px;
  padding: 8px 14px 12px;
  background: var(--bg-card);
  border-top: 1px solid #eef2f7;
}
/* El botón que pliega el párrafo compuesto solo existe a 400 px (abajo). */
.ai-step-text-toggle { display: none; }
.ai-step-foot-gap { flex: 1 1 auto; }
.ai-step-empty {
  display: grid;
  gap: 6px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px dashed #cfd9e6;
  border-radius: 10px;
}
.ai-step-empty.is-end { border-style: solid; border-color: #bfe6d2; background: #f6fbf8; }
.ai-step-empty-acts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.ai-step-empty .ai-step-bar { grid-column: auto; }

/* Fila de cambio (N3, `ArTextChangeCard.renderRow`): la propuesta en la lista
   de cambios de un paso. Casilla, punto de nivel y recomendación, antes →
   después y un botón para desplegar. Aplicada, la casilla deja sitio a la
   palabra «Modificado» (el estado no depende solo del color). */
.change-rows { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.change-row {
  --card-line: #cfd9e6;
  --card-accent: #006fc0;
  --card-ink: #334155;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
}
.change-row.is-checked { border-color: #9cc7e8; box-shadow: inset 3px 0 0 var(--brand); }
.change-row.is-done { background: #fbfdfc; border-color: #d5ecdf; }
.change-row-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
  padding: 8px 6px 8px 10px;
}
.change-row-check {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--brand);
  cursor: pointer;
}
.change-row-check:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.change-row-done {
  align-self: start;
  padding: 1px 6px;
  color: var(--applied, #0f6b4a);
  background: #e3f4ec;
  border-radius: 999px;
  font: 650 11px/1.5 var(--font-heading, inherit);
}
.change-row-main { display: grid; gap: 2px; min-width: 0; }
.change-row-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main);
  font: 600 12px/1.35 var(--font-heading, inherit);
}
.change-row-name .layer-dot { flex: 0 0 auto; }
.change-row-diff { color: #334155; font-size: 12.5px; line-height: 1.5; overflow-wrap: anywhere; }
.change-row-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}
.change-row-toggle:hover { background: #f1f5f9; color: var(--text-main); }
.change-row-toggle:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.change-row-toggle svg { transition: transform 0.15s ease; }
.change-row.is-open .change-row-toggle svg { transform: rotate(180deg); }
.change-row-more {
  display: grid;
  gap: 8px;
  padding: 0 10px 10px 34px;
  font-size: 12.5px;
  color: #334155;
}
.change-row-more[hidden] { display: none; }
.change-row-more .change-card-actions { justify-content: flex-start; gap: 4px; }
/* Las acciones de la fila son las de la tarjeta, sin el panel alrededor: el
   mismo azul para la principal (RD18) y discretas las demás. */
.change-row .sg-btn {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  color: #334155;
  background: var(--bg-card);
  border: 1px solid #cfd9e6;
  border-radius: 8px;
  font: 600 12px var(--font-heading, inherit);
  cursor: pointer;
}
.change-row .sg-btn:hover { background: #f1f5f9; }
.change-row .sg-btn.ghost { background: transparent; border-color: transparent; color: var(--brand); }
.change-row .sg-btn.ghost:hover { background: #eef5fb; }
.change-row .sg-btn.primary { color: var(--text-inverse); background: var(--brand); border-color: var(--brand); }
.change-row .sg-btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.change-row .sg-btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.ai-step-fold .sg-link {
  padding: 0;
  color: var(--brand);
  background: none;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ai-step-fold .sg-link:hover { text-decoration: underline; }
.ai-step-fold .sg-link:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: 3px; }
.change-row-explanation {
  padding: 8px 10px;
  background: var(--bg-app);
  border-radius: 8px;
}
.change-row-explanation .sg-desc { margin: 0 0 6px; }
.change-row-edit { display: grid; gap: 6px; }
.change-row-edit-input {
  width: 100%;
  min-height: 52px;
  padding: 6px 8px;
  border: 1px solid #cfd9e6;
  border-radius: 8px;
  font: inherit;
  resize: vertical;
}
.change-row-edit-input:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
@media (max-width: 768px) {
  /* Móvil (N7): el carril es una hoja y en un paso deja el folio a la vista
     (`02-editor-mobile.css`). El párrafo compuesto se pliega tras un botón y
     los controles miden 44 px, salvo las casillas, que miden 24. */
  .ai-step-text-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    color: #334155;
    background: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font: 600 12.5px/1.3 var(--font-heading, inherit);
    text-align: left;
    cursor: pointer;
  }
  .ai-step-text-toggle svg { flex: 0 0 auto; transition: transform 0.15s ease; }
  .ai-step-text-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
  .ai-step-text-toggle:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
  .ai-step-compose:not(.is-open) { display: none; }
  .ai-step-text { max-height: 9em; }
  .ai-step-btn { min-height: 44px; }
  .ai-step-arrow { width: 44px; height: 44px; }
  .ai-step-head { padding-bottom: 4px; }
  .change-row-line { align-items: center; padding-block: 4px; }
  .change-row-check { width: 24px; height: 24px; margin: 0; }
  .change-row-toggle { width: 44px; height: 44px; }
  .change-row .sg-btn { min-height: 44px; }
  .ai-step-fold summary { display: flex; align-items: center; min-height: 44px; padding: 0; }
  .ai-step-fold .sg-link { min-height: 44px; }
  .ai-step-foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}
@media (max-width: 420px) {
  /* A 400 px la acción baja bajo el nombre para que el rótulo quepa entero. */
  .ai-step { grid-template-columns: minmax(0, 1fr); }
  .ai-step-act { grid-row: auto; grid-column: 1; justify-self: start; margin-top: 6px; }
  .change-row-more { padding-left: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .ai-step-bar i { animation: none; transform: translateX(75%); }
  .ai-step-btn { transition: none; }
  .ai-compose-change { transition: none; }
  .change-row-toggle svg { transition: none; }
  .ai-step-text-toggle svg { transition: none; }
}
