/* TPS Retirement Calculator - scoped styles (.tps-) */

/* Base Styles */
.tps-app {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: #1f2937;
  line-height: 1.6;
  box-sizing: border-box;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

.tps-app *,
.tps-app *::before,
.tps-app *::after {
  box-sizing: border-box;
}

/* Container */
.tps-wrap {
  max-width: 1200px !important;
  width: 100% !important;
  margin: 0 auto !important;
  padding: 32px !important;
  box-sizing: border-box;
  background: #ffffff;
  border: none;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

@media (max-width: 1200px) {
  .tps-wrap {
    padding: 28px !important;
  }
}

@media (max-width: 768px) {
  .tps-wrap {
    padding: 20px !important;
    border-radius: 6px;
  }
}

/* Typography */
.tps-h1 {
  font-size: 2.25rem;
  font-weight: 700;
  margin: 0 0 12px;
  color: #111827;
  line-height: 1.2;
}

.tps-h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #111827;
}

.tps-h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 12px;
  color: #111827;
}

.tps-h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 24px 0 12px 0;
  color: #111827;
}

.tps-sub {
  margin: 0 0 24px;
  color: #4b5563;
  font-size: 1.05rem;
  line-height: 1.6;
}

.tps-section-desc {
  margin-bottom: 20px;
  font-size: 0.95rem;
  color: #6b7280;
  line-height: 1.6;
}

.tps-note {
  color: #6b7280;
  font-size: 0.9rem;
  margin-top: 12px;
  line-height: 1.6;
  word-wrap: break-word;
}

/* Cards and Sections */
.tps-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 24px;
  margin: 20px 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  width: 100%;
}

.tps-card--spaced {
  margin-top: 24px;
}

/* Contribution boxes with pastel colors */
.tps-contrib-box {
  border-radius: 10px;
  padding: 20px;
}

.tps-contrib-box--pension {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 2px solid #fbbf24;
}

.tps-contrib-box--pension strong {
  color: #92400e;
}

.tps-contrib-box--pension .tps-info-box-content {
  color: #78350f;
}

.tps-contrib-box--state {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  border: 2px solid #60a5fa;
}

.tps-contrib-box--state strong {
  color: #1e40af;
}

.tps-contrib-box--state .tps-info-box-content {
  color: #1e3a8a;
}

.tps-contrib-box--savings {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  border: 2px solid #34d399;
}

.tps-contrib-box--savings strong {
  color: #065f46;
}

.tps-contrib-box--savings .tps-info-box-content {
  color: #064e3b;
}

.tps-contrib-box--total {
  background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
  border: 2px solid #f472b6;
}

.tps-contrib-box--total strong {
  color: #831843;
}

.tps-contrib-box--total .tps-info-box-content {
  color: #701a75;
}

.tps-contrib-value {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 8px 0;
}

.tps-contrib-box--pension .tps-contrib-value {
  color: #92400e;
}

.tps-contrib-box--state .tps-contrib-value {
  color: #1e40af;
}

.tps-contrib-box--savings .tps-contrib-value {
  color: #065f46;
}

.tps-contrib-box--total .tps-contrib-value {
  color: #831843;
}

.tps-section {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 24px;
  margin: 20px 0;
  width: 100%;
  overflow: visible;
  display: flex;
  flex-direction: column;
}

.tps-section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  font-weight: 700;
  font-size: 1.35rem;
  color: #111827;
  letter-spacing: -0.02em;
  text-transform: none;
}

.tps-section-header img {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

/* Grid Layouts */
.tps-grid {
  display: grid;
  gap: 20px;
  width: 100%;
}

.tps-grid2 {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 768px) {
  .tps-grid2 {
    grid-template-columns: 1fr;
  }
}

.tps-grid2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tps-grid3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tps-grid4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tps-grid--spaced {
  margin-top: 20px;
  margin-bottom: 24px;
}

@media (max-width: 1200px) {
  .tps-grid4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .tps-grid2,
  .tps-grid3,
  .tps-grid4 {
    grid-template-columns: 1fr;
  }
}

/* Form Fields */
.tps-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.tps-field label {
  display: block;
  font-weight: 500;
  font-size: 0.95rem;
  color: #374151;
}

.tps-field input,
.tps-field select,
.tps-field textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 1rem;
  background: #ffffff;
  color: #111827;
  transition: all 0.2s;
  box-sizing: border-box;
}

