/* ══════════════════════════════════════════════════════════════
   FINANCEL — Insights Engine Dashboard (CSS)
   Premium dark theme, mobile-first, Design System v4 tokens
   ══════════════════════════════════════════════════════════════ */

/* ─── Container ───────────────────────────────────────────── */
.dash-card--insights-engine {
  --ie-bg: rgba(22, 27, 34, 0.75);
  --ie-border: rgba(255, 255, 255, 0.06);
  --ie-radius: 16px;
  --ie-accent: var(--gold-400, #f5c842);
  --ie-accent-soft: rgba(245, 200, 66, 0.12);
  --ie-green: #00C853;
  --ie-green-soft: rgba(0, 200, 83, 0.12);
  --ie-yellow: #FFB300;
  --ie-yellow-soft: rgba(255, 179, 0, 0.12);
  --ie-orange: #FF7043;
  --ie-orange-soft: rgba(255, 112, 67, 0.12);
  --ie-red: #F44336;
  --ie-red-soft: rgba(244, 67, 54, 0.12);
  --ie-text: rgba(255, 255, 255, 0.92);
  --ie-text-muted: rgba(255, 255, 255, 0.55);
  --ie-card-bg: rgba(255, 255, 255, 0.04);
  background: var(--ie-bg);
  border: 1px solid var(--ie-border);
  border-radius: var(--ie-radius);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* ─── Loading ─────────────────────────────────────────────── */
.ie-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  color: var(--ie-text-muted);
  font-size: 0.875rem;
}
.ie-spinner {
  width: 22px; height: 22px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--ie-accent);
  border-radius: 50%;
  animation: ieSpin 0.7s linear infinite;
}
@keyframes ieSpin { to { transform: rotate(360deg); } }

/* ─── Grid layout ─────────────────────────────────────────── */
.ie-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 768px) {
  .ie-grid { grid-template-columns: 280px 1fr; }
}

/* ─── Mensagem personalizada ──────────────────────────────── */
.ie-message {
  padding: 16px 20px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(245, 200, 66, 0.08) 0%, rgba(245, 200, 66, 0.02) 100%);
  border-left: 3px solid var(--ie-accent);
  color: var(--ie-text);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 4px;
}
.ie-message-counsel {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-style: italic;
  color: var(--ie-text-muted);
  font-size: 0.82rem;
  line-height: 1.5;
}
.ie-message-counsel-source {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  opacity: 0.6;
  font-style: normal;
}

