/* Retirement Planning Calculator - Scoped styles */
/* Matches hybrid-pension-calculator styling pattern */

.rpc-root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: 100% !important;
  display: block !important;
  margin: 0 auto !important;
  padding: 0 !important;
  clear: both !important;
  float: none !important;
}

.rpc-app {
  --rpc-bg: #fef7ff;
  --rpc-card: #ffffff;
  --rpc-border: #e9d5ff;
  --rpc-text: #0f172a;
  --rpc-muted: #475569;
  --rpc-primary: #9333ea;
  --rpc-primary-hover: #7e22ce;
  --rpc-success: #16a34a;
  --rpc-danger: #dc2626;
  --rpc-warn: #d97706;
  --rpc-soft: #f3e8ff;
  --rpc-table: #faf5ff;
  --rpc-pastel-blue: #e0f2fe;
  --rpc-pastel-green: #dcfce7;
  --rpc-pastel-yellow: #fef9c3;
  --rpc-pastel-pink: #fce7f3;
  --rpc-pastel-purple: #f3e8ff;
  --rpc-pastel-orange: #fff7ed;
  
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--rpc-text);
  background: var(--rpc-bg);
  border: 2px solid var(--rpc-border);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(147, 51, 234, 0.08);
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  box-sizing: border-box;
  display: block;
}

.rpc-app * { box-sizing: border-box; }

.rpc-loading {
  padding: 2rem;
  text-align: center;
  color: var(--rpc-muted);
}

