/* ========================================
   Compound Calculator View
   ======================================== */

/* === View Container === */

.view--compound {
  display: none;
  flex-direction: column;
  padding: var(--space-6);
  padding-bottom: var(--space-8);
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.view--compound.view--active {
  display: flex;
}

.view--compound.view--hidden {
  display: none !important;
}

/* === Header === */

.compound-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.compound-header__left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.compound-header__icon {
  font-size: var(--text-2xl);
}

.compound-header__title {
  color: var(--text-primary);
  font-weight: var(--font-bold);
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  margin: 0;
}

.compound-header__subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* === 2-Column Layout === */

.compound-layout {
  display: flex;
  gap: var(--space-6);
  flex: 1;
  min-height: 0;
}

/* === Sidebar === */

.compound-sidebar {
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Sidebar cards */
.compound-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-lg);
}

.compound-card .card__header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.compound-card .card__icon {
  font-size: var(--text-base);
}

.compound-card .card__title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0;
}

.compound-card .label-optional {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--font-normal);
  margin-left: auto;
}

.compound-card .card__body {
  padding: var(--space-4);
}

.compound-card .input-group {
  margin-bottom: var(--space-3);
}

.compound-card .input-group:last-child {
  margin-bottom: 0;
}

.compound-card .preset-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.compound-card .preset-btn {
  padding: var(--space-2);
  font-size: var(--text-xs);
  border-width: 1px;
  border-radius: var(--border-radius);
  background: var(--bg-elevated);
}

.compound-card .preset-btn:hover {
  background: var(--bg-hover);
}

.compound-card .preset-btn.active {
  background: rgba(59, 130, 246, 0.1);
}

/* === Info Card === */

.compound-info {
  padding: var(--space-3);
  border-radius: var(--border-radius);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
}

.compound-info__text {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

.compound-info__text strong {
  color: var(--text-secondary);
}

/* === Contributions Section === */

.contribution-mode-toggle {
  margin-bottom: var(--space-3);
}

.contribution-mode-toggle .preset-btn {
  font-family: var(--font-sans);
}

/* Contribution fields - stack vertically in sidebar */
.contribution-fields-wrapper {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.contribution-fields {
  flex: 1;
}

.input-label--sm {
  font-size: var(--text-xs);
  margin-bottom: var(--space-2);
  display: block;
  color: var(--text-muted);
}

.contribution-input-row {
  display: flex;
  gap: var(--space-2);
}

.contribution-input-row .input-wrapper {
  flex: 1;
}

.contribution-input-row .input--select {
  width: 100px;
  flex-shrink: 0;
}

/* Select inputs */
.input--select {
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
}

.input--select:focus {
  outline: none;
  border-color: var(--primary);
}

/* === Main Content === */

.compound-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

/* === Table Container === */

.compound-table-container {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  overflow-x: auto;
  position: relative;
}

/* Fade gradient on right edge to indicate more content */
.compound-table-container::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 60px;
  background: linear-gradient(to right, transparent, var(--bg-base));
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.2s ease;
}

/* Hide fade when scrolled to the end */
.compound-table-container.scrolled-end::after {
  opacity: 0;
}

/* === Table === */

.compound-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
}

.compound-th,
.compound-cell {
  padding: var(--space-3) var(--space-4);
  text-align: center;
  border-bottom: 1px solid var(--border-subtle);
}

.compound-th {
  font-family: var(--font-mono);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: var(--text-xs);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}

.compound-th--year {
  text-align: center;
  position: sticky;
  left: 0;
  background: var(--bg-elevated);
  z-index: 2;
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
}

.compound-cell {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  white-space: nowrap;
}

.compound-cell--year {
  text-align: center;
  color: var(--text-primary);
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.3);
  font-weight: var(--font-medium);
  position: sticky;
  left: 0;
  background: var(--bg-surface);
  z-index: 1;
}

.compound-row {
  transition: background var(--transition-fast);
}

.compound-row:hover {
  background: var(--bg-hover);
}

.compound-row:hover .compound-cell--year {
  background: var(--bg-hover);
}

.compound-row:last-child .compound-cell {
  border-bottom: none;
}

/* === Glow Effects === */

.compound-cell--green {
  font-weight: var(--font-semibold);
  color: var(--success);
  text-shadow: 0 0 8px var(--success-glow);
}

.compound-cell--gold {
  font-weight: var(--font-semibold);
  color: var(--warning);
  text-shadow: 0 0 10px var(--warning-glow);
}

/* $100K+ values - white/bright */
.compound-cell--white {
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.3);
  color: var(--text-primary);
  font-weight: var(--font-semibold);
}

