/* Seguimiento Ejecutivo 1.0.54
   Lectura sticky completa en Fases/Actividades + contexto de proyecto en Históricos.
   Capa aislada: no modifica datos, API, SSO ni permisos.
*/

.project-phase {
  overflow: visible !important;
  position: relative;
}

.project-phase > summary {
  position: sticky;
  top: 0;
  z-index: 26;
  min-height: 58px;
  padding: 10px 16px 11px 38px !important;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "context dates"
    "phase dates";
  align-items: center;
  column-gap: 16px;
  background: rgba(250, 252, 255, 0.96) !important;
  border-bottom: 1px solid rgba(211, 221, 235, 0.94);
  box-shadow: 0 7px 18px rgba(31, 49, 78, 0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
}

.project-phase > summary::marker {
  color: #50647f;
}

.project-phase > summary::before {
  content: "PROYECTO · " attr(data-project-name);
  grid-area: context;
  min-width: 0;
  margin-bottom: 2px;
  color: #74839a;
  font-size: 9px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: .11em;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-phase > summary > strong {
  grid-area: phase;
  min-width: 0;
  color: #24334b;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-phase > summary > strong::before {
  content: "Fase · ";
  color: #6b5bd2;
  font-weight: 700;
}

.project-phase > summary > .muted {
  grid-area: dates;
  align-self: center;
  margin: 0 !important;
  float: none !important;
  color: #667891;
  font-size: 10px !important;
  white-space: nowrap;
}

/* Segunda franja sticky: conserva los nombres de columnas durante el scroll. */
.phase-sticky-columns {
  position: sticky;
  top: 58px;
  z-index: 25;
  display: grid;
  grid-template-columns:
    minmax(260px, 2.15fr)
    minmax(180px, 1.28fr)
    minmax(130px, .92fr)
    minmax(115px, .82fr)
    minmax(135px, .92fr)
    minmax(145px, 1fr);
  align-items: center;
  gap: 0;
  min-height: 37px;
  padding: 0 16px;
  background: rgba(249, 250, 253, 0.97);
  border-bottom: 1px solid rgba(219, 226, 237, 0.96);
  box-shadow: 0 5px 13px rgba(31, 49, 78, 0.045);
  backdrop-filter: blur(11px);
  -webkit-backdrop-filter: blur(11px);
  color: #728097;
  font-size: 10px;
  line-height: 1;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}

.phase-sticky-columns > span {
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 12px;
}

.project-phase > .table-scroll {
  overflow-x: auto;
  overflow-y: visible;
  border-radius: 0 0 8px 8px;
}

/* Evita repetir visualmente el thead normal cuando la franja sticky ya está presente. */
.project-phase.has-sticky-columns > .table-scroll thead {
  visibility: collapse;
}

.project-phase > summary.is-stuck {
  background: rgba(255, 255, 255, 0.985) !important;
  border-color: rgba(113, 91, 210, 0.18);
  box-shadow: 0 10px 24px rgba(31, 49, 78, 0.11);
}

/* Históricos: hacer explícito de qué proyecto es cada movimiento. */
.history .history-body .link.block {
  display: inline-flex !important;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  color: #4f46c9;
  font-weight: 700;
  text-decoration: none;
}

.history .history-body .link.block::before {
  content: "Proyecto · ";
  color: #8793a7;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .035em;
  text-transform: uppercase;
}

/* Si el título llega como texto simple en alguna variante, dejamos listo el estilo. */
.history-project-context {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 5px;
  color: #4f46c9;
  font-size: 12px;
  font-weight: 700;
}
.history-project-context::before {
  content: "Proyecto · ";
  color: #8793a7;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .035em;
  text-transform: uppercase;
}

@media (max-width: 980px) {
  .phase-sticky-columns {
    grid-template-columns:
      minmax(220px, 2fr)
      minmax(160px, 1.25fr)
      minmax(120px, .9fr)
      minmax(110px, .8fr)
      minmax(120px, .9fr)
      minmax(130px, 1fr);
    overflow-x: auto;
  }
}

@media (max-width: 760px) {
  .project-phase > summary {
    min-height: 64px;
    padding: 9px 12px 10px 30px !important;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "context"
      "phase"
      "dates";
    row-gap: 1px;
  }

  .project-phase > summary > .muted {
    margin-top: 2px !important;
    font-size: 9px !important;
  }

  .project-phase > summary::before {
    font-size: 8px;
  }

  .project-phase > summary > strong {
    font-size: 12px;
  }

  .phase-sticky-columns {
    top: 64px;
    min-width: 760px;
    padding-left: 12px;
    font-size: 9px;
  }

  .project-phase.has-sticky-columns > .table-scroll thead {
    visibility: visible;
  }
}

@media (prefers-reduced-motion: reduce) {
  .project-phase > summary,
  .phase-sticky-columns {
    scroll-behavior: auto;
  }
}
