/*
  Archivo: propuestas.css
  Ruta: estudiantes/css/propuestas.css
  Funciones principales del archivo:
  - Dar estilo compacto a las tarjetas de propuestas del módulo estudiantes.
  - Organizar campos de tema, problema, contexto, grupo, período y objetivo.
  - Reducir altura visual de inputs, textareas, tarjetas y separaciones.
  - Dar estilo al bloque de título final.
  - Estilizar el modal de sugerencias generadas por IA con etiquetas de enfoque, proveedor, modelo y calidad.
  - Estilizar la animación de carga del orquestador multi IA.
  - Resaltar visualmente el título final cuando el estudiante elige una sugerencia.
*/

/* =========================================================
   PROPUESTAS - DISEÑO COMPACTO REAL PARA EL HTML ACTUAL
   ========================================================= */

.proposal-step {
  position: relative;
}

.proposal-card {
  margin-top: 16px;
  padding: 20px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.04);
}

.proposal-card__header,
.proposal-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.proposal-card__header h3,
.proposal-card__top h3 {
  margin: 6px 0 0;
  color: #0f172a;
  font-size: 1.03rem;
  line-height: 1.2;
}

.proposal-card__badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 5px 12px;
  border-radius: 999px;
  background: #eef2f7;
  color: #0f172a;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.proposal-card .btn {
  min-height: 42px;
  padding: 9px 15px;
  border-radius: 12px;
  white-space: nowrap;
}

.proposal-card__grid,
.proposal-card .form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 16px;
  row-gap: 10px;
  margin-top: 8px;
}

.proposal-card .field {
  gap: 5px;
  margin: 0;
}

.proposal-card .field + .field {
  margin-top: 10px;
}

.proposal-card__grid .field + .field,
.proposal-card .form-grid .field + .field {
  margin-top: 0;
}

.proposal-card label {
  margin: 0;
  color: #0f172a;
  font-size: 0.92rem;
  font-weight: 900;
  line-height: 1.15;
}

.proposal-card input,
.proposal-card textarea {
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 11px;
  font-size: 0.94rem;
  line-height: 1.35;
}

.proposal-card textarea {
  min-height: 76px;
  resize: vertical;
}

.proposal-card textarea[rows="3"] {
  min-height: 76px;
}

.proposal-card .field--title-final {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(37, 99, 235, 0.14);
  border-radius: 15px;
  background: #f8fbff;
}

.proposal-card .field--title-final textarea {
  min-height: 86px;
  background: #ffffff;
}

.proposal-card small,
.proposal-card .title-helper {
  display: block;
  margin-top: 3px;
  color: #64748b;
  font-size: 0.78rem;
  line-height: 1.3;
}

.suggestions-container,
.suggestions {
  margin-top: 10px;
}

/* Compactar encabezado general del paso de propuesta */
[data-step^="propuesta"] > .section-heading {
  margin-bottom: 12px;
}

[data-step^="propuesta"] > .section-heading h2 {
  margin-bottom: 4px;
}

[data-step^="propuesta"] > .section-heading p {
  margin-top: 4px;
}

/* Botones inferiores más cerca del formulario */
[data-step^="propuesta"] .step-actions {
  margin-top: 16px;
}

/* =========================================================
   SOPORTE PARA ESTRUCTURA ANTERIOR SI EXISTE EN OTROS BLOQUES
   ========================================================= */

.proposal-main-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin-top: 12px;
}

.field--wide,
.field--full {
  grid-column: 1 / -1;
}

.title-builder {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.07), rgba(14, 165, 233, 0.05)),
    #ffffff;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.06);
}

.title-builder__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.title-builder__header h3 {
  margin: 3px 0;
  color: #0f172a;
  font-size: 1.06rem;
}

.title-builder__header .muted {
  margin: 0;
}

.btn--ai {
  border: 0;
  color: #ffffff;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  box-shadow: 0 14px 24px rgba(79, 70, 229, 0.22);
  white-space: nowrap;
}

