/* Calculator styles: loan */

/* ====================================
  Loan Calculator - Financial Advisor Dashboard
  Two-step "Terms + Cost Analysis" design
  ==================================== */

/* Dashboard-specific layout */
.vareoncalc-loan-dashboard {
  width: 100%;
}

.loan-section {
  gap: 12px;
}

.loan-section .vareoncalc-field-row {
  margin-bottom: 0;
}

/* Loan presets (segmented control) */
.vareoncalc-loan-presets {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  margin-bottom: 12px;
  border-radius: 999px;
  background: var(--sc-input-bg, #f3f4f6);
  border: 1px solid var(--sc-card-border, #e5e7eb);
}

.vareoncalc-loan-preset {
  border: 0;
  background: transparent;
  color: var(--sc-muted-text, #6b7280);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.vareoncalc-loan-preset:hover,
.vareoncalc-loan-preset:focus-visible {
  color: var(--sc-card-text, #111827);
}

.vareoncalc-loan-preset:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.vareoncalc-loan-preset.is-active {
  background: var(--sc-card-bg, #ffffff);
  color: var(--sc-card-text, #111827);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

/* Field header (label + inline toggle) */
.vareoncalc-field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.vareoncalc-field-header label {
  margin-bottom: 0;
}

/* Term unit toggle (inline in label) */
.vareoncalc-term-units {
  display: inline-flex;
  align-items: center;
  gap: 0;
}

.vareoncalc-term-unit {
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  font-size: inherit;
  font-weight: 500;
  line-height: 1;
  color: var(--sc-muted-text, #6b7280);
  cursor: pointer;
  transition: color 0.15s ease;
}

.vareoncalc-term-unit:hover,
.vareoncalc-term-unit:focus-visible {
  color: var(--sc-card-text, #111827);
}

.vareoncalc-term-unit:focus-visible {
  outline: 2px solid var(--sc-accent, #2563eb);
  outline-offset: 2px;
  border-radius: 4px;
}

.vareoncalc-term-unit.is-active {
  font-weight: 700;
  color: var(--sc-card-text, #111827);
}

.vareoncalc-term-unit-divider {
  color: var(--sc-muted-text, #6b7280);
}

.vareoncalc-term-warning {
  margin-top: 6px;
  font-size: 12px;
  color: var(--sc-warning, #f59e0b);
}

/* Wider card for loan dashboard */
.vareoncalc-card:has(.vareoncalc-loan-dashboard) {
  max-width: 800px;
}

/* Right Panel: Cost Analysis */
.vareoncalc-loan-result {
  display: flex;
  flex-direction: column;
  background: var(--sc-input-bg, #f9fafb);
  border: 1px solid var(--sc-card-border, #e5e7eb);
  border-radius: 12px;
  overflow: hidden;
  min-height: 340px;
}

/* Placeholder state */
.vareoncalc-loan-result__placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  padding: var(--sc-card-padding);
  color: var(--sc-muted-text, #6b7280);
}

.vareoncalc-loan-result__placeholder .placeholder-icon {
  font-size: 52px;
  opacity: 0.4;
  margin-bottom: 12px;
}

.vareoncalc-loan-result__placeholder .placeholder-text {
  font-size: 14px;
  opacity: 0.7;
}

/* Results content container */
.vareoncalc-loan-result__content {
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Monthly Payment Headline */
.loan-result-headline {
  padding: var(--sc-card-padding);
  text-align: center;
  background: var(--sc-card-bg, #ffffff);
  border-bottom: 1px solid var(--sc-card-border, #e5e7eb);
}

.loan-monthly-amount {
  font-size: 48px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--sc-card-text, #111827);
  font-variant-numeric: tabular-nums;
}

.loan-monthly-label {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--sc-muted-text, #6b7280);
  margin-top: 8px;
}

/* Info Grid: Loan Details + Impact */
.loan-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px;
}

.loan-info-grid--solo {
  grid-template-columns: 1fr;
}

/* Detail Cards (shared base) */
.loan-detail-card {
  padding: var(--sc-card-padding);
  border-radius: 10px;
  border: 1px solid var(--sc-card-border, #e5e7eb);
  background: var(--sc-card-bg, #ffffff);
}

.loan-detail-card__title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sc-card-text, #111827);
  margin-bottom: 12px;
}

/* Loan Details Card */
.loan-breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  gap: 8px;
}

.loan-breakdown-row + .loan-breakdown-row {
  border-top: 1px solid var(--sc-card-border, #e5e7eb);
}

.loan-breakdown-row .breakdown-label {
  font-size: 13px;
  color: var(--sc-muted-text, #6b7280);
}

.loan-breakdown-row .breakdown-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--sc-card-text, #111827);
  font-variant-numeric: tabular-nums;
  text-align: right;
  flex-shrink: 0;
  white-space: nowrap;
}

.loan-breakdown-row--interest .breakdown-value--interest {
  color: #ea580c;
  font-weight: 700;
}

.loan-breakdown-row--total {
  padding-top: 12px;
  margin-top: 4px;
}

.loan-breakdown-row--total .breakdown-label {
  font-weight: 600;
  color: var(--sc-card-text, #111827);
}

.loan-breakdown-row--total .breakdown-value--total {
  font-size: 15px;
  font-weight: 700;
  color: var(--sc-card-text, #111827);
}

/* Impact Card (green tint) */
.loan-detail-card--impact {
  background: rgba(22, 163, 74, 0.06);
  border-color: rgba(22, 163, 74, 0.18);
  display: flex;
  flex-direction: column;
}

.loan-impact__badge {
  margin-bottom: 14px;
}

.loan-impact__badge-value {
  font-size: 13px;
  font-weight: 700;
  color: #16a34a;
}

.loan-impact__stats {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.loan-impact__stat {
  display: flex;
  align-items: center;
  gap: 10px;
}

.loan-impact__stat-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.loan-impact__stat-icon--savings {
  background: rgba(22, 163, 74, 0.12);
  color: #16a34a;
}

.loan-impact__stat-icon--time {
  background: rgba(22, 163, 74, 0.12);
  color: #16a34a;
}

.loan-impact__stat-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.loan-impact__stat-value {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  color: #16a34a;
}

.loan-impact__stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--sc-muted-text, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Cost of Money */
.loan-cost-metric {
  margin: 0 16px 12px;
  padding: var(--sc-card-padding);
  border-radius: 12px;
  background: var(--sc-card-bg, #ffffff);
  border: 1px solid var(--sc-card-border, #e5e7eb);
}

.loan-cost-metric__header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sc-muted-text, #6b7280);
  margin-bottom: 14px;
  text-align: center;
}

.loan-cost-metric__visual {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px 10px;
  align-items: center;
  justify-items: stretch;
}

.loan-cost-metric__unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.loan-cost-metric__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.loan-cost-metric__icon--borrow {
  background: #3b82f6;
  color: #ffffff;
}

.loan-cost-metric__icon--payback {
  background: #ea580c;
  color: #ffffff;
}

.loan-cost-metric__amount {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  color: var(--sc-card-text, #111827);
  font-variant-numeric: tabular-nums;
}

.loan-cost-metric__caption {
  font-size: 11px;
  font-weight: 600;
  color: var(--sc-muted-text, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: center;
}

.loan-cost-metric__arrow {
  color: var(--sc-muted-text, #6b7280);
  opacity: 0.5;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Donut Chart: Principal vs Interest */
.loan-donut {
  margin: 0 16px 16px;
  padding: var(--sc-card-padding);
  border-radius: 12px;
  background: var(--sc-card-bg, #ffffff);
  border: 1px solid var(--sc-card-border, #e5e7eb);
  overflow: hidden;
}

.loan-donut__header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sc-muted-text, #6b7280);
  margin-bottom: 16px;
  text-align: center;
}

.loan-donut__wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.loan-donut__svg {
  display: block;
  width: 180px;
  height: auto;
  max-width: 100%;
}

.loan-donut__track {
  stroke: var(--sc-card-border, #e5e7eb);
}

.loan-donut__segment {
  transition: stroke-dasharray 0.5s ease, stroke-dashoffset 0.5s ease;
}

.loan-donut__segment--principal {
  stroke: #3b82f6;
}

.loan-donut__segment--interest {
  stroke: #ea580c;
}

.loan-donut__legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 24px;
}

.loan-donut__legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.loan-donut__legend-color {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}

.loan-donut__legend-item--principal .loan-donut__legend-color {
  background: #3b82f6;
}

.loan-donut__legend-item--interest .loan-donut__legend-color {
  background: #ea580c;
}

.loan-donut__legend-label {
  color: var(--sc-muted-text, #6b7280);
  font-weight: 500;
}

.loan-donut__legend-pct {
  font-weight: 700;
  color: var(--sc-card-text, #111827);
}

/* Error display in loan result panel */
[data-role="result-error"] {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  padding: var(--sc-card-padding);
}

[data-role="result-error"] .vareoncalc-result-error {
  max-width: 280px;
}

/* Dark theme: Loan Dashboard */
.vareoncalc-root[data-theme="dark"] .vareoncalc-loan-result,
.vareoncalc-root.theme-dark .vareoncalc-loan-result {
  background: var(--sc-input-bg, #1f2937);
}

.vareoncalc-root[data-theme="dark"] .loan-result-headline,
.vareoncalc-root.theme-dark .loan-result-headline {
  background: var(--sc-card-bg, #111827);
}

.vareoncalc-root[data-theme="dark"] .loan-detail-card,
.vareoncalc-root.theme-dark .loan-detail-card {
  background: var(--sc-card-bg, #111827);
  border-color: var(--sc-card-border, #374151);
}

.vareoncalc-root[data-theme="dark"] .loan-detail-card--impact,
.vareoncalc-root.theme-dark .loan-detail-card--impact {
  background: rgba(22, 163, 74, 0.12);
  border-color: rgba(34, 197, 94, 0.35);
}

.vareoncalc-root[data-theme="dark"] .loan-cost-metric,
.vareoncalc-root.theme-dark .loan-cost-metric {
  background: var(--sc-card-bg, #111827);
  border-color: var(--sc-card-border, #374151);
}

.vareoncalc-root[data-theme="dark"] .loan-breakdown-row--interest .breakdown-value--interest,
.vareoncalc-root.theme-dark .loan-breakdown-row--interest .breakdown-value--interest {
  color: #fb923c;
}

.vareoncalc-root[data-theme="dark"] .loan-donut,
.vareoncalc-root.theme-dark .loan-donut {
  background: var(--sc-card-bg, #111827);
  border-color: var(--sc-card-border, #374151);
}

.vareoncalc-root[data-theme="dark"] .loan-donut__track,
.vareoncalc-root.theme-dark .loan-donut__track {
  stroke: var(--sc-card-border, #374151);
}

.vareoncalc-root[data-theme="dark"] .loan-cost-metric__icon--borrow,
.vareoncalc-root.theme-dark .loan-cost-metric__icon--borrow {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

.vareoncalc-root[data-theme="dark"] .loan-cost-metric__icon--payback,
.vareoncalc-root.theme-dark .loan-cost-metric__icon--payback {
  background: rgba(234, 88, 12, 0.2);
  color: #fb923c;
}

/* Responsive */
@media (max-width: 720px) {
  .vareoncalc-loan-result {
    min-height: auto;
  }

  .loan-monthly-amount {
    font-size: 40px;
  }
}

@media (max-width: 480px) {
  .loan-monthly-amount {
    font-size: 34px;
  }

  .loan-info-grid {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .loan-cost-metric {
    margin: 0 12px 12px;
  }

  .loan-donut {
    margin: 0 12px 12px;
  }
}

@media (max-width: 410px) {
  .vareoncalc-field-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .loan-info-grid {
    padding: 12px;
  }

  .loan-cost-metric {
    margin: 0 12px 12px;
  }

  .loan-cost-metric__visual {
    grid-template-columns: 1fr;
    gap: 12px;
    justify-items: center;
  }

  .loan-cost-metric__arrow {
    transform: rotate(90deg);
  }

  .loan-breakdown-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .loan-impact__stat-value {
    font-size: 16px;
  }

  .loan-donut {
    margin: 0 12px 12px;
  }
}

@media (max-width: 360px) {
  .loan-monthly-amount {
    font-size: 30px;
  }

  .loan-cost-metric {
    margin: 0 10px 10px;
  }

  .loan-donut {
    margin: 0 10px 10px;
  }
}

@container vareoncalc (max-width: 480px) {
  .loan-info-grid {
    grid-template-columns: 1fr;
  }
}

@container vareoncalc (max-width: 410px) {
  .vareoncalc-field-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .loan-info-grid {
    padding: 12px;
  }

  .loan-cost-metric {
    margin: 0 12px 12px;
  }

  .loan-cost-metric__visual {
    grid-template-columns: 1fr;
    gap: 12px;
    justify-items: center;
  }

  .loan-cost-metric__arrow {
    transform: rotate(90deg);
  }

  .loan-breakdown-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .loan-impact__stat-value {
    font-size: 16px;
  }

  .loan-donut {
    margin: 0 12px 12px;
  }
}

@container vareoncalc (max-width: 360px) {
  .loan-monthly-amount {
    font-size: 30px;
  }

  .loan-cost-metric {
    margin: 0 10px 10px;
  }

  .loan-donut {
    margin: 0 10px 10px;
  }
}
