/* ------------------------------------------------------------------ */
/* Obrify Design System — Painel do Investidor (módulo 40)             */
/*                                                                      */
/* Escopado por `.obrify-theme-lab` (ver ApplicationHelper#             */
/* obrify_theme_lab?) e consome só tokens --ob-*. Regra do módulo: as   */
/* telas NÃO têm <style>, <script> nem hex — tudo vem daqui, dos         */
/* componentes ob-* já existentes ou de controllers Stimulus. Único      */
/* style="" aceito: a largura (%) dinâmica de barra de progresso.        */
/*                                                                      */
/* Quase nada é novo: cabeçalho (.ob-page-canvas), KPIs (.ob-kpi-card), */
/* tabelas (.ob-table-card), badges (.ob-badge-*), rosca               */
/* (.ob-donut-*), barra (.progress) e estado vazio (.ob-empty-state)    */
/* já existem em obrify_atividades_theme.css / obrify_dashboard_theme.css */
/* e são reaproveitados como estão. Só entra aqui o que ainda não       */
/* existia no Design System. Antes de criar uma classe nova, procure o   */
/* equivalente ob-*.                                                    */
/*                                                                      */
/* Precisa carregar depois de obrify_dashboard_theme.css — ver          */
/* _head.html.erb.                                                      */
/* ------------------------------------------------------------------ */

/* ---------- Legenda de rosca com valor ---------------------------------- */
/* A legenda existente (.ob-comp-legend) mostra contagem dentro da bolinha;
   aqui a leitura é "cor — rótulo — valor monetário", então o marcador é um
   quadrado de cor simples e o valor fica alinhado à direita. */
.obrify-theme-lab .ob-invest-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
}

.obrify-theme-lab .ob-invest-legend li {
  display: flex;
  align-items: center;
  gap: var(--ob-space-8);
  padding: var(--ob-space-8) 0;
  border-bottom: 1px solid var(--ob-divider);
  font-size: 13px;
  color: var(--ob-text-secondary);
}

.obrify-theme-lab .ob-invest-legend li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.obrify-theme-lab .ob-invest-legend-value {
  margin-left: auto;
  font-weight: 600;
  color: var(--ob-text-primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.obrify-theme-lab .ob-invest-swatch {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  border-radius: 3px;
  background-color: var(--ob-chart-gray);
}

.obrify-theme-lab .ob-invest-swatch-primary { background-color: var(--ob-primary); }
.obrify-theme-lab .ob-invest-swatch-gray    { background-color: var(--ob-chart-gray); }
.obrify-theme-lab .ob-invest-swatch-track   { background-color: var(--ob-progress-track); }

/* ---------- Gráfico de linha em card ------------------------------------ */
/* Chart.js precisa de um contêiner de altura definida (maintainAspectRatio
   desligado no chart_controller). */
.obrify-theme-lab .ob-invest-chart-box {
  position: relative;
  height: 240px;
}

/* ---------- Linha de tabela inteira clicável ---------------------------- */
.obrify-theme-lab .ob-invest-row-link {
  color: var(--ob-text-primary);
  font-weight: inherit;
  text-decoration: none;
}

.obrify-theme-lab .ob-invest-row-link:hover {
  color: var(--ob-primary);
}

/* ---------- KPIs alinhados pelo topo ------------------------------------ */
/* .ob-kpi-body centraliza o conteúdo na vertical; numa linha de KPIs em que
   só alguns cards têm barra de progresso, o rótulo dos demais descia. Aqui
   todos começam no topo, então rótulo e valor ficam na mesma altura. */
.obrify-theme-lab .ob-invest-kpi-row .ob-kpi-body {
  justify-content: flex-start;
}

/* ---------- Coluna de barra de progresso em tabela ---------------------- */
/* Largura mínima para a barra não colapsar em telas estreitas. */
.obrify-theme-lab .ob-invest-col-progress {
  min-width: 120px;
}

/* ---------- Valor de indicador em lista de métricas --------------------- */
/* Escala: valor de indicador = 13 / 600 (mesmo de .ob-meta-chip-value).
   Um <strong> cru renderiza em 700, fora da escala. */
.obrify-theme-lab .ob-invest-metric-value {
  font-weight: 600;
  color: var(--ob-text-primary);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ---------- Gerenciar painel: visibilidade para investidores ----------- */
.obrify-theme-lab .ob-invest-visibility-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 0.85fr)) minmax(220px, 1.2fr) minmax(250px, 1.45fr);
  gap: var(--ob-space-12);
  align-items: end;
}