.btn--ai:hover {
  filter: brightness(1.03);
  transform: translateY(-1px);
}

.btn--ai:disabled {
  filter: grayscale(0.1);
  opacity: 0.72;
  transform: none;
}

.title-helper {
  display: block;
  margin-top: 6px;
  color: #64748b;
  font-size: 0.82rem;
  line-height: 1.35;
}

.field-title-selected label {
  color: #1d4ed8;
}

.field-title-selected--warning label {
  color: #b45309;
}

.title-final-selected {
  border-color: #2563eb !important;
  background: #eff6ff !important;
  color: #0f172a !important;
  box-shadow:
    0 0 0 4px rgba(37, 99, 235, 0.16),
    0 14px 28px rgba(37, 99, 235, 0.12) !important;
  transition:
    border-color 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.field-title-selected--warning .title-final-selected {
  border-color: #f59e0b !important;
  background: #fffbeb !important;
  box-shadow:
    0 0 0 4px rgba(245, 158, 11, 0.16),
    0 14px 28px rgba(245, 158, 11, 0.12) !important;
}

.title-final-selected--stable {
  transform: translateY(-1px);
}

/* =========================================================
   MODALES DE AYUDA Y SUGERENCIAS
   ========================================================= */

.modal-advice-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.modal-advice-list li {
  position: relative;
  padding: 12px 14px 12px 40px;
  border: 1px solid rgba(37, 99, 235, 0.14);
  border-radius: 14px;
  background: #f8fbff;
  color: #334155;
  line-height: 1.42;
}

.modal-advice-list li::before {
  content: "✓";
  position: absolute;
  left: 14px;
  top: 12px;
  width: 19px;
  height: 19px;
  border-radius: 999px;
  background: #2563eb;
  color: #ffffff;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 800;
}

.suggestion-modal-list {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.suggestion-modal-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: 20px;
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.06), rgba(255, 255, 255, 0)),
    #ffffff;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.07);
}

.suggestion-modal-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: #2563eb;
}

.suggestion-modal-card--buena::before {
  background: #16a34a;
}

.suggestion-modal-card--revisar::before {
  background: #f59e0b;
}

.suggestion-modal-card--mala::before {
  background: #dc2626;
}

.suggestion-modal-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.suggestion-modal-card h3 {
  margin: 0;
  color: #1d4ed8;
  font-size: 0.98rem;
  line-height: 1.32;
}

.suggestion-modal-card__text,
.suggestion-modal-card p {
  margin: 0 0 12px;
  color: #0f172a;
  font-size: 0.96rem;
  line-height: 1.45;
}

.suggestion-chip-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  max-width: 62%;
}

.suggestion-chip {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eff6ff;
  border: 1px solid rgba(37, 99, 235, 0.16);
  color: #1e3a8a;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.suggestion-chip--focus {
  background: #eef2ff;
  border-color: rgba(79, 70, 229, 0.2);
  color: #3730a3;
}

.suggestion-chip--provider {
  background: #ecfeff;
  border-color: rgba(8, 145, 178, 0.18);
  color: #155e75;
}

.suggestion-chip--model {
  background: #f8fafc;
  border-color: rgba(100, 116, 139, 0.22);
  color: #334155;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-chip--buena {
  background: #dcfce7;
  border-color: rgba(22, 163, 74, 0.2);
  color: #166534;
}

.suggestion-chip--revisar {
  background: #fef3c7;
  border-color: rgba(245, 158, 11, 0.28);
  color: #92400e;
}

.suggestion-chip--mala {
  background: #fee2e2;
  border-color: rgba(220, 38, 38, 0.24);
  color: #991b1b;
}

.suggestion-chip--rebuilt {
  background: #f5f3ff;
  border-color: rgba(124, 58, 237, 0.2);
  color: #5b21b6;
}

.suggestion-modal-detail {
  margin: 10px 0 12px;
  padding: 11px 12px;
  border-radius: 13px;
  background: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.22);
}

