/*
 * Estilos propios de la zona «wizard». Los componentes comunes están en app.css:
 * aquí sólo lo que no reutiliza ninguna otra pantalla.
 *
 * Dos piezas:
 *  - .focus: la pantalla de enfoque sin barra lateral (layouts/focus.html.twig). Sirve para
 *    cualquier tarea de varios pasos.
 *  - .wizard*: el asistente «Nuevo agente» (agent/wizard.html.twig).
 */

/* ============================================================
   Pantalla de enfoque
   ============================================================ */

.focus {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface-sunken);
}

.focus__bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.focus__brand img {
  height: 24px;
}

.focus__progress {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
}

.focus__cancel {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
}

.focus__cancel:hover {
  color: var(--brand-primary);
}

.focus__main {
  flex: 1;
  display: flex;
  justify-content: center;
  /* El hueco de abajo deja ver lo último por encima de la barra fija. */
  padding: 40px 32px 120px;
}

.focus__footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 14px 32px;
  background: rgb(255 255 255 / 0.94);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border-subtle);
}

.focus__footer-inner {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.focus__note {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ============================================================
   Asistente: indicador de pasos
   ============================================================ */

.wizard-steps__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.wizard-steps__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.wizard-steps__item:hover {
  color: var(--brand-primary);
}

.wizard-steps__num {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: var(--neutral-100);
  color: var(--text-muted);
  font-size: 12px;
}

.wizard-steps__check {
  display: none;
}

.wizard-steps__item[aria-current="step"] {
  background: var(--brand-primary-bg);
  color: var(--brand-primary);
}

.wizard-steps__item[aria-current="step"] .wizard-steps__num {
  background: var(--brand-primary);
  color: #fff;
}

.wizard-steps__item.is-done {
  color: var(--text-primary);
}

.wizard-steps__item.is-done .wizard-steps__num {
  background: var(--success-bg);
  color: var(--success);
}

.wizard-steps__item.is-done .wizard-steps__digit {
  display: none;
}

.wizard-steps__item.is-done .wizard-steps__check {
  display: block;
}

/* ============================================================
   Asistente: composición
   ============================================================ */

.wizard {
  width: 100%;
  max-width: 1040px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 32px;
  align-items: start;
}

.wizard__main {
  min-width: 0;
}

/* Sin JavaScript los cinco pasos van seguidos: más aire entre ellos. */
.wizard__form {
  display: flex;
  flex-direction: column;
  gap: 48px;
}

.is-stepped .wizard__form {
  gap: 22px;
}

.wizard-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  scroll-margin-top: 24px;
}

.wizard-panel__count {
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-primary);
}

.wizard-panel__title {
  margin-top: 6px;
  font-size: 28px;
  color: var(--text-heading);
}

.wizard-panel__title:focus {
  outline: none;
}

.wizard-panel__lead {
  margin: 6px 0 0;
  font-size: 15px;
  color: var(--text-secondary);
}

.wizard-card {
  padding: 24px;
}

/* ---- Tarjetas que se eligen: plantillas, modelos, papel ---- */

.wizard-templates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.wizard-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.wizard-choice {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
  border: 1.5px solid var(--border-subtle);
  border-radius: 16px;
  background: var(--surface);
  font: inherit;
  text-align: left;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease);
}

.wizard-choice:hover {
  color: var(--text-primary);
  border-color: var(--border);
}

.wizard-choice[aria-current="true"],
.wizard-choice[aria-pressed="true"],
.wizard-choice:has(input:checked) {
  border-color: var(--brand-primary);
  background: var(--neutral-25);
}