/* Hero section */
.rpc-hero {
  background: linear-gradient(135deg, var(--rpc-pastel-purple), #ffffff);
  border: 2px solid var(--rpc-border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 6px 20px rgba(147, 51, 234, 0.1);
  margin-bottom: 24px;
}

.rpc-title {
  margin: 0 0 12px 0;
  line-height: 1.3;
  font-size: 28px;
  font-weight: 800;
  color: var(--rpc-text);
}

.rpc-subtitle {
  margin: 0;
  color: var(--rpc-muted);
  font-size: 15px;
  line-height: 1.6;
  font-weight: 400;
}

/* Instruction tip */
.rpc-inst {
  background: var(--rpc-soft);
  border: 2px dashed var(--rpc-border);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 14px;
  color: var(--rpc-muted);
  margin-bottom: 20px;
  text-align: center;
}

/* Cards - Row-based layout */
.rpc-card {
  background: var(--rpc-card);
  border: 2px solid var(--rpc-border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 4px 12px rgba(147, 51, 234, 0.06);
  margin-bottom: 20px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.rpc-card.profile {
  background: linear-gradient(135deg, var(--rpc-pastel-blue), #ffffff);
  border-color: #bae6fd;
}

.rpc-card.savings {
  background: linear-gradient(135deg, var(--rpc-pastel-green), #ffffff);
  border-color: #86efac;
}

.rpc-card.contributions {
  background: linear-gradient(135deg, var(--rpc-pastel-yellow), #ffffff);
  border-color: #fde047;
}

.rpc-card.assumptions {
  background: linear-gradient(135deg, var(--rpc-pastel-pink), #ffffff);
  border-color: #f9a8d4;
}

.rpc-card.needs {
  background: linear-gradient(135deg, var(--rpc-pastel-purple), #ffffff);
  border-color: #d8b4fe;
}

.rpc-card.results {
  background: linear-gradient(135deg, #ffffff, var(--rpc-soft));
  border-color: var(--rpc-primary);
  border-width: 3px;
}

/* Section titles */
.rpc-card h3 {
  margin: 0 0 16px 0;
  line-height: 1.3;
  font-size: 22px;
  font-weight: 700;
  color: var(--rpc-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Section descriptions */
.rpc-section-desc {
  font-size: 14px;
  color: var(--rpc-muted);
  line-height: 1.6;
  margin-bottom: 20px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  border-left: 4px solid var(--rpc-primary);
}

/* Grid - Row-based (single column) */
.rpc-grid {
  display: grid;
  gap: 12px;
}

.rpc-grid-2 {
  grid-template-columns: 1fr;
  gap: 16px;
}

/* Fields */
.rpc-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.rpc-field:last-child {
  margin-bottom: 0;
}

.rpc-field label {
  font-size: 14px;
  font-weight: 600;
  color: var(--rpc-text);
  margin-bottom: 4px;
}

.rpc-input {
  width: 100%;
  border: 2px solid #e9d5ff;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  background: #ffffff;
  color: var(--rpc-text);
  outline: none;
  transition: all 0.2s ease;
}

.rpc-input:focus {
  border-color: var(--rpc-primary);
  box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.1);
}

.rpc-input-money {
  text-align: left;
}

.rpc-hint {
  font-size: 13px;
  color: var(--rpc-muted);
  line-height: 1.5;
  margin-top: 4px;
  font-style: italic;
}

/* Toggle switch */
.rpc-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0;
  padding: 14px 16px;
  background: var(--rpc-soft);
  border-radius: 12px;
  border: 2px dashed var(--rpc-border);
}

.rpc-toggle input[type="checkbox"] {
  width: 48px;
  height: 24px;
  appearance: none;
  background: #cbd5e1;
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  transform: scale(1.05);
}

.rpc-toggle input[type="checkbox"]:checked {
  background: var(--rpc-primary);
}

.rpc-toggle input[type="checkbox"]::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  top: 2px;
  left: 2px;
  transition: left 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.rpc-toggle input[type="checkbox"]:checked::before {
  left: 26px;
}

.rpc-toggle-label {
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  color: var(--rpc-text);
}

/* Inline tags */
.rpc-inline {
  margin-top: 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rpc-tag {
  background: var(--rpc-soft);
  border-radius: 999px;
  padding: 6px 10px;
  border: 1px solid var(--rpc-border);
  font-size: 12px;
}

.rpc-tag-bold {
  font-weight: 700;
  color: var(--rpc-primary);
}

/* Tooltips */
.rpc-tooltip {
  position: relative;
  display: inline-block;
  cursor: help;
  margin-left: 0.25rem;
}

.rpc-tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--rpc-primary);
  color: #ffffff;
  font-size: 11px;
  line-height: 1;
  font-weight: bold;
  vertical-align: middle;
}

.rpc-tooltip-text {
  visibility: hidden;
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--rpc-text);
  color: #ffffff;
  text-align: left;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  white-space: normal;
  width: 240px;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  line-height: 1.5;
}

.rpc-tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--rpc-text);
}

.rpc-tooltip:hover .rpc-tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* Badges */
.rpc-badges {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.rpc-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 800;
  font-size: 13px;
  border: 1px solid var(--rpc-border);
  background: #ffffff;
}

.rpc-badge-success {
  border-color: rgba(22, 163, 74, 0.35);
  background: rgba(22, 163, 74, 0.08);
  color: var(--rpc-success);
}

.rpc-badge-warning {
  border-color: rgba(217, 119, 6, 0.35);
  background: rgba(217, 119, 6, 0.08);
  color: var(--rpc-warn);
}

.rpc-badge-text {
  margin: 12px 0 0 0;
  font-size: 14px;
  color: var(--rpc-text);
  line-height: 1.6;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  border-left: 4px solid var(--rpc-primary);
}

/* KPIs / Summary cards */
.rpc-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin-top: 24px;
  margin-bottom: 32px;
}

@media (max-width: 980px) {
  .rpc-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .rpc-kpis {
    grid-template-columns: 1fr;
  }
}

.rpc-kpi {
  border: 2px solid var(--rpc-border);
  border-radius: 16px;
  padding: 20px;
  background: #ffffff;
  transition: all 0.2s ease;
}

.rpc-kpi:hover {
  border-color: var(--rpc-primary);
  box-shadow: 0 4px 12px rgba(147, 51, 234, 0.1);
}

.rpc-kpi-highlight {
  border: 3px solid var(--rpc-primary);
  background: linear-gradient(135deg, var(--rpc-soft), #ffffff);
  box-shadow: 0 4px 16px rgba(147, 51, 234, 0.15);
}

.rpc-kpi-label {
  font-size: 14px;
  color: var(--rpc-muted);
  margin-bottom: 12px;
  font-weight: 600;
  text-transform: none;
}

.rpc-kpi-highlight .rpc-kpi-label {
  color: var(--rpc-primary);
  font-weight: 700;
  font-size: 15px;
}

.rpc-kpi-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--rpc-text);
  line-height: 1.2;
  margin-bottom: 8px;
}

.rpc-kpi-highlight .rpc-kpi-value {
  font-size: 32px;
  color: var(--rpc-primary);
}

.rpc-kpi-sub {
  font-size: 13px;
  color: var(--rpc-muted);
  margin-top: 8px;
  font-style: italic;
}

/* Chart section */
.rpc-chart-section {
  margin-top: 24px;
  margin-bottom: 24px;
}

.rpc-chart-wrapper {
  position: relative;
  width: 100%;
  height: 400px;
  margin-top: 20px;
  border: 2px solid var(--rpc-border);
  border-radius: 14px;
  padding: 20px;
  background: #ffffff;
  box-sizing: border-box;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.rpc-chart-canvas {
  width: 100%;
  height: 100%;
  max-width: 100%;
  display: block;
}

.rpc-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 16px;
  font-size: 13px;
  padding: 14px 16px;
  background: var(--rpc-soft);
  border-radius: 12px;
}

.rpc-chart-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.rpc-chart-legend-color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  flex-shrink: 0;
}

/* Table */
.rpc-table-wrapper {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  margin: 20px 0;
  width: 100%;
  max-width: 100%;
  border-radius: 14px;
  position: relative;
}

.rpc-table-wrapper::-webkit-scrollbar {
  height: 10px;
}

.rpc-table-wrapper::-webkit-scrollbar-track {
  background: var(--rpc-soft);
  border-radius: 5px;
}

.rpc-table-wrapper::-webkit-scrollbar-thumb {
  background: var(--rpc-primary);
  border-radius: 5px;
}

.rpc-table-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--rpc-primary-hover);
}

.rpc-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  overflow: hidden;
  border: 1px solid var(--rpc-border);
  border-radius: 14px;
  min-width: 800px;
}

