/* ════════════════════════════════════════════════════════════════
   pm-report.css — Estilos para Reporte de Avance de Proyecto
   GestionPM: Paleta verde bosque (var(--crimson*)), mobile-first (375px+).
   Extiende global.css y añade soporte para impresión horizontal.
════════════════════════════════════════════════════════════════ */

/* ─── Utilidades ─────────────────────────────────────────────── */
.is-hidden {
  display: none !important;
}

.data-store-container,
.data-store-list {
  display: none !important;
}

/* ─── Espaciado entre Secciones ──────────────────────────────── */
.report-section {
  margin-bottom: 26px;
}

/* ─── Topbar Extras ──────────────────────────────────────────── */
.report-topbar-date {
  font-size: 11.5px;
  color: var(--text-soft);
  font-weight: 500;
  display: inline-block;
}

.breadcrumb-link {
  color: inherit;
  text-decoration: none;
  transition: var(--transition);
}

.breadcrumb-link:hover {
  color: var(--crimson);
  text-decoration: underline;
}

/* ─── Barra de Filtros Activos Aplicados ─────────────────────── */
.active-filters-bar {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.active-filters-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.active-filters-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.active-filters-chip {
  font-size: 11px;
  font-weight: 600;
  background: var(--gray-100);
  color: var(--text-dark);
  padding: 3px 9px;
  border-radius: 99px;
  border: 1px solid var(--gray-200);
}

.active-filters-chip.chip-highlight {
  background: var(--crimson-pale);
  color: var(--crimson);
  border-color: var(--crimson-light);
  font-weight: 700;
}

/* ─── Banner Principal de Encabezado (Report Header) ─────────── */
.report-header {
  background: linear-gradient(135deg, var(--crimson-dark) 0%, var(--crimson) 55%, var(--crimson-light) 100%);
  border-radius: var(--radius-xl);
  padding: 30px 34px;
  color: #fff;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 28px;
  align-items: center;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

/* Círculos decorativos de fondo */
.report-header::before,
.report-header::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  pointer-events: none;
}
.report-header::before { width: 320px; height: 320px; top: -130px; right: -70px; }
.report-header::after  { width: 190px; height: 190px; bottom: -90px; right: 130px; }

.rh-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 6px;
}

.rh-project-name {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
  line-height: 1.25;
}

.rh-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.rh-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
}

.rh-badge.overdue {
  background: rgba(181, 42, 16, 0.55);
  border-color: rgba(255, 100, 80, 0.45);
}

.rh-badge.done {
  background: rgba(14, 122, 64, 0.55);
  border-color: rgba(50, 200, 120, 0.45);
}

.rh-badge.projected {
  background: rgba(255, 255, 255, 0.25);
  font-weight: 700;
  border-color: rgba(255, 255, 255, 0.4);
}

/* Anillo SVG de progreso en el banner */
.rh-right {
  flex-shrink: 0;
  text-align: center;
  position: relative;
  z-index: 1;
}

.rh-ring-wrap {
  width: 132px;
  height: 132px;
  position: relative;
  display: inline-block;
}

.rh-ring-wrap svg {
  width: 100%;
  height: 100%;
}

.rh-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.rh-pct {
  font-size: 27px;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.5px;
}

.rh-pct-label {
  font-size: 9.5px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ─── Grid de Tarjetas KPI ───────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.kpi-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  transition: var(--transition);
  border-top: 3.5px solid transparent;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-icon {
  font-size: 20px;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-dark);
  margin-bottom: 2px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.kpi-sub {
  font-size: 11px;
  color: var(--text-soft);
  margin-top: 4px;
}

/* ─── Layout Grids (Columnas) ────────────────────────────────── */
.report-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.report-grid-13 {
  display: grid;
  grid-template-columns: 1.15fr 1.85fr;
  gap: 20px;
}

/* ─── Paneles del Reporte ────────────────────────────────────── */
.panel {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-subtitle {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 2px;
}

.panel-body {
  padding: 20px;
}

.panel-body-flush {
  padding: 0;
}

/* ─── Gráfico Donut de Estados ───────────────────────────────── */
.donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.donut-svg-box {
  width: 170px;
  height: 170px;
  position: relative;
  margin-bottom: 16px;
}

.donut-svg-box svg {
  width: 100%;
  height: 100%;
}

.donut-center-info {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.donut-center-val {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-dark);
}

.donut-center-sub {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-soft);
  text-transform: uppercase;
}

.donut-legend-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  font-size: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-label {
  color: var(--text-mid);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.legend-pct {
  font-weight: 700;
  color: var(--text-dark);
}

/* ─── Lista Desglosada de Estados ────────────────────────────── */
.status-cards-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.status-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  background: var(--white);
  transition: var(--transition);
}

.status-card-row:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

.status-card-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.status-card-icon {
  font-size: 16px;
}

.status-card-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dark);
}