.tps-field input:focus,
.tps-field select:focus,
.tps-field textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.tps-field small {
  display: block;
  color: #6b7280;
  margin-top: 4px;
  font-size: 0.875rem;
  line-height: 1.5;
}

.tps-field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.tps-field-row input[type="checkbox"] {
  width: auto;
  margin: 0;
  flex-shrink: 0;
}

.tps-field-row label {
  margin-left: 8px;
  font-weight: normal;
}

.tps-checkbox-label {
  margin-left: 8px;
  font-weight: normal;
}

/* Info Boxes */
.tps-inst {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 16px;
  font-size: 0.95rem;
  color: #1e40af;
  margin: 16px 0;
  line-height: 1.6;
  width: 100%;
}

.tps-warning {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 16px;
  font-size: 0.95rem;
  color: #991b1b;
  margin: 16px 0;
  line-height: 1.6;
  display: flex;
  align-items: start;
  gap: 10px;
  width: 100%;
}

.tps-warning img {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}

.tps-warning strong {
  font-weight: 600;
}

.tps-warning p {
  margin: 8px 0;
}

.tps-warning p:first-of-type {
  margin-top: 0;
}

.tps-warning p:last-of-type {
  margin-bottom: 0;
}

.tps-info-box {
  background: #f0f9ff;
  border-left: 4px solid #3b82f6;
  padding: 16px;
  margin: 16px 0;
  border-radius: 4px;
  width: 100%;
}

.tps-info-box--spaced {
  margin-top: 16px;
}

.tps-info-box strong {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: #1e40af;
  flex-wrap: wrap;
  font-weight: 600;
}

.tps-info-box-content {
  font-size: 0.95rem;
  color: #374151;
  line-height: 1.6;
  margin-top: 8px;
}

.tps-info-box-inner {
  font-size: 0.95rem;
  color: #374151;
  line-height: 1.6;
}

/* Buttons */
.tps-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
  width: 100%;
}

.tps-btn {
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #374151;
  border-radius: 6px;
  padding: 10px 18px;
  font-weight: 500;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s;
  white-space: nowrap;
}

.tps-btn:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.tps-btn--primary {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #ffffff;
}

.tps-btn--primary:hover {
  background: #2563eb;
  border-color: #2563eb;
}

.tps-btn--secondary {
  background: #6b7280;
  border-color: #6b7280;
  color: #ffffff;
}

.tps-btn--secondary:hover {
  background: #4b5563;
  border-color: #4b5563;
}

.tps-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
  width: 100%;
}

.tps-example-btn {
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #374151;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.tps-example-btn:hover {
  background: #f9fafb;
  border-color: #9ca3af;
  color: #111827;
}

/* KPIs and Badges */
.tps-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 24px 0;
  width: 100%;
}

.tps-kpi {
  background: #ffffff;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  min-width: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: transform 0.2s, box-shadow 0.2s;
}

.tps-kpi:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Pastel color variants for different KPI types */
.tps-kpi--pension {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-color: #fbbf24;
}

.tps-kpi--lump {
  background: linear-gradient(135deg, #ddd6fe 0%, #c4b5fd 100%);
  border-color: #a78bfa;
}

.tps-kpi--breakeven {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  border-color: #60a5fa;
}

.tps-kpi--assets {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  border-color: #34d399;
}

.tps-kpi--withdrawal {
  background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
  border-color: #f472b6;
}

.tps-kpi--used {
  background: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%);
  border-color: #fb923c;
}

.tps-kpi .k {
  font-size: 0.875rem;
  color: #4b5563;
  margin-bottom: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tps-kpi .v {
  font-size: 1.75rem;
  font-weight: 700;
  color: #111827;
  word-break: break-word;
  line-height: 1.2;
}

.tps-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 6px;
  font-weight: 600;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  font-size: 0.95rem;
  flex-wrap: wrap;
}

.tps-badge.ok {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}

.tps-badge.bad {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

/* Tables */
.tps-tablewrap {
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #ffffff;
  margin: 20px 0;
  width: 100%;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  display: block;
}

.tps-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 1000px;
  font-size: 0.9rem;
}

.tps-table th,
.tps-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tps-table th:first-child,
.tps-table td:first-child {
  text-align: left;
}

.tps-table thead th {
  background: #f9fafb;
  font-size: 0.875rem;
  color: #374151;
  position: sticky;
  top: 0;
  font-weight: 600;
  z-index: 1;
}

.tps-table tbody tr:hover {
  background: #f9fafb;
}

.tps-table td.tps-table-detail {
  font-size: 0.85rem;
  color: #6b7280;
}