.suggestion-modal-detail strong,
.suggestion-modal-warnings strong {
  display: block;
  margin-bottom: 5px;
  color: #334155;
  font-size: 0.8rem;
}

.suggestion-modal-detail p {
  margin: 0;
  color: #475569;
  font-size: 0.86rem;
  line-height: 1.42;
}

.suggestion-modal-warnings {
  margin: 10px 0 12px;
  padding: 11px 12px;
  border-radius: 13px;
  background: #fffbeb;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.suggestion-modal-warnings ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-left: 18px;
  color: #92400e;
  font-size: 0.84rem;
  line-height: 1.4;
}

.suggestion-modal-card__actions {
  margin-top: 12px;
}

.suggestion-modal-card .btn,
.suggestion-modal-card__actions .btn {
  width: 100%;
}

.suggestion-modal-empty {
  padding: 18px;
  border-radius: 16px;
  background: #fff7ed;
  border: 1px solid rgba(249, 115, 22, 0.22);
  color: #9a3412;
}

.suggestion-modal-empty strong {
  display: block;
  margin-bottom: 6px;
}

.suggestion-modal-empty p {
  margin: 0;
}

/* =========================================================
   RESUMEN DE ENVÍO
   ========================================================= */

.summary-title-option {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 16px;
  background: #ffffff;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

.summary-title-option + .summary-title-option {
  margin-top: 10px;
}

.summary-title-option:hover {
  border-color: rgba(37, 99, 235, 0.46);
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.08);
}

.summary-title-option input {
  margin-top: 4px;
}

.summary-title-option span {
  display: grid;
  gap: 4px;
}

.summary-title-option strong {
  color: #1d4ed8;
}

.summary-title-option em {
  color: #0f172a;
  font-style: normal;
  line-height: 1.42;
}

.summary-block {
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 16px;
  background: #ffffff;
}

.summary-block + .summary-block {
  margin-top: 12px;
}

.summary-block h3 {
  margin: 0 0 8px;
  color: #0f172a;
}

.summary-block p {
  margin: 5px 0;
  color: #334155;
  line-height: 1.42;
}

.summary-block--highlight {
  border-color: rgba(37, 99, 235, 0.28);
  background: #eff6ff;
}

/* =========================================================
   MODAL DE CARGA IA
   ========================================================= */

.ia-loading-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 24px;
}

.ia-loading-modal.is-hidden {
  display: none;
}

.ia-loading-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(6px);
}

.ia-loading-modal__panel {
  position: relative;
  width: min(620px, 100%);
  padding: 28px;
  border-radius: 26px;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.16), transparent 34%),
    linear-gradient(135deg, rgba(248, 250, 252, 0.98), rgba(255, 255, 255, 0.98));
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.28);
  text-align: center;
}

.ia-loading-modal__spinner {
  width: 54px;
  height: 54px;
  margin: 0 auto 16px;
  border-radius: 999px;
  border: 5px solid #dbeafe;
  border-top-color: #2563eb;
  border-right-color: #7c3aed;
  animation: iaSpin 0.9s linear infinite;
}

.ia-loading-modal h2 {
  margin: 6px 0 8px;
  color: #0f172a;
  font-size: 1.48rem;
}

.ia-loading-modal__detail,
#iaLoadingDetalle {
  margin: 0 auto 14px;
  color: #475569;
  font-size: 0.96rem;
  line-height: 1.46;
  max-width: 520px;
}

.ia-loading-provider {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  margin: 0 auto 14px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #eff6ff;
  border: 1px solid rgba(37, 99, 235, 0.16);
  color: #1e3a8a;
  font-size: 0.82rem;
  font-weight: 800;
  white-space: normal;
}

.ia-loading-modal__status,
#iaLoadingEstado {
  margin: 12px auto;
  padding: 9px 12px;
  border-radius: 999px;
  background: #eff6ff;
  border: 1px solid rgba(37, 99, 235, 0.16);
  color: #1e3a8a;
  font-size: 0.84rem;
  font-weight: 900;
}