.status-card-bar-wrap {
  width: 120px;
  height: 6px;
  border-radius: 99px;
  background: var(--gray-100);
  overflow: hidden;
  margin: 0 14px;
}

.status-card-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s ease;
}

.status-card-count {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-dark);
}

.status-card-pct {
  font-size: 11px;
  color: var(--text-soft);
  margin-left: 4px;
}

/* ─── Barras de Progreso por Categoría / Etiqueta ────────────── */
.label-bar-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 290px;
  overflow-y: auto;
  padding-right: 4px;
}

.label-bar-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.label-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
}

.label-bar-title {
  font-weight: 600;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 6px;
}

.label-bar-pill {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.label-bar-stat {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-mid);
}

.label-progress-track {
  width: 100%;
  height: 7px;
  border-radius: 99px;
  background: var(--gray-100);
  overflow: hidden;
}

.label-progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* ─── Desempeño del Equipo (Miembros) ────────────────────────── */
.team-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 290px;
  overflow-y: auto;
  padding-right: 4px;
}

.team-user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
}

.team-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.team-info {
  flex: 1;
  min-width: 0;
}

.team-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  margin-bottom: 4px;
}

.team-name {
  font-weight: 700;
  color: var(--text-dark);
}

.team-ratio {
  font-size: 11px;
  color: var(--text-soft);
  font-weight: 600;
}

.team-bar-track {
  width: 100%;
  height: 6px;
  border-radius: 99px;
  background: var(--gray-200);
  overflow: hidden;
}

.team-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--crimson);
  transition: width 0.4s ease;
}

/* ─── Línea de Tiempo e Hitos (Fases Raíz WBS) ────────────────── */
.timeline-wrapper {
  overflow-x: auto;
  padding: 10px 4px 18px;
}

.timeline {
  display: flex;
  align-items: flex-start;
  position: relative;
  min-width: 600px;
}

.timeline::before {
  content: '';
  position: absolute;
  top: 21px;
  left: 20px;
  right: 20px;
  height: 3px;
  background: var(--gray-200);
  z-index: 0;
}

.timeline-milestone {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
}

.timeline-milestone + .timeline-milestone::after {
  content: '';
  position: absolute;
  top: 20px;
  right: 50%;
  left: -50%;
  height: 3px;
  z-index: -1;
}

.milestone-dot-wrap {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  border: 3.5px solid var(--white);
  box-shadow: 0 0 0 2px var(--gray-200);
  background: var(--gray-100);
  transition: var(--transition);
  margin-bottom: 10px;
}

.milestone-dot-wrap.done {
  background: #0e7a40;
  box-shadow: 0 0 0 2px #0e7a40, 0 0 12px rgba(14, 122, 64, 0.3);
  color: #fff;
}

.milestone-dot-wrap.progress {
  background: var(--crimson);
  box-shadow: 0 0 0 2px var(--crimson), 0 0 12px var(--crimson-glow);
  color: #fff;
}

.milestone-dot-wrap.blocked {
  background: #b52a10;
  box-shadow: 0 0 0 2px #b52a10;
  color: #fff;
}

.milestone-dot-wrap.pending {
  background: var(--white);
  box-shadow: 0 0 0 2px var(--gray-300);
}

.milestone-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-dark);
  text-align: center;
  margin-bottom: 2px;
  max-width: 140px;
  line-height: 1.3;
}

.milestone-date {
  font-size: 11px;
  color: var(--text-soft);
  text-align: center;
}

.milestone-status-chip {
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  text-align: center;
}

.timeline-milestone.done + .timeline-milestone::after {
  background: #0e7a40;
}

.timeline-milestone.progress + .timeline-milestone::after {
  background: linear-gradient(to right, var(--crimson), var(--gray-200));
}

/* ─── Health Badges ──────────────────────────────────────────── */
.health-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
}

.health-on-track {
  background: rgba(14, 122, 64, 0.12);
  color: #0e7a40;
}

.health-at-risk {
  background: rgba(217, 119, 6, 0.12);
  color: #92400e;
}

.health-off-track {
  background: rgba(181, 42, 16, 0.12);
  color: #b52a10;
}

/* ─── Tabla de Tareas (Base) ─────────────────────────────────── */
.scroll-table-wrap {
  max-height: 330px;
  overflow-y: auto;
}

.task-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.task-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-soft);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-100);
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: 0 1px 0 var(--gray-100);
}

.task-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