.wizard-choice:has(input:focus-visible) {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.wizard-choice__title {
  font-size: 15.5px;
  font-weight: 700;
}

.wizard-choice__text {
  font-size: 13.5px;
  color: var(--text-secondary);
  text-wrap: pretty;
}

.wizard-choice--radio {
  gap: 3px;
  padding: 14px;
  border-radius: 14px;
}

.wizard-choice--radio .wizard-choice__title {
  font-size: 14.5px;
}

.wizard-choice--radio .wizard-choice__text {
  font-size: 12.5px;
}

/* El radio del papel no se ve: la tarjeta entera es la opción. */
.wizard-choice__input,
.wizard-pill__input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.wizard-fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.wizard-fieldset > legend {
  padding: 0;
  margin-bottom: 8px;
}

/* ---- Gasto diario con su unidad ---- */

.wizard-money {
  display: flex;
  align-items: center;
  max-width: 260px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  overflow: hidden;
}

.wizard-money:focus-within {
  outline: 2px solid var(--focus-ring);
  border-color: var(--brand-primary);
}

.wizard-money .wizard-money__input {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 0;
  outline: 0;
}

.wizard-money__unit {
  padding: 0 14px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---- Paso 4: capacidades en píldoras ---- */

fieldset.wizard-caps {
  margin: 0;
  padding: 20px 22px;
}

.wizard-caps__title {
  float: left;
  width: 100%;
  padding: 0;
  font-size: 15.5px;
  font-weight: 700;
}

.wizard-caps__lead {
  clear: both;
  margin: 0;
  padding-top: 2px;
  font-size: 13px;
  color: var(--text-secondary);
}

.wizard-caps__empty {
  margin: 14px 0 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

.wizard-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.wizard-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  background: #fff;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--neutral-600);
  cursor: pointer;
}

.wizard-pill:hover {
  border-color: var(--border-strong);
}

.wizard-pill:has(input:checked) {
  border-color: var(--brand-primary);
  background: var(--brand-primary-bg);
  color: var(--brand-primary);
}

.wizard-pill:has(input:focus-visible) {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.wizard-pill__check,
.wizard-pill:has(input:checked) .wizard-pill__plus {
  display: none;
}

.wizard-pill:has(input:checked) .wizard-pill__check {
  display: block;
}

/* ---- Paso 5: resumen ---- */

.wizard-review {
  overflow: hidden;
}

.wizard-review__row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--divider);
}

.wizard-review__row:last-child {
  border-bottom: 0;
}

.wizard-review__key {
  width: 140px;
  flex-shrink: 0;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-secondary);
}

.wizard-review__value {
  flex: 1;
  min-width: 0;
  font-size: 14.5px;
  overflow-wrap: anywhere;
}

.wizard-review__change {
  font-size: 13px;
  font-weight: 700;
}

/* ============================================================
   Asistente: vista previa
   ============================================================ */

