/* Cashew Application Styles */

:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --success-color: #10b981;
  --error-color: #ef4444;
  --warning-color: #f59e0b;
  --text-color: #1f2937;
  --text-light: #6b7280;
  --border-color: #e5e7eb;
  --bg-light: #f9fafb;
  --spacing-unit: 1rem;
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text-color);
  line-height: 1.6;
  margin: 0;
  padding: 0;
  background-color: #fff;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--spacing-unit) 1.5rem;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-color);
}

header h1 {
  font-size: 2.5rem;
  margin: 0;
  color: var(--primary-color);
}

header .subtitle {
  font-size: 1.1rem;
  color: var(--text-light);
  margin-top: 0.5rem;
}

/* Form Sections */
.form-section {
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

/* Horizontal Layout for Mortgage and Overpayment Sections */
.form-sections-horizontal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

@media (max-width: 1024px) {
  .form-sections-horizontal {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
}

.form-section h2 {
  font-size: 1.5rem;
  margin-top: 0;
  margin-bottom: 1.5rem;
  color: var(--text-color);
  border-bottom: 2px solid var(--primary-color);
  padding-bottom: 0.5rem;
}

/* Form Groups */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-color);
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input[type="text"]:read-only,
input[type="number"]:read-only {
  background-color: var(--bg-light);
  cursor: not-allowed;
}

input[type="checkbox"] {
  margin-right: 0.5rem;
}

.help-text {
  display: block;
  font-size: 0.875rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

.error-message {
  display: block;
  color: var(--error-color);
  font-size: 0.875rem;
  margin-top: 0.25rem;
  min-height: 1.25rem;
}

.warning-message {
  display: block;
  color: var(--warning-color);
  font-size: 0.875rem;
  margin-top: 0.25rem;
  min-height: 1.25rem;
}

/* Form Actions */
.form-actions {
  text-align: center;
  margin: 2rem 0;
}

button[type="submit"] {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s;
  min-width: 200px;
}

button[type="submit"]:hover:not(:disabled) {
  background-color: var(--primary-hover);
}

button[type="submit"]:disabled {
  background-color: var(--text-light);
  cursor: not-allowed;
  opacity: 0.6;
}

/* Results Section */
#results-section {
  margin-top: 3rem;
  padding: 2rem;
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

#results-section h2 {
  margin-top: 0;
  color: var(--primary-color);
}

/* Charts Section */
.charts-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

/* Chart Container */
.chart-container {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  height: 400px;
  position: relative;
}

.chart-container h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--primary-color);
  font-size: 1.1rem;
  border-bottom: 2px solid var(--primary-color);
  padding-bottom: 0.5rem;
}

.chart-wrapper {
  position: relative;
  height: calc(100% - 60px);
  min-height: 300px;
}

.chart-container canvas {
  max-height: 100%;
}

/* Responsive chart layout */
@media (max-width: 768px) {
  .charts-section {
    grid-template-columns: 1fr;
  }

  .chart-container {
    height: 350px;
  }
}

.results-container {
  margin-top: 1.5rem;
}

.result-summary {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  margin-bottom: 2rem;
  text-align: center;
  border: 2px solid var(--primary-color);
}

.result-summary h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  color: var(--text-color);
  font-size: 1.2rem;
}

.result-summary .result-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
  margin: 0;
}

.result-section {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  margin-bottom: 2rem;
  border: 1px solid var(--border-color);
}

.result-section h3 {
  margin-top: 0;
  margin-bottom: 1.5rem;
  color: var(--primary-color);
  font-size: 1.3rem;
  border-bottom: 2px solid var(--primary-color);
  padding-bottom: 0.5rem;
}

.result-section h4 {
  margin-top: 1.5rem;
  margin-bottom: 1rem;
  color: var(--text-color);
  font-size: 1.1rem;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
}

.result-item {
  display: flex;
  flex-direction: column;
  padding: 1rem;
  background: var(--bg-light);
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.result-label {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.result-value {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-color);
}

.result-value.positive {
  color: var(--success-color);
}

.result-value.negative {
  color: var(--error-color);
}

/* Comparison Table */
.comparison-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  background: white;
}

.comparison-table th,
.comparison-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.comparison-table th {
  background: var(--bg-light);
  font-weight: 600;
  color: var(--text-color);
}

.comparison-table td.positive {
  color: var(--success-color);
  font-weight: 600;
}

.comparison-table td.negative {
  color: var(--error-color);
  font-weight: 600;
}