.task-table tbody tr:last-child td {
  border-bottom: none;
}

.task-table tbody tr:hover td {
  background: var(--gray-50);
}

/* Fila de contexto (ancestros preservados para estructura WBS) */
.task-table tbody tr.row-context {
  opacity: 0.65;
  background: rgba(240, 247, 242, 0.4);
}

.context-tag {
  font-size: 9.5px;
  font-weight: 700;
  background: var(--gray-200);
  color: var(--text-mid);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  text-transform: uppercase;
}

.task-num-cell {
  font-family: monospace;
  font-weight: 700;
  color: var(--crimson);
  font-size: 11.5px;
}

.task-name-cell {
  font-weight: 600;
  color: var(--text-dark);
}

.task-desc-cell {
  font-size: 11px;
  color: var(--text-soft);
  margin-top: 2px;
}

.task-depth-indent {
  display: inline-block;
}

/* Indicador de Ajuste Manual */
.manual-date-badge {
  font-size: 10px;
  font-weight: 700;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 99px;
  padding: 1px 6px;
  margin-left: 5px;
  white-space: nowrap;
}

/* Semáforo de Desviación */
.dev-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.dev-badge.dev-ok {
  background: rgba(14, 122, 64, 0.12);
  color: #0e7a40;
}

.dev-badge.dev-late {
  background: rgba(181, 42, 16, 0.12);
  color: #b52a10;
}

/* Status Pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

/* Avatar de Asignado en Tabla */
.user-avatar-table {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Group header en tabla atrasadas */
.group-header-row td {
  padding: 8px 14px 4px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-100);
}

/* ─── Paneles Colapsables ────────────────────────────────────── */
.collapsible-toggle {
  cursor: pointer;
  user-select: none;
}

.collapsible-toggle:hover .panel-title {
  color: var(--crimson);
}

.collapse-arrow {
  font-size: 12px;
  color: var(--text-soft);
  transition: transform 0.25s ease;
}

.collapse-arrow.open {
  transform: rotate(180deg);
}

.collapsible-body {
  overflow: hidden;
  transition: max-height 0.35s ease;
}

/* ─── Estado Vacío ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 30px;
  color: var(--text-soft);
  font-size: 13px;
}

/* ─── Footer Institucional ───────────────────────────────────── */
.page-footer {
  text-align: center;
  padding: 24px 0 12px;
  font-size: 12px;
  color: var(--text-soft);
}

.atomo-link {
  color: #cb4949;
  font-weight: 700;
  text-decoration: none;
  transition: var(--transition);
}

.atomo-link:hover {
  color: #e56363;
  text-decoration: underline;
}

/* ════════════════════════════════════════════════════════════════
   PRINT STYLES (@media print)
════════════════════════════════════════════════════════════════ */
@page {
  size: landscape;
  margin: 12mm;
}

@media print {
  .sidebar-frame,
  .mobile-overlay,
  .mobile-nav-toggle,
  .topbar,
  .active-filters-bar,
  .btn,
  .toast-container {
    display: none !important;
  }

  .main {
    margin-left: 0 !important;
    padding: 0 !important;
  }

  .content {
    padding: 0 !important;
  }

  .report-header {
    background: var(--crimson) !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    box-shadow: none !important;
  }

  .panel,
  .kpi-card {
    box-shadow: none !important;
    border: 1px solid #d1d5db !important;
    break-inside: avoid;
  }

  .scroll-table-wrap {
    max-height: none !important;
    overflow: visible !important;
  }

  .task-table th {
    position: static !important;
  }

  .report-grid-13,
  .report-grid-2 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .kpi-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }

  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ════════════════════════════════════════════════════════════════
   RESPONSIVIDAD (Breakpoints obligatorios)
════════════════════════════════════════════════════════════════ */

/* Tablet (≤ 900px) */
@media (max-width: 900px) {
  .report-grid-13,
  .report-grid-2 {
    grid-template-columns: 1fr;
  }
  .report-header {
    grid-template-columns: 1fr;
  }
  .rh-right {
    display: none;
  }
  .kpi-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }
}

/* Teléfono (≤ 576px) */
@media (max-width: 576px) {
  .report-header {
    padding: 20px 18px;
  }
  .rh-project-name {
    font-size: 21px;
  }
  .panel-header,
  .panel-body {
    padding: 14px 16px;
  }
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .active-filters-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  .scroll-table-wrap {
    max-height: 240px;
  }
}

/* Teléfono pequeño (≤ 400px) */
@media (max-width: 400px) {
  .rh-project-name {
    font-size: 18px;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .donut-legend-grid {
    grid-template-columns: 1fr;
  }
}