.obrify-theme-lab .ob-invest-visibility-toggle {
  display: flex;
  align-items: center;
  gap: var(--ob-space-8);
  min-width: 0;
  min-height: 54px;
  margin: 0;
  padding: var(--ob-space-8) var(--ob-space-12);
  border: 1px solid var(--ob-border);
  border-radius: var(--ob-radius-sm);
  background: var(--ob-card-inner);
}

.obrify-theme-lab .ob-invest-visibility-toggle .form-check-input {
  flex: 0 0 auto;
  margin-top: 0;
  margin-left: 0;
}

.obrify-theme-lab .ob-invest-visibility-toggle .form-check-label {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ob-text-primary);
  font-size: 13px;
  font-weight: 600;
}

.obrify-theme-lab .ob-invest-visibility-field { min-width: 0; }

@media (max-width: 1199px) {
  .obrify-theme-lab .ob-invest-visibility-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .obrify-theme-lab .ob-invest-visibility-grid { grid-template-columns: minmax(0, 1fr); }
}

.obrify-theme-lab .ob-invest-capital-evolution { min-width: 0; margin-top: var(--ob-space-32); }
.obrify-theme-lab .ob-invest-capital-evolution .card-title { margin-bottom: var(--ob-space-16); }
.obrify-theme-lab .ob-invest-capital-legend { display: flex; flex-wrap: wrap; gap: var(--ob-space-16); margin-bottom: var(--ob-space-16); color: var(--ob-text-secondary); }
.obrify-theme-lab .ob-invest-capital-legend span { display: inline-flex; align-items: center; gap: var(--ob-space-8); }
.obrify-theme-lab .ob-invest-capital-key { width: 24px; border-top: 3px solid var(--ob-primary); }
.obrify-theme-lab .ob-invest-capital-key--projected { border-top: 2px dashed var(--ob-info); opacity: 0.8; }
.obrify-theme-lab .ob-invest-capital-key--reference { border-top: 1px solid var(--ob-text-muted); }

/* ---------- Empreendimentos: card da listagem (antes em undertakings/_styles, com hex) ---------- */
.obrify-theme-lab .ob-invest-project-card { transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease; } /* sem overflow:hidden: o menu (dropdown) nao pode ser cortado */
.obrify-theme-lab .ob-invest-project-card--selectable { cursor: pointer; }
.obrify-theme-lab .ob-invest-project-card--selectable:focus-visible { outline: 2px solid var(--ob-primary); outline-offset: 2px; }
.obrify-theme-lab .ob-invest-project-card--current { border-color: var(--ob-primary); box-shadow: 0 0 0 3px var(--ob-primary-soft); } /* mesmo destaque da obra selecionada */
.obrify-theme-lab .ob-invest-project-card:hover { transform: translateY(-2px); }
.obrify-theme-lab .ob-invest-project-media { height: 92px; margin: calc(-1 * var(--ob-space-16)) calc(-1 * var(--ob-space-16)) 0; border-bottom: 1px solid var(--ob-border); overflow: hidden; border-radius: var(--ob-radius) var(--ob-radius) 0 0; }
.obrify-theme-lab .ob-invest-project-image { width: 100%; height: 100%; object-fit: cover; display: block; }
.obrify-theme-lab .ob-invest-project-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--ob-space-12); }
.obrify-theme-lab .ob-invest-project-metrics .ob-kpi-value { font-size: 18px; line-height: 1.2; margin: var(--ob-space-4) 0 0; text-align: left; overflow-wrap: anywhere; }
.obrify-theme-lab .ob-invest-selected-action { min-height: 31px; padding-inline: var(--ob-space-12); }
@media (prefers-reduced-motion: reduce) {
  .obrify-theme-lab .ob-invest-project-card { transition: none; }
  .obrify-theme-lab .ob-invest-project-card:hover { transform: none; }
}

/* ---------- Tabelas com linha expansivel (Investimentos) ---------- */
.obrify-theme-lab .ob-invest-col-toggle { width: 40px; }
.obrify-theme-lab .ob-invest-expand-row { cursor: pointer; }
.obrify-theme-lab .ob-invest-toggle-icon { display: inline-block; transition: transform 0.2s ease-in-out; }
.obrify-theme-lab [aria-expanded="true"] .ob-invest-toggle-icon { transform: rotate(90deg); }
.obrify-theme-lab .ob-invest-details-cell { padding: var(--ob-space-12) var(--ob-space-16) var(--ob-space-16); background: var(--ob-card-inner); }
@media (prefers-reduced-motion: reduce) {
  .obrify-theme-lab .ob-invest-toggle-icon { transition: none; }
}

