/* =========================================================================
   estilos.css  ──  Todo el aspecto visual de FondoFinder vive aquí.
   
   Para cambiar colores: edita las variables en :root.
   Para cambiar tipografías: edita las fuentes en :root y en los @import.
   
   Este archivo lo usan: index.html, perfil.html y admin.html.
   ========================================================================= */

/* ── Tokens de diseño ── */
:root {
  /* Paleta principal */
  --primary: #0e7a5f;
  --primary-dark: #0a5a46;
  --primary-light: #12996f;
  --primary-tint: #edf4f1;
  --primary-soft: #d4ebe3;

  /* Neutros */
  --text: #1a1f1c;
  --text-secondary: #5a6360;
  --text-muted: #8a9490;
  --border: #dfe4e1;
  --border-light: #eef1ef;
  --surface: #ffffff;
  --surface-raised: #f7f9f8;
  --bg: #fafbfa;

  /* Acentos funcionales */
  --amber-bg: #fef9ee;
  --amber-border: #f0ddb0;
  --amber-text: #7a5c18;
  --red-text: #b4352a;
  --red-bg: #fef2f1;
  --blue-text: #1a6fb5;
  --blue-bg: #eff6fd;

  /* Gráficos (admin) */
  --chart-1: #0e7a5f;
  --chart-2: #e87b5f;
  --chart-3: #4a90d9;
  --chart-4: #d4a843;
  --chart-5: #7c5cbf;

  /* Layout */
  --max-w: 740px;
  --max-w-wide: 1080px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;

  /* Sombras */
  --shadow-sm: 0 1px 3px rgba(26, 31, 28, 0.06);
  --shadow-md: 0 4px 16px rgba(26, 31, 28, 0.08);
  --shadow-lg: 0 8px 30px rgba(26, 31, 28, 0.1);

  /* Transiciones */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

a {
  color: inherit;
  text-decoration: none;
}
button {
  cursor: pointer;
  font-family: inherit;
}

/* ── Cabecera / Navegación ── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 251, 250, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
}
.nav__inner {
  max-width: var(--max-w-wide);
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav__logo {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  letter-spacing: -0.02em;
}
.nav__logo b {
  color: var(--primary);
  font-weight: 700;
}

.nav__links {
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav__link {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: none;
  background: none;
  transition: all 0.15s var(--ease);
}
.nav__link:hover {
  background: var(--primary-tint);
  color: var(--primary-dark);
}
.nav__link.is-active {
  background: var(--primary-tint);
  color: var(--primary-dark);
}
.nav__status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 4px 10px;
  background: var(--surface-raised);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-light);
}
.nav__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}
.nav__dot.offline {
  background: var(--text-muted);
}

/* ── Hero / Bloque central ── */
.hero {
  max-width: var(--max-w);
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
  flex: 1;
}
.hero__inner {
  padding-top: 11vh;
  transition: padding-top 0.35s var(--ease);
}
.hero__inner.compacto {
  padding-top: 28px;
}

@media (prefers-reduced-motion: reduce) {
  .hero__inner {
    transition: none;
  }
}

.hero__title {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  text-align: center;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-bottom: 8px;
}
.hero__sub {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 28px;
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

/* ── Caja de búsqueda ── */
.search {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.search:focus-within {
  border-color: var(--primary-soft);
  box-shadow:
    var(--shadow-lg),
    0 0 0 3px rgba(14, 122, 95, 0.08);
}

.search__field {
  padding: 18px 18px 6px;
}
.search__textarea {
  display: block;
  width: 100%;
  border: none;
  background: none;
  resize: none;
  min-height: 80px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.55;
}
.search__textarea::placeholder {
  color: var(--text-muted);
}
.search__textarea:focus {
  outline: none;
}

/* ── Aviso de privacidad (bajo el buscador, sobre la línea de confianza) ── */
.privacidad {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 8px;
  line-height: 1.4;
  text-align: center;
}

/* ── Toast: mini popup abajo, se cierra solo o con la × ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 480px);
  background: var(--text);
  color: #fff;
  font-size: 0.82rem;
  line-height: 1.4;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  animation: toast-in 0.25s var(--ease);
}
.toast--saliendo {
  opacity: 0;
  transition: opacity 0.3s;
}
.toast__x {
  border: none;
  background: none;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.7;
}
.toast__x:hover {
  opacity: 1;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.search__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px 12px;
  flex-wrap: wrap;
}

/* Segmento de modo */
.seg {
  display: inline-flex;
  background: var(--surface-raised);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
}
.seg button {
  border: none;
  background: none;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  transition: all 0.15s var(--ease);
}
.seg button:hover {
  color: var(--text);
}
.seg button.is-on {
  background: var(--surface);
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}
.ia-dot {
  font-size: 0.7rem;
  margin-right: 2px;
}

.search__actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  border: none;
  padding: 9px 20px;
  transition: all 0.15s var(--ease);
}
.btn--primary {
  background: var(--primary);
  color: #fff;
}
.btn--primary:hover {
  background: var(--primary-dark);
}
.btn--primary:disabled {
  opacity: 0.5;
  cursor: wait;
}

.btn--ghost {
  background: none;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn--ghost:hover {
  background: var(--surface-raised);
  color: var(--text);
}
.btn--ghost.is-active {
  background: var(--primary-tint);
  color: var(--primary-dark);
  border-color: var(--primary-soft);
}

/* ── Mini-formulario "Afinar búsqueda" ── */
.refine {
  max-height: 0;
  overflow: hidden;
  transition:
    max-height 0.35s var(--ease),
    opacity 0.25s;
  opacity: 0;
  border-top: 1px solid transparent;
}
.refine.abierto {
  max-height: 600px;
  opacity: 1;
  border-top-color: var(--border-light);
}
.refine__inner {
  padding: 18px 18px 16px;
}
.refine__head {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 14px;
}
.refine__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.refine__group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.refine__group.full {
  grid-column: 1 / -1;
}
.refine__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
}
.refine__select {
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%238a9490' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
.refine__select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(14, 122, 95, 0.12);
}

/* ── Chips de ejemplo ── */
.chips {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 6px 16px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s var(--ease);
}
.chip:hover {
  border-color: var(--primary-soft);
  color: var(--primary-dark);
  background: var(--primary-tint);
}

/* ── Línea de confianza ── */
.trust {
  margin-top: 30px;
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.trust b {
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
}

/* ── Estados: aviso, carga ── */
.aviso {
  display: none;
  margin-top: 18px;
  font-size: 0.85rem;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  line-height: 1.45;
}
.aviso.visible {
  display: block;
}
.aviso--warn {
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  color: var(--amber-text);
}
.aviso--error {
  background: var(--red-bg);
  border: 1px solid #f0c0bc;
  color: var(--red-text);
}

.cargando {
  display: none;
  margin-top: 22px;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}
.cargando.visible {
  display: flex;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: girar 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes girar {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }
}

/* ── Encabezado de resultados ── */
.results-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  margin-top: 28px;
  margin-bottom: 16px;
}
.results-header.visible {
  display: flex;
}

.results-header__title {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.results-header__count {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Tarjetas de resultado (colapsables) ── */
.resultados {
  padding-bottom: 60px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  overflow: hidden;
  transition: box-shadow 0.15s var(--ease);
}
.card:hover {
  box-shadow: var(--shadow-md);
}

/* Parte clickeable (siempre visible) */
.card__head {
  padding: 16px 20px;
  cursor: pointer;
}

.card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.card__left {
  flex: 1;
  min-width: 0;
}

/* Badge de institución (CORFO, SERCOTEC, etc.) */
.card__badges {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.badge-inst {
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.card__alcance {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

.card__title {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}

/* Anillo de afinidad */
.ring__wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}
.ring {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-content: center;
  position: relative;
  background: conic-gradient(
    var(--ring-color, var(--primary)) calc(var(--pct) * 1%),
    var(--border-light) calc(var(--pct) * 1%)
  );
}
.ring::before {
  content: "";
  position: absolute;
  inset: 4px;
  background: var(--surface);
  border-radius: 50%;
}
.ring__nivel {
  position: relative;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--ring-color, var(--primary-dark));
  line-height: 1;
}
.ring__label {
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ring-color, var(--primary));
  margin-top: 3px;
}

/* Colores por nivel de afinidad (Fase 2.7) */
.ring__wrap--alta {
  --ring-color: var(--primary);
}
.ring__wrap--media {
  --ring-color: #d4a843;
}
.ring__wrap--baja {
  --ring-color: var(--text-muted);
}

/* Pills de requisitos */
.card__pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.pill {
  font-size: 0.73rem;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}
.pill--match {
  background: #e8f5e9;
  color: #2e7d32;
  border-color: #c8e6c9;
}

/* Pie visible (monto + cierre + chevron) */
.card__foot {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
  font-size: 0.82rem;
}
.card__foot strong {
  font-weight: 600;
  color: var(--text);
}
.card__foot .cierre {
  color: var(--text-secondary);
}
.card__chevron {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: transform 0.2s var(--ease);
  user-select: none;
}

/* Detalle expandible (oculto por defecto) */
.card__detail {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s var(--ease);
  border-top: 1px solid transparent;
}
.card__detail.abierto {
  max-height: 600px;
  border-top-color: var(--border-light);
}

/* Cuerpo scrollable (resumen + requisitos) */
.card__detail-scroll {
  max-height: 280px;
  overflow-y: auto;
  padding: 14px 20px 8px;
}

/* Label de sección */
.card__section-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 6px;
}

.card__body {
  color: var(--text-secondary);
  font-size: 0.86rem;
  line-height: 1.55;
  margin: 0;
}

/* Pie fijo (siempre visible al expandir, fuera del scroll) */
.card__detail-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--surface-raised);
}
.card__link {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}
.card__link:hover {
  text-decoration: underline;
}

/* Badge de estado */
.estado {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  text-transform: capitalize;
}
.estado::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
}
.estado--abierta {
  background: #e8f5e9;
  color: #2e7d32;
}
.estado--abierta::before {
  background: #2e7d32;
}
.estado--proxima {
  background: var(--blue-bg);
  color: var(--blue-text);
}
.estado--proxima::before {
  background: var(--blue-text);
}
.estado--cerrada {
  background: #f5f5f5;
  color: #757575;
}
.estado--cerrada::before {
  background: #757575;
}