/* Payslip Table */
.payslip-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  background: white;
  font-size: 0.95rem;
}

.payslip-table th,
.payslip-table td {
  padding: 0.75rem 1rem;
  text-align: right;
  border-bottom: 1px solid var(--border-color);
}

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

.payslip-table thead th {
  background: var(--bg-light);
  font-weight: 600;
  color: var(--text-color);
  position: sticky;
  top: 0;
}

.payslip-table tbody tr:hover {
  background: var(--bg-light);
}

.payslip-table tbody tr.section-divider {
  border-top: 2px solid var(--border-color);
  background: #f9fafb;
}

.payslip-table tbody tr.section-divider td {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.payslip-table tbody tr.sub-item td:first-child {
  padding-left: 2rem;
  font-size: 0.9rem;
  color: var(--text-light);
}

.payslip-table tbody tr.highlight-row {
  background: #eff6ff;
  border-top: 2px solid var(--primary-color);
  border-bottom: 2px solid var(--primary-color);
}

.payslip-table tbody tr.highlight-row td {
  padding-top: 1rem;
  padding-bottom: 1rem;
  font-size: 1.05rem;
}

.break-even {
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--bg-light);
  border-left: 4px solid var(--primary-color);
  border-radius: 4px;
  font-style: italic;
  color: var(--text-light);
}

/* Recommendation Box */
.recommendation-box {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 2rem;
  border-radius: 8px;
  margin-bottom: 2rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.recommendation-box h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  color: white;
  border-bottom: 2px solid rgba(255, 255, 255, 0.3);
  padding-bottom: 0.5rem;
}

.recommendation-box p {
  margin: 0;
  line-height: 1.8;
  font-size: 1.05rem;
}

/* Monte Carlo Scenarios */
.monte-carlo-scenarios {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--bg-light);
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.scenarios-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.scenario {
  padding: 1rem;
  border-radius: 6px;
  border: 2px solid var(--border-color);
}

.scenario.optimistic {
  background: #ecfdf5;
  border-color: var(--success-color);
}

.scenario.realistic {
  background: #eff6ff;
  border-color: var(--primary-color);
}

.scenario.pessimistic {
  background: #fef2f2;
  border-color: var(--error-color);
}

.scenario strong {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-color);
}

.scenario span {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-color);
}

/* Disclaimer */
.disclaimer {
  margin-top: 3rem;
  padding: 1rem;
  background-color: #fef3c7;
  border-left: 4px solid var(--warning-color);
  border-radius: 4px;
}

.disclaimer p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-color);
}

/* Accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Sliders */
input[type="range"] {
  width: 100%;
  height: 8px;
  border-radius: 5px;
  background: #e5e7eb; /* Visible gray track */
  outline: none;
  -webkit-appearance: none;
  margin: 1rem 0;
  position: relative;
}

/* Track/Rail - visible background for slider */
input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 8px;
  background: #e5e7eb; /* Light gray track */
  border-radius: 5px;
  border: 1px solid #d1d5db;
}

input[type="range"]::-moz-range-track {
  width: 100%;
  height: 8px;
  background: #e5e7eb; /* Light gray track */
  border-radius: 5px;
  border: 1px solid #d1d5db;
}

/* Progress/Fill - shows portion before thumb */
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
  border: 3px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 2;
  margin-top: -7px;
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
  border: 3px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 2;
}

/* Hover state for better visibility */
input[type="range"]:hover::-webkit-slider-thumb {
  background: var(--primary-hover);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
  transform: scale(1.1);
}

input[type="range"]:hover::-moz-range-thumb {
  background: var(--primary-hover);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
  transform: scale(1.1);
}

/* Focus state */
input[type="range"]:focus {
  outline: none;
}

input[type="range"]:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2);
}

input[type="range"]:focus::-moz-range-thumb {
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  color: var(--text-light);
  margin-top: -0.5rem;
}

.button-secondary {
  background-color: var(--text-light);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.button-secondary:hover {
  background-color: var(--text-color);
}

/* Taxable Investments Section */
.investment-row {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.investment-row-content {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.button-remove {
  background-color: var(--error-color);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.button-remove:hover {
  background-color: #dc2626;
}

.investment-preview {
  font-size: 0.875rem;
  color: var(--text-light);
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: var(--spacing-unit);
  }

  header h1 {
    font-size: 2rem;
  }

  .form-section {
    padding: 1rem;
  }

  button[type="submit"] {
    width: 100%;
  }
}