.tps-sensitivity-table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
  margin: 16px 0;
  table-layout: auto;
}

.tps-sensitivity-table th,
.tps-sensitivity-table td {
  padding: 12px;
  text-align: right;
  border-bottom: 1px solid #e5e7eb;
  word-wrap: break-word;
}

.tps-sensitivity-table th {
  background: #f9fafb;
  font-weight: 600;
  font-size: 0.9rem;
}

.tps-sensitivity-table th:first-child,
.tps-sensitivity-table td:first-child {
  text-align: left;
}

.tps-sensitivity-table tbody tr:hover {
  background: #f9fafb;
}

/* Charts */
.tps-chart-container {
  position: relative;
  height: 400px;
  margin: 20px 0;
  padding: 20px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  width: 100%;
  min-height: 400px;
}

/* Lists */
.tps-insights {
  list-style: none;
  padding: 0;
  margin: 16px 0;
  width: 100%;
}

.tps-insights li {
  display: flex;
  align-items: start;
  gap: 12px;
  padding: 10px 0;
  font-size: 0.95rem;
  width: 100%;
}

.tps-insights li img {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}

.tps-notes-list {
  padding-left: 24px;
  line-height: 1.8;
  color: #4b5563;
}

/* Utilities */
.tps-hr {
  height: 1px;
  background: #e5e7eb;
  margin: 20px 0;
  border: 0;
  width: 100%;
}

.tps-separator {
  height: 1px;
  background: #e5e7eb;
  margin: 24px 0;
  border: 0;
  width: 100%;
}

.tps-flex {
  display: flex;
}

.tps-flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

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

.tps-spacing-top {
  margin-top: 20px;
}

.tps-spacing-bottom {
  margin-bottom: 20px;
}

.tps-spacing-sm {
  margin-bottom: 12px;
}

.tps-heading-icon {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  font-weight: 600;
}

/* Two Column Layout */
.tps-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
  width: 100%;
  margin: 0;
}

.tps-two-col > div {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

@media (max-width: 1200px) {
  .tps-two-col {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .tps-two-col > div {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .tps-two-col {
    gap: 16px;
  }
}

/* Mobile Optimizations */
@media (max-width: 768px) {
  .tps-wrap {
    padding: 16px !important;
  }

  .tps-h1 {
    font-size: 1.75rem;
  }

  .tps-h2 {
    font-size: 1.25rem;
  }

  .tps-h3 {
    font-size: 1.1rem;
  }

  .tps-card,
  .tps-section {
    padding: 18px;
    margin: 16px 0;
  }

  .tps-section-header {
    font-size: 1.05rem;
    margin-bottom: 16px;
  }

  .tps-grid {
    gap: 16px;
  }

  .tps-kpis {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .tps-kpi .v {
    font-size: 1.3rem;
  }

  .tps-table {
    font-size: 0.85rem;
    min-width: 800px;
  }

  .tps-sensitivity-table {
    min-width: 500px;
    font-size: 0.85rem;
  }

  .tps-table th,
  .tps-table td {
    padding: 10px 12px;
  }

  .tps-chart-container {
    height: 300px;
    min-height: 300px;
    padding: 12px;
  }

  .tps-btn,
  .tps-example-btn {
    font-size: 0.9rem;
    padding: 9px 16px;
  }

  .tps-field input,
  .tps-field select {
    padding: 9px 12px;
    font-size: 0.95rem;
  }
}

@media (max-width: 480px) {
  .tps-wrap {
    padding: 12px !important;
  }

  .tps-h1 {
    font-size: 1.5rem;
  }

  .tps-sub {
    font-size: 1rem;
  }

  .tps-card,
  .tps-section {
    padding: 16px;
    margin: 12px 0;
  }

  .tps-grid {
    gap: 14px;
  }

  .tps-table {
    min-width: 700px;
    font-size: 0.8rem;
  }

  .tps-sensitivity-table {
    min-width: 450px;
    font-size: 0.8rem;
  }

  .tps-chart-container {
    height: 250px;
    min-height: 250px;
  }
}

/* Print Styles */
@media print {
  .tps-actions,
  .tps-examples {
    display: none !important;
  }

  .tps-card {
    box-shadow: none;
    page-break-inside: avoid;
  }

  .tps-wrap {
    max-width: none;
    padding: 0;
  }

  .tps-table {
    min-width: 0;
  }

  .tps-chart-container {
    page-break-inside: avoid;
  }

  .tps-two-col {
    grid-template-columns: 1fr;
  }
}
