/* =============================================================================
   Valoris Financiero RC15 — Plan de Distribución de Capital
   Bloque de estilos: .capital-plan-*
   Para agregar al final de: public/css/styles.css
   Autor: Claude (Agente Frontend/UX)
   Instrucción para Codex: copiar este bloque al final de styles.css.
   No rompe ningún selector existente; todos los nombres están prefijados cp-*
   o capital-plan-*.
   ============================================================================= */

/* ── Aviso contable ──────────────────────────────────────────────────────── */
.capital-plan-disclaimer {
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.capital-plan-over-alert {
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.6;
}

/* ── KPI grid ────────────────────────────────────────────────────────────── */
.capital-plan-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.capital-plan-kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.capital-plan-kpi:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}

/* Acento de color por tipo */
.capital-plan-kpi.cp-kpi-blue  { border-top: 3px solid #3b82f6; }
.capital-plan-kpi.cp-kpi-yellow { border-top: 3px solid #f59e0b; }
.capital-plan-kpi.cp-kpi-green  { border-top: 3px solid #22c55e; }
.capital-plan-kpi.cp-kpi-teal   { border-top: 3px solid #14b8a6; }
.capital-plan-kpi.cp-kpi-red    { border-top: 3px solid #ef4444; }

.cp-kpi-icon {
  font-size: 18px;
  margin-bottom: 2px;
}

.cp-kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cp-kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.cp-kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Barra de progreso ───────────────────────────────────────────────────── */
.capital-plan-progress-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.capital-plan-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.cp-prog-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cp-prog-pct {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.cp-prog-pct.cp-prog-over {
  color: var(--danger);
}

.capital-plan-progress-track {
  height: 10px;
  background: var(--border);
  border-radius: 99px;
  overflow-x: auto;
  margin-bottom: 8px;
}

.capital-plan-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.4s ease;
  max-width: 100%;
}

.capital-plan-progress-bar.cp-bar-over {
  background: var(--danger);
}

.cp-prog-legend {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
}

/* ── Secciones ───────────────────────────────────────────────────────────── */
.capital-plan-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
}

.capital-plan-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.capital-plan-section-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

/* ── Tabla ───────────────────────────────────────────────────────────────── */
.capital-plan-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.capital-plan-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.capital-plan-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}

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

.capital-plan-table tbody tr:hover {
  background: rgba(255,255,255,0.025);
}

.cp-item-name {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
  font-size: 13px;
}

.cp-item-modulo {
  font-size: 11px;
  font-weight: 500;
}

.cp-td-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.cp-td-pct {
  min-width: 140px;
}

.cp-inline-bar-wrap {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  margin-bottom: 4px;
  overflow: hidden;
  width: 100%;
}

.cp-inline-bar {
  height: 100%;
  border-radius: 99px;
  transition: width 0.3s ease;
}

.cp-pct-text {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.cp-td-notas {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Botones de fila ─────────────────────────────────────────────────────── */
.cp-row-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  white-space: nowrap;
}

/* ── Estado vacío ────────────────────────────────────────────────────────── */
.capital-plan-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.cp-empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.6;
}

.capital-plan-empty h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
}

.capital-plan-empty p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 20px;
  max-width: 340px;
  line-height: 1.6;
}

/* ── Gráfico de barras horizontales ──────────────────────────────────────── */
.capital-plan-chart {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cp-chart-row {
  display: grid;
  grid-template-columns: 160px 1fr 160px;
  align-items: center;
  gap: 12px;
}

.cp-chart-lbl {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cp-chart-track {
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

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

.cp-chart-val {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.cp-chart-pct {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 11px;
  margin-left: 4px;
}

/* ── Modales — piezas específicas de Capital Plan ────────────────────────── */
.capital-plan-readonly {
  background: var(--bg);
  color: var(--text-muted);
  cursor: default;
  user-select: none;
}

.capital-plan-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Modal redistribuir: box origen ─────────────────────────────────────── */
.capital-plan-redist-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.cp-redist-dir {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: rgba(59,130,246,0.12);
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.cp-redist-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.cp-redist-amount {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── Responsive: móvil ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .capital-plan-kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .cp-kpi-value {
    font-size: 18px;
  }

  .capital-plan-table {
    font-size: 12px;
  }

  /* En móvil: ocultar columnas de menor prioridad */
  .capital-plan-table th:nth-child(3),
  .capital-plan-table td:nth-child(3),
  .capital-plan-table th:nth-child(5),
  .capital-plan-table td:nth-child(5) {
    display: none;
  }

  .cp-row-actions {
    flex-direction: column;
    gap: 4px;
  }

  .cp-chart-row {
    grid-template-columns: 100px 1fr 110px;
    gap: 8px;
  }

  .capital-plan-form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .capital-plan-kpi-grid {
    grid-template-columns: 1fr;
  }

  .capital-plan-table th:nth-child(4),
  .capital-plan-table td:nth-child(4) {
    display: none;
  }

  .cp-chart-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .cp-chart-val {
    text-align: left;
  }
}