.wizard__aside {
  position: sticky;
  top: 24px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wizard-preview {
  padding: 22px;
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 4px 12px rgb(61 61 61 / 0.06);
}

.wizard-preview__head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.wizard-preview__avatar {
  width: 48px;
  height: 48px;
  border-radius: 15px;
  font-size: 16px;
}

.wizard-preview__name {
  font-size: 16.5px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.wizard-preview__meta {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.wizard-preview__summary {
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--text-secondary);
  text-wrap: pretty;
}

.wizard-preview__chat {
  margin-top: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-radius: 14px;
  background: var(--surface-sunken);
}

.wizard-bubble {
  max-width: 85%;
  padding: 9px 13px;
  font-size: 13.5px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.wizard-bubble--user {
  align-self: flex-end;
  border-radius: 14px 14px 4px 14px;
  background: var(--brand-primary);
  color: #fff;
}

.wizard-bubble--agent {
  align-self: flex-start;
  border-radius: 14px 14px 14px 4px;
  border: 1px solid var(--border-subtle);
  background: #fff;
}

.wizard-preview__caps {
  margin-top: 14px;
}

.wizard-preview__caps:empty {
  display: none;
}

.wizard-preview__caps .tag {
  white-space: normal;
}

.wizard__aside-note {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ============================================================
   Pantallas estrechas
   ============================================================ */

@media (max-width: 900px) {
  .focus__bar {
    gap: 12px;
    padding: 12px 16px;
  }

  /* El indicador baja a su propia fila, debajo de la marca y «Cancelar». */
  .focus__progress {
    order: 3;
    flex-basis: 100%;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .focus__cancel {
    margin-left: auto;
  }

  .focus__main {
    padding: 24px 16px 112px;
  }

  .focus__footer {
    padding: 12px 16px;
  }

  .wizard-steps__list {
    flex-wrap: nowrap;
    justify-content: flex-start;
  }

  /* Sólo el paso actual con nombre: los cinco no caben en 390px. */
  .is-stepped .wizard-steps__item:not([aria-current="step"]) .wizard-steps__label {
    display: none;
  }

  .is-stepped .wizard-steps__item:not([aria-current="step"]) {
    padding-right: 6px;
  }

  .wizard__aside {
    position: static;
  }

  .wizard-panel__title {
    font-size: 24px;
  }
}

@media (max-width: 600px) {
  .focus__note {
    display: none;
  }

  /* Sin la nota, Atrás a la izquierda y el botón principal a la derecha. */
  .focus__footer-inner > .btn:not([data-agent-wizard-target="back"]) {
    margin-left: auto;
  }

  .wizard-review__row {
    flex-wrap: wrap;
    gap: 4px 16px;
  }

  .wizard-review__key {
    width: auto;
    flex: 1 1 100%;
  }
}

/* ==== Asistente de servidores MCP (templates/mcp/wizard.html.twig) ==== */

/* El modo de autenticación de cada plantilla, bajo su descripción. */
.mcp-wizard__chip {
  align-self: flex-start;
  margin-top: 4px;
  padding: 2px 9px;
  border-radius: var(--radius-full);
  background: var(--neutral-25);
  border: 1px solid var(--border-subtle);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
}

/* Lo que se dice de la dirección según se escribe. */
.mcp-wizard__urlhint {
  min-height: 1.2em;
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.mcp-wizard__urlhint[data-tone="ok"] { color: var(--success); }
.mcp-wizard__urlhint[data-tone="danger"] { color: var(--danger); }

.mcp-wizard__auth {
  grid-template-columns: 1fr;
}

.mcp-wizard__auth-icon {
  vertical-align: -2px;
  margin-right: 4px;
}

/* Los tres pasos de OAuth, numerados. */
.mcp-wizard__flow {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: flow;
}

.mcp-wizard__flow li {
  position: relative;
  padding-left: 34px;
  font-size: 14px;
  color: var(--text-secondary);
  counter-increment: flow;
}

.mcp-wizard__flow li::before {
  content: counter(flow);
  position: absolute;
  left: 0;
  top: -1px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand-primary-bg);
  color: var(--brand-primary);
  font-size: 12px;
  font-weight: 700;
}

.mcp-wizard__oauth {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Lo avanzado, plegado: cliente OAuth propio y cabeceras. */
.mcp-wizard__more {
  border-top: 1px solid var(--border-subtle);
  padding-top: 14px;
}

.mcp-wizard__more > summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.mcp-wizard__more[open] > summary {
  margin-bottom: 14px;
}

/* Probar */
.mcp-wizard__probe {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.mcp-wizard__probe-note {
  font-size: 13px;
  color: var(--text-muted);
}

.mcp-wizard__result {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--neutral-25);
  font-size: 14px;
  color: var(--text-secondary);
}

.mcp-wizard__result[data-tone="ok"] { background: var(--success-bg); color: var(--success); }
.mcp-wizard__result[data-tone="danger"] { background: var(--danger-bg); color: var(--danger); }

.mcp-wizard__tools {
  margin-top: 18px;
}

.mcp-wizard__tools .options {
  margin-top: 10px;
  max-height: 360px;
  overflow: auto;
}

.mcp-wizard__tools-actions {
  margin-top: 6px;
}

.mcp-wizard__allowed:not([hidden]) {
  margin-top: 18px;
}

.mcp-wizard__allowed .field {
  margin-top: 0;
}

/* Vista previa: la dirección y la lista de seguridad. */
.mcp-wizard__preview-url {
  margin-top: 12px;
  font-size: 12px;
  word-break: break-all;
}

.mcp-wizard__checks {
  display: grid;
  gap: 8px;
  margin: 16px 0 0;
  padding: 14px 0 0;
  border-top: 1px solid var(--border-subtle);
  list-style: none;
}

.mcp-wizard__checks li {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--text-secondary);
}

.mcp-wizard__check-icon {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-muted);
}

.mcp-wizard__checks li[data-tone="ok"] .mcp-wizard__check-icon { background: var(--success); }
.mcp-wizard__checks li[data-tone="warning"] .mcp-wizard__check-icon { background: var(--warning); }
.mcp-wizard__checks li[data-tone="danger"] .mcp-wizard__check-icon { background: var(--danger); }
.mcp-wizard__checks li[data-tone="danger"] { color: var(--danger); }