/* Growth percentage header colors with glow effects */
.compound-th.growth-10 {
  color: #94a3b8;
  text-shadow: 0 0 6px rgba(148, 163, 184, 0.4);
}
.compound-th.growth-20 {
  color: #a78bfa;
  text-shadow: 0 0 6px rgba(167, 139, 250, 0.4);
}
.compound-th.growth-30 {
  color: #818cf8;
  text-shadow: 0 0 6px rgba(129, 140, 248, 0.4);
}
.compound-th.growth-40 {
  color: #60a5fa;
  text-shadow: 0 0 6px rgba(96, 165, 250, 0.4);
}
.compound-th.growth-50 {
  color: #38bdf8;
  text-shadow: 0 0 6px rgba(56, 189, 248, 0.4);
}
.compound-th.growth-60 {
  color: #22d3ee;
  text-shadow: 0 0 6px rgba(34, 211, 238, 0.4);
}
.compound-th.growth-70 {
  color: #2dd4bf;
  text-shadow: 0 0 6px rgba(45, 212, 191, 0.4);
}
.compound-th.growth-80 {
  color: #34d399;
  text-shadow: 0 0 6px rgba(52, 211, 153, 0.4);
}
.compound-th.growth-90 {
  color: #4ade80;
  text-shadow: 0 0 6px rgba(74, 222, 128, 0.4);
}
.compound-th.growth-100 {
  color: #a3e635;
  text-shadow: 0 0 6px rgba(163, 230, 53, 0.4);
}
.compound-th.growth-150 {
  color: #facc15;
  text-shadow: 0 0 8px rgba(250, 204, 21, 0.5);
}
.compound-th.growth-200 {
  color: #fb923c;
  text-shadow: 0 0 8px rgba(251, 146, 60, 0.5);
}
.compound-th.growth-250 {
  color: #f97316;
  text-shadow: 0 0 10px rgba(249, 115, 22, 0.6);
}
.compound-th.growth-300 {
  color: #ef4444;
  text-shadow: 0 0 12px rgba(239, 68, 68, 0.7);
}

/* === Summary Stats === */

.compound-summary {
  margin-top: 0;
}

/* Add glows to match table values */
.compound-summary .stat-card--success .stat-card__value {
  text-shadow: 0 0 8px var(--success-glow);
}

.compound-summary .stat-card--warning .stat-card__value {
  text-shadow: 0 0 10px var(--warning-glow);
}

/* === Entrance Animations === */

.view--compound.view--active .compound-header {
  animation: fadeInUp 0.4s ease-out backwards;
  animation-delay: 0ms;
}

.view--compound.view--active .compound-sidebar {
  animation: fadeInUp 0.4s ease-out backwards;
  animation-delay: 80ms;
}

.view--compound.view--active .compound-table-container {
  animation: fadeInUp 0.4s ease-out backwards;
  animation-delay: 120ms;
}

.view--compound.view--active .compound-summary {
  animation: fadeInUp 0.4s ease-out backwards;
  animation-delay: 160ms;
}

/* === Mobile / Responsive === */

@media (max-width: 1024px) {
  .compound-layout {
    flex-direction: column;
  }

  .compound-sidebar {
    flex: 0 0 auto;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .compound-sidebar .compound-card {
    flex: 1;
    min-width: 250px;
  }
}

@media (max-width: 768px) {
  .view--compound {
    padding: var(--space-4);
  }

  .compound-sidebar {
    flex-direction: column;
  }

  .compound-sidebar .compound-card {
    min-width: 100%;
  }

  .compound-th,
  .compound-cell {
    padding: var(--space-2);
    font-size: var(--text-xs);
  }

  /* Simpler animations on mobile */
  .view--compound.view--active .compound-header,
  .view--compound.view--active .compound-sidebar,
  .view--compound.view--active .compound-table-container,
  .view--compound.view--active .compound-summary,
  .view--compound.view--active .compound-insights {
    animation: fadeIn 0.3s ease-out;
    animation-delay: 0ms;
  }
}

/* === Selected Column Header === */

.compound-th--selected {
  background: rgba(59, 130, 246, 0.15) !important;
  box-shadow: inset 0 -2px 0 var(--primary);
  cursor: pointer;
}

.compound-th[data-rate] {
  cursor: pointer;
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
}

.compound-th[data-rate]:hover {
  background: rgba(59, 130, 246, 0.1);
}

/* === Insights Row === */

.compound-insights {
  margin-top: var(--space-4);
  margin-bottom: var(--space-4);
}

.stats-grid--insights {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}

.view--compound.view--active .compound-insights {
  animation: fadeInUp 0.4s ease-out backwards;
  animation-delay: 200ms;
}

/* === Insight Cards (Sentence-based) === */

.insight-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-lg);
  padding: var(--space-4);
}

.insight-card__text {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--text-secondary);
}

.insight-card__text strong {
  color: var(--text-primary);
  font-weight: var(--font-semibold);
}

.insight-highlight {
  font-family: var(--font-mono);
  font-weight: var(--font-bold);
  color: var(--text-primary);
}

.insight-highlight--success {
  color: var(--success);
  text-shadow: 0 0 8px var(--success-glow);
}

.insight-highlight--warning {
  color: var(--warning);
  text-shadow: 0 0 8px var(--warning-glow);
}

/* === Responsive Insights === */

@media (max-width: 1024px) {
  .stats-grid--insights {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .compound-insights {
    margin-top: var(--space-3);
  }

  .stats-grid--insights {
    gap: var(--space-3);
  }
}