.ia-loading-progress {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
  margin: 4px 0 16px;
}

.ia-loading-progress span,
.ia-loading-progress__bar {
  display: block;
  width: 8%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #7c3aed);
  transition: width 0.28s ease;
}

.ia-loading-steps {
  display: grid;
  gap: 9px;
  margin: 14px 0;
  text-align: left;
}

.ia-loading-step {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: #ffffff;
}

.ia-loading-step__dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #cbd5e1;
}

.ia-loading-step__label {
  color: #334155;
  font-size: 0.88rem;
  font-weight: 800;
}

.ia-loading-step__state {
  color: #64748b;
  font-size: 0.74rem;
  font-weight: 800;
}

.ia-loading-step--trabajando {
  border-color: rgba(37, 99, 235, 0.28);
  background: #eff6ff;
}

.ia-loading-step--trabajando .ia-loading-step__dot {
  background: #2563eb;
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.12);
  animation: iaPulse 1s ease-in-out infinite;
}

.ia-loading-step--trabajando .ia-loading-step__state {
  color: #1d4ed8;
}

.ia-loading-step--completado {
  border-color: rgba(22, 163, 74, 0.24);
  background: #f0fdf4;
}

.ia-loading-step--completado .ia-loading-step__dot {
  background: #16a34a;
}

.ia-loading-step--completado .ia-loading-step__state {
  color: #166534;
}

.ia-loading-modal__note,
.ia-loading-modal__hint,
#iaLoadingNota {
  margin: 12px 0 0;
  color: #64748b;
  font-size: 0.84rem;
  line-height: 1.42;
}

.has-open-modal {
  overflow: hidden;
}

/* =========================================================
   ANIMACIONES
   ========================================================= */

@keyframes iaSpin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes iaPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.2);
    opacity: 0.72;
  }
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (min-width: 980px) {
  .proposal-card {
    padding: 18px 20px;
  }

  .proposal-card textarea {
    min-height: 70px;
  }

  .proposal-card .field--title-final textarea {
    min-height: 80px;
  }
}

@media (max-width: 820px) {
  .proposal-main-grid,
  .proposal-card__grid,
  .proposal-card .form-grid {
    grid-template-columns: 1fr;
  }

  .proposal-card {
    padding: 16px;
    border-radius: 16px;
  }

  .proposal-card__header,
  .proposal-card__top,
  .title-builder__header,
  .suggestion-modal-card__header {
    flex-direction: column;
  }

  .proposal-card .btn,
  .btn--ai {
    width: 100%;
  }

  .proposal-card textarea,
  .proposal-card textarea[rows="3"] {
    min-height: 82px;
  }

  .proposal-card .field--title-final {
    padding: 11px;
  }

  .proposal-card .field--title-final textarea {
    min-height: 90px;
  }

  .title-builder {
    padding: 16px;
  }

  .suggestion-modal-card {
    padding: 15px;
  }

  .suggestion-chip-row {
    justify-content: flex-start;
    max-width: 100%;
  }

  .suggestion-chip--model {
    max-width: 100%;
  }

  .ia-loading-modal {
    padding: 14px;
  }

  .ia-loading-modal__panel {
    padding: 24px 18px;
    border-radius: 24px;
  }

  .ia-loading-modal h2 {
    font-size: 1.3rem;
  }

  .ia-loading-step {
    grid-template-columns: auto 1fr;
  }

  .ia-loading-step__state {
    grid-column: 2;
  }
}

@media (max-width: 560px) {
  .proposal-card {
    margin-top: 12px;
    padding: 14px;
  }

  .proposal-card__header,
  .proposal-card__top {
    gap: 10px;
    margin-bottom: 12px;
  }

  .proposal-card input,
  .proposal-card textarea {
    font-size: 0.92rem;
  }

  .proposal-card .field + .field {
    margin-top: 9px;
  }

  [data-step^="propuesta"] .step-actions {
    margin-top: 14px;
  }
}