/* ─── Health Score Ring ───────────────────────────────────── */
.ie-health-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px;
  background: var(--ie-card-bg);
  border-radius: 14px;
  border: 1px solid var(--ie-border);
}
.ie-health-ring {
  position: relative;
  width: 140px; height: 140px;
  margin-bottom: 12px;
}
.ie-health-ring svg {
  width: 100%; height: 100%;
  transform: rotate(-90deg);
}
.ie-health-ring .ring-bg {
  fill: none;
  stroke: rgba(255,255,255,0.06);
  stroke-width: 10;
}
.ie-health-ring .ring-fill {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 1.2s ease-out, stroke 0.5s;
}
.ie-health-value {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ie-health-num {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
  font-family: 'Montserrat', sans-serif;
}
.ie-health-label {
  font-size: 0.78rem;
  color: var(--ie-text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ie-health-subtitle {
  font-size: 0.82rem;
  color: var(--ie-text-muted);
  text-align: center;
  margin-bottom: 16px;
}

/* ─── Componentes do Score (barras) ──────────────────────── */
.ie-components {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ie-comp-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ie-comp-label {
  font-size: 0.75rem;
  color: var(--ie-text-muted);
  min-width: 80px;
  flex-shrink: 0;
}
.ie-comp-bar {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
}
.ie-comp-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 1s ease-out;
}
.ie-comp-score {
  font-size: 0.72rem;
  color: var(--ie-text-muted);
  min-width: 34px;
  text-align: right;
}

/* ─── Perfil Badge ────────────────────────────────────────── */
.ie-perfil-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 10px;
}
.ie-perfil-badge--poupador { background: var(--ie-green-soft); color: var(--ie-green); }
.ie-perfil-badge--equilibrado { background: var(--ie-accent-soft); color: var(--ie-accent); }
.ie-perfil-badge--ajustando { background: var(--ie-yellow-soft); color: var(--ie-yellow); }
.ie-perfil-badge--gastador { background: var(--ie-red-soft); color: var(--ie-red); }

/* ─── KPIs Grid ───────────────────────────────────────────── */
.ie-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.ie-kpi-card {
  padding: 14px 16px;
  background: var(--ie-card-bg);
  border-radius: 12px;
  border: 1px solid var(--ie-border);
}
.ie-kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.ie-kpi-label {
  font-size: 0.78rem;
  color: var(--ie-text-muted);
  font-weight: 500;
}
.ie-kpi-status {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
}
.ie-kpi-status--bom { background: var(--ie-green-soft); color: var(--ie-green); }
.ie-kpi-status--Excelente { background: var(--ie-green-soft); color: var(--ie-green); }
.ie-kpi-status--Bom { background: var(--ie-green-soft); color: var(--ie-green); }
.ie-kpi-status--regular { background: var(--ie-yellow-soft); color: var(--ie-yellow); }
.ie-kpi-status--Regular { background: var(--ie-yellow-soft); color: var(--ie-yellow); }
.ie-kpi-status--critico { background: var(--ie-red-soft); color: var(--ie-red); }
.ie-kpi-status--Atenção, .ie-kpi-status--Crítico { background: var(--ie-red-soft); color: var(--ie-red); }
.ie-kpi-value {
  font-size: 1.4rem;
  font-weight: 700;
  font-family: 'Montserrat', sans-serif;
  color: var(--ie-text);
  margin-bottom: 4px;
}
.ie-kpi-desc {
  font-size: 0.75rem;
  color: var(--ie-text-muted);
  line-height: 1.4;
}
.ie-kpi-action {
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--ie-accent);
  font-weight: 500;
}

/* ─── Insights Cards ──────────────────────────────────────── */
.ie-insights-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ie-text);
  margin: 20px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ie-insights-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ie-insight-card {
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--ie-border);
  background: var(--ie-card-bg);
  transition: border-color 0.3s;
}
.ie-insight-card:hover {
  border-color: rgba(255,255,255,0.12);
}
.ie-insight-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}
.ie-insight-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 2px;
}
.ie-insight-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ie-text);
  line-height: 1.3;
}
.ie-insight-type {
  display: inline-block;
  font-size: 0.62rem;
  padding: 1px 6px;
  border-radius: 6px;
  margin-left: 8px;
  font-weight: 600;
  text-transform: uppercase;
  vertical-align: middle;
}
.ie-insight-type--critico { background: var(--ie-red-soft); color: var(--ie-red); }
.ie-insight-type--risco { background: var(--ie-orange-soft); color: var(--ie-orange); }
.ie-insight-type--alerta { background: var(--ie-yellow-soft); color: var(--ie-yellow); }
.ie-insight-type--atencao { background: var(--ie-yellow-soft); color: var(--ie-yellow); }
.ie-insight-type--info { background: rgba(255,255,255,0.06); color: var(--ie-text-muted); }
.ie-insight-type--positivo { background: var(--ie-green-soft); color: var(--ie-green); }
.ie-insight-desc {
  font-size: 0.8rem;
  color: var(--ie-text-muted);
  line-height: 1.5;
  margin-bottom: 8px;
}
.ie-insight-action {
  font-size: 0.78rem;
  color: var(--ie-accent);
  font-weight: 500;
  line-height: 1.4;
  padding: 8px 12px;
  background: var(--ie-accent-soft);
  border-radius: 8px;
}
.ie-insight-action::before {
  content: '→ ';
}
.ie-insight-impact {
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--ie-green);
  font-weight: 500;
}
.ie-insight-counsel {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.04);
  font-size: 0.76rem;
  font-style: italic;
  color: var(--ie-text-muted);
  line-height: 1.4;
}
.ie-insight-counsel-source {
  font-size: 0.65rem;
  opacity: 0.5;
  font-style: normal;
  margin-left: 6px;
}

/* ─── Composição Gastos (mini bars) ──────────────────────── */
.ie-comp-gastos {
  display: flex;
  gap: 3px;
  height: 24px;
  border-radius: 6px;
  overflow: hidden;
  margin-top: 12px;
}
.ie-comp-gastos-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 600;
  color: #fff;
  min-width: 28px;
  transition: width 0.8s ease-out;
}
.ie-comp-gastos-seg--essencial { background: var(--ie-green); }
.ie-comp-gastos-seg--importante { background: var(--ie-yellow); }
.ie-comp-gastos-seg--superfluo { background: var(--ie-red); }
.ie-comp-gastos-seg--sem { background: rgba(255,255,255,0.12); color: var(--ie-text-muted); }

.ie-comp-gastos-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}
.ie-comp-gastos-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  color: var(--ie-text-muted);
}
.ie-comp-gastos-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ─── Regras Badge ────────────────────────────────────────── */
.ie-regras-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 16px;
}
.ie-regras-badge--alta { background: var(--ie-red-soft); color: var(--ie-red); }
.ie-regras-badge--media { background: var(--ie-yellow-soft); color: var(--ie-yellow); }
.ie-regras-badge--baixa { background: var(--ie-green-soft); color: var(--ie-green); }

/* ─── Error state ─────────────────────────────────────────── */
.ie-error {
  text-align: center;
  padding: 32px 20px;
  color: var(--ie-text-muted);
  font-size: 0.85rem;
}
.ie-error-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

/* ─── Mobile ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  .ie-kpis { grid-template-columns: 1fr; }
  .ie-health-ring { width: 120px; height: 120px; }
  .ie-health-num { font-size: 1.8rem; }
  .ie-kpi-value { font-size: 1.2rem; }
  .ie-grid { gap: 12px; }
}