/* ── Requisitos clave (tarjeta ámbar dentro del scroll) ── */
.card__requisitos {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  border-radius: var(--radius-sm);
}
.card__requisitos-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--amber-text);
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.card__requisitos-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.card__requisitos-list li {
  font-size: 0.82rem;
  color: var(--amber-text);
  padding: 2px 0 2px 16px;
  position: relative;
  line-height: 1.5;
}
.card__requisitos-list li::before {
  content: "•";
  position: absolute;
  left: 4px;
  color: var(--amber-text);
}

/* ── No aplica para (tarjeta roja de exclusiones) ── */
.card__no-aplica {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--red-bg);
  border: 1px solid #f0c0bc;
  border-radius: var(--radius-sm);
}
.card__no-aplica-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--red-text);
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.card__no-aplica-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.card__no-aplica-list li {
  font-size: 0.82rem;
  color: var(--red-text);
  padding: 2px 0 2px 16px;
  position: relative;
  line-height: 1.5;
}
.card__no-aplica-list li::before {
  content: "•";
  position: absolute;
  left: 4px;
  color: var(--red-text);
}

/* Pill de foco género */
.pill--genero {
  background: #fce4ec;
  color: #ad1457;
  border-color: #f8bbd0;
}

/* ── Filtros activos (chips sobre los resultados) ── */
.filtros-activos {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.filtro-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  padding: 4px 10px;
  background: var(--primary-tint);
  color: var(--primary-dark);
  border: 1px solid var(--primary-soft);
  border-radius: var(--radius-pill);
}
.filtro-chip__x {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
.filtro-chip__x:hover {
  color: var(--primary-dark);
}

/* ── Captura de email ── */
.email-capture {
  margin-top: 28px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.email-capture__title {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.email-capture__sub {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}
.email-capture__row {
  display: flex;
  gap: 8px;
  max-width: 420px;
  margin: 0 auto;
}
.email-capture__input {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 0.88rem;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.email-capture__input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(14, 122, 95, 0.12);
}
.email-capture__btn {
  white-space: nowrap;
}
.email-capture__legal {
  font-size: 0.75rem;
  margin-top: 8px;
  min-height: 1.2em;
}

/* ── Footer ── */
.footer {
  text-align: center;
  font-size: 0.74rem;
  color: var(--text-muted);
  padding: 18px 20px 24px;
  border-top: 1px solid var(--border-light);
  margin-top: auto;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .nav__inner {
    padding: 0 16px;
  }
  .hero {
    padding: 0 16px;
  }
  .hero__inner {
    padding-top: 7vh;
  }

  .search__row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .search__actions {
    justify-content: flex-end;
  }

  .refine__grid {
    grid-template-columns: 1fr;
  }

  .card__head {
    padding: 14px 16px;
  }
  .card__top {
    flex-direction: column;
  }
  .ring__wrap {
    flex-direction: row;
    gap: 10px;
    margin-top: 8px;
  }
  .ring {
    width: 48px;
    height: 48px;
  }
  .ring__nivel {
    font-size: 0.65rem;
  }
  .email-capture__row {
    flex-direction: column;
  }

  .nav__status {
    display: none;
  }
}
