/* ============================================
   LOAN CALCULATOR - Page-specific Styles
   Shared styles from /styles.css are inherited
   ============================================ */

/* === Loan Type Grid === */
.loan-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.loan-type-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.loan-type-option:hover {
  border-color: var(--slate-300);
  background: var(--slate-50);
}

.loan-type-option.active {
  border-color: var(--emerald-500);
  background: var(--emerald-50);
}

.loan-type-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--slate-100);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.loan-type-option.active .loan-type-icon {
  background: var(--emerald-100);
  color: var(--emerald-text);
}

.loan-type-icon svg {
  width: 16px;
  height: 16px;
}

.loan-type-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.loan-type-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.loan-type-rate {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.loan-type-option.active .loan-type-name {
  color: var(--emerald-text);
}

.loan-type-option--full {
  grid-column: 1 / -1;
}

/* === Interest Rate Input === */
.input-field--rate {
  font-size: 18px;
  padding-right: 80px;
}

.input-suffix--wide {
  min-width: 60px;
  text-align: center;
}

/* === Term Input Row === */
.term-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.term-input-row .period-toggle {
  flex-shrink: 0;
}

/* === Comparison Summary === */
.comparison-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-sm);
}

.summary-item {
  text-align: center;
}

.summary-item-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.summary-item-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.summary-item-value--green {
  color: var(--emerald-text);
}

/* === Payment Timeline Chart === */
.payment-chart-container {
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-sm);
}

.payment-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.payment-chart-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.payment-chart-legend {
  display: flex;
  gap: 12px;
}

.payment-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-secondary);
}

.payment-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.payment-legend-dot--principal {
  background: var(--emerald-500);
}

.payment-legend-dot--interest {
  background: var(--slate-300);
}

.payment-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 120px;
  padding: 0 2px;
}

.payment-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-width: 2px;
  max-width: 12px;
  border-radius: 2px 2px 0 0;
  overflow: hidden;
}

.payment-bar__interest {
  background: var(--slate-300);
  transition: height 0.3s ease;
}

.payment-bar__principal {
  background: var(--emerald-500);
  transition: height 0.3s ease;
}

.payment-chart-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
}

/* === Amortization Table === */
.amort-section {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.amort-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: inherit;
}

.amort-toggle:hover {
  background: var(--slate-50);
}

.amort-toggle-icon {
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.amort-section.open .amort-toggle-icon {
  transform: rotate(180deg);
}

.amort-table-container {
  max-height: 500px;
  overflow-y: auto;
  border-top: 1px solid var(--border-default);
}

.amort-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.amort-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.amort-table th {
  padding: 10px 16px;
  background: var(--slate-50);
  font-weight: 600;
  color: var(--text-secondary);
  text-align: right;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border-default);
}

.amort-table th:first-child {
  text-align: center;
  width: 50px;
}

.amort-table td {
  padding: 8px 16px;
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
}

.amort-table td:first-child {
  text-align: center;
  color: var(--text-muted);
  font-family: inherit;
}

.amort-table tbody tr:hover {
  background: var(--slate-50);
}

.amort-table tfoot td {
  font-weight: 700;
  background: var(--slate-50);
  border-top: 2px solid var(--border-default);
  color: var(--emerald-text);
}

.amort-show-more {
  display: block;
  width: 100%;
  padding: 12px;
  background: var(--slate-50);
  border: none;
  border-top: 1px solid var(--border-default);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--emerald-600);
  font-family: inherit;
  transition: background 0.15s ease;
}

.amort-show-more:hover {
  background: var(--slate-100);
}

/* === Card Detail Link === */
.card-detail-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  font-size: 13px;
  font-weight: 600;
  color: var(--emerald-600);
  transition: color 0.15s ease;
}

.card-detail-link svg {
  width: 14px;
  height: 14px;
}

.result-card:hover .card-detail-link {
  color: var(--emerald-700);
}

.result-card--default .card-detail-link {
  color: var(--text-muted);
}

.result-card--default:hover .card-detail-link {
  color: var(--text-secondary);
}

/* === Savings Indicator (between result cards) === */
.savings-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--emerald-50);
  border: 1px solid var(--emerald-200);
  border-radius: var(--radius-lg);
  margin-top: -8px;
  margin-bottom: 4px;
}

.savings-indicator svg {
  width: 14px;
  height: 14px;
  color: var(--emerald-600);
}

.savings-indicator span {
  font-size: 13px;
  font-weight: 600;
  color: var(--emerald-text);
}

/* === Method Badge === */
.method-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 6px;
}

.method-badge--declining {
  background: var(--emerald-50);
  color: var(--emerald-text);
}

.method-badge--annuity {
  background: var(--slate-100);
  color: var(--text-secondary);
}

/* === Responsive === */
@media (max-width: 640px) {
  .loan-type-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .loan-type-option {
    padding: 8px 10px;
    gap: 8px;
  }

  .loan-type-icon {
    width: 28px;
    height: 28px;
  }

  .loan-type-name {
    font-size: 12px;
  }

  .loan-type-rate {
    font-size: 10px;
  }

  .comparison-summary {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 16px;
  }

  .summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
  }

  .payment-chart {
    height: 80px;
  }

  .amort-table th,
  .amort-table td {
    padding: 6px 10px;
    font-size: 11px;
  }

  .amort-toggle {
    padding: 14px 18px;
    font-size: 13px;
  }
}

@media (max-width: 768px) {
  .payment-chart-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}