.rpc-table th,
.rpc-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--rpc-border);
  text-align: right;
  white-space: nowrap;
}

.rpc-table th {
  background: var(--rpc-table);
  font-weight: 800;
  color: #0f172a;
}

.rpc-table th:first-child,
.rpc-table td:first-child {
  text-align: left;
}

.rpc-table tr:last-child td {
  border-bottom: none;
}

.rpc-table tr:nth-child(even) td {
  background: var(--rpc-soft);
}

.rpc-table tr:hover td {
  background: var(--rpc-pastel-blue);
}

/* Export/CSV section - at bottom */
.rpc-export-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 2px solid var(--rpc-border);
  text-align: center;
}

.rpc-btn-export {
  appearance: none;
  border: 2px solid var(--rpc-primary);
  background: var(--rpc-primary);
  color: #ffffff;
  padding: 14px 24px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.rpc-btn-export:hover {
  background: var(--rpc-primary-hover);
  border-color: var(--rpc-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(147, 51, 234, 0.3);
}

.rpc-btn-export:active {
  transform: translateY(0);
}

.rpc-export-help {
  margin-top: 12px;
  font-size: 13px;
  color: var(--rpc-muted);
  font-style: italic;
}

/* Additional income sources */
.rpc-income-source {
  background: #f9fafb;
  border: 2px solid var(--rpc-border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.rpc-income-source-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.rpc-income-source-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--rpc-text);
}

.rpc-btn-remove {
  background: rgba(220, 38, 38, 0.08);
  color: var(--rpc-danger);
  border: 1px solid rgba(220, 38, 38, 0.35);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
}

.rpc-btn-remove:hover {
  background: rgba(220, 38, 38, 0.15);
}

.rpc-btn-add {
  background: var(--rpc-soft);
  color: var(--rpc-primary);
  border: 2px solid var(--rpc-border);
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
  margin-top: 8px;
  transition: all 0.2s ease;
}

.rpc-btn-add:hover {
  background: var(--rpc-pastel-purple);
  border-color: var(--rpc-primary);
  transform: translateY(-1px);
}

/* Responsive */
@media (max-width: 1280px) {
  .rpc-app {
    width: 100% !important;
    max-width: 100% !important;
    padding: 16px !important;
  }
}

@media (max-width: 768px) {
  .rpc-app {
    padding: 12px !important;
    border-radius: 16px;
  }

  .rpc-title {
    font-size: 24px;
  }

  .rpc-card h3 {
    font-size: 20px;
  }

  .rpc-card {
    padding: 20px;
  }

  .rpc-chart-wrapper {
    height: 300px;
    padding: 12px;
  }

  .rpc-table-wrapper {
    font-size: 12px;
  }

  .rpc-table th,
  .rpc-table td {
    padding: 8px;
  }

  .rpc-tooltip-text {
    width: 200px;
    font-size: 12px;
    padding: 8px 12px;
  }
}

/* Print styles */
@media print {
  .rpc-app {
    box-shadow: none;
    border-radius: 0;
    border: 1px solid #000;
    max-width: 100%;
    padding: 1rem;
  }

  .rpc-root {
    color: #000000;
  }

  .rpc-table-wrapper {
    overflow: visible;
  }

  .rpc-chart-wrapper {
    display: none;
  }

  .rpc-btn-export {
    display: none;
  }

  .rpc-inst {
    display: none;
  }
}