/* ---------- Faixa de KPIs em mini-cards (Controle de Parcelas e afins) ---------- */
.obrify-theme-lab .ob-invest-kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--ob-space-12); }
.obrify-theme-lab .ob-invest-kpi-strip .ob-kpi-value { font-size: 20px; line-height: 1.2; margin: var(--ob-space-4) 0 0; text-align: left; overflow-wrap: anywhere; }

/* ---------- Controle de Parcelas: grupos por mes ---------- */
.obrify-theme-lab .ob-invest-month + .ob-invest-month { margin-top: var(--ob-space-16); }
.obrify-theme-lab .ob-invest-month-head { display: flex; justify-content: space-between; align-items: center; gap: var(--ob-space-12); margin-bottom: var(--ob-space-8); }
.obrify-theme-lab .ob-invest-month-total { font-weight: 700; color: var(--ob-text-primary); font-variant-numeric: tabular-nums; }
.obrify-theme-lab .ob-invest-investor-name { font-weight: 600; color: var(--ob-text-primary); }
.obrify-theme-lab .ob-invest-receivable-row.status-overdue { background-color: color-mix(in srgb, var(--ob-danger) 6%, transparent); }
.obrify-theme-lab .ob-invest-receivable-row.status-cancelled { background-color: color-mix(in srgb, var(--ob-warning) 8%, transparent); }

/* ---------- Investidores (ativos e registro): lista em cards + painel de detalhes ---------- */
.obrify-theme-lab .ob-invest-header-filter { flex: 0 1 320px; min-width: 220px; }
.obrify-theme-lab .transition-layout { transition: all 0.3s ease; align-items: flex-start; gap: var(--ob-space-16); }
.obrify-theme-lab #investors-list.half { width: 50%; flex: 0 0 50%; }
@media (min-width: 992px) {
  .obrify-theme-lab #investors-list .row.two-per-row .col-xl-4 { flex: 0 0 50% !important; max-width: 50% !important; }
}
.obrify-theme-lab .investment-investors-grid .container-fluid { padding-left: 0; padding-right: 0; }
.obrify-theme-lab .ob-invest-investor-card { cursor: pointer; transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease; }
.obrify-theme-lab .ob-invest-investor-card:hover { transform: translateY(-2px); }
.obrify-theme-lab .ob-invest-investor-card.active-card { border-color: color-mix(in srgb, var(--ob-primary) 45%, var(--ob-border)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ob-primary) 10%, transparent); }
.obrify-theme-lab .ob-invest-details-pane { width: 50%; flex: 0 0 50%; padding: var(--ob-space-16); border-radius: var(--ob-radius); border: 1px solid var(--ob-border); background: var(--ob-card-inner); overflow-y: auto; }
.obrify-theme-lab .ob-invest-percent-cell { min-width: 35px; text-align: right; }
@media (max-width: 991px) {
  .obrify-theme-lab #investors-list.half, .obrify-theme-lab .ob-invest-details-pane { width: 100%; flex: 1 1 100%; }
  .obrify-theme-lab #investors-layout { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  .obrify-theme-lab .ob-invest-investor-card, .obrify-theme-lab .transition-layout { transition: none; }
  .obrify-theme-lab .ob-invest-investor-card:hover { transform: none; }
}
.obrify-theme-lab .ob-invest-view-toggle.active { background: var(--ob-primary); border-color: var(--ob-primary); color: var(--ob-text-on-primary); }
.obrify-theme-lab .ob-invest-contact-cell { max-width: 220px; }

/* ---------- Investimentos: capacidade de captacao no cabecalho de cada empreendimento ---------- */
.obrify-theme-lab .ob-invest-group-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--ob-space-12); }
.obrify-theme-lab .ob-invest-group-stats .ob-kpi-value { font-size: 18px; line-height: 1.2; margin: var(--ob-space-4) 0 0; text-align: left; overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .obrify-theme-lab .ob-invest-group-stats { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Etapas manuais do empreendimento: larguras das colunas numericas ---------- */
.obrify-theme-lab .ob-invest-stages-table .ob-stage-col-value { width: 190px; }
.obrify-theme-lab .ob-invest-stages-table .ob-stage-col-share { width: 110px; }
.obrify-theme-lab .ob-invest-stages-table .ob-stage-col-percent { width: 150px; }
.obrify-theme-lab .ob-invest-stages-table .ob-stage-col-date { width: 180px; }
.obrify-theme-lab .ob-invest-stages-table .ob-stage-col-action { width: 56px; }
.obrify-theme-lab .ob-invest-stages-table td input { min-width: 0; }
@media (max-width: 991px) {
  .obrify-theme-lab .ob-invest-stages-table { min-width: 860px; } /* rola dentro do .table-responsive no mobile */
}
