/* styles.css - How Much Did It Cost Me */

:root {
  --color-bg: #f8f9fa;
  --color-surface: #ffffff;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-text: #1f2937;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-success: #059669;
  --color-warning: #d97706;
  --color-result: #1e40af;
  --color-legal-bg: #fef3f2;
  --color-legal-border: #dc2626;
  --color-legal-accent: #991b1b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --radius-lg: 12px;
  --max-width: 640px;
}

/* Dark mode - automatically detected from system preferences */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0f172a;
    --color-surface: #1e293b;
    --color-primary: #3b82f6;
    --color-primary-hover: #60a5fa;
    --color-text: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-border: #334155;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-result: #60a5fa;
    --color-legal-bg: #450a0a;
    --color-legal-border: #ef4444;
    --color-legal-accent: #fca5a5;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

header p {
  color: var(--color-text-muted);
  font-size: 1rem;
}

/* Stages */
.stage {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.stage.visible {
  opacity: 1;
  transform: translateY(0);
}

.stage.disabled {
  pointer-events: none;
  opacity: 0.5;
}

.stage h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stage-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--color-primary);
  color: white;
  border-radius: 50%;
  font-size: 0.875rem;
  font-weight: 600;
}

/* Form Elements */
.input-group {
  margin-bottom: 1rem;
}

.input-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper .prefix {
  position: absolute;
  left: 1rem;
  color: var(--color-text-muted);
  font-size: 1.125rem;
  pointer-events: none;
}

.input-wrapper input {
  width: 100%;
  padding: 0.875rem 1rem 0.875rem 2rem;
  font-size: 1.125rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s;
  background: var(--color-surface);
  color: var(--color-text);
}

.input-wrapper input:focus {
  border-color: var(--color-primary);
}

.input-wrapper-billions {
  position: relative;
}

.input-wrapper-billions input {
  padding-right: 5rem;
}

.input-wrapper .suffix {
  position: absolute;
  right: 1rem;
  color: var(--color-text-muted);
  font-size: 1rem;
  font-weight: 500;
  pointer-events: none;
}

.input-unit {
  font-weight: 400;
  color: var(--color-primary);
  font-size: 0.85rem;
}

.input-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.5rem;
  min-height: 1.2rem;
}

.input-hint strong {
  color: var(--color-primary);
  font-weight: 600;
}

/* Toggle Buttons (Filing Status, Input Mode) */
.toggle-group {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.toggle-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
  color: var(--color-text);
}

.toggle-btn:hover {
  border-color: var(--color-primary);
}

.toggle-btn.active {
  border-color: var(--color-primary);
  background: rgba(37, 99, 235, 0.1);
  color: var(--color-primary);
}

/* Tax Result Display */
.tax-result {
  background: rgba(37, 99, 235, 0.05);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 1rem;
  text-align: center;
}

.tax-result .amount {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
}

.tax-result .label {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* Spending Chips */
.example-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.chip {
  padding: 0.5rem 1rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s;
  color: var(--color-text);
  position: relative;
}

.chip:hover {
  background: rgba(37, 99, 235, 0.1);
  border-color: var(--color-primary);
}

.chip.selected {
  background: rgba(37, 99, 235, 0.1);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.chip.savings {
  background: var(--color-bg);
  border-color: var(--color-border);
  border-style: dashed;
  color: inherit;
}

.chip.savings:hover {
  background: rgba(5, 150, 105, 0.1);
  border-color: var(--color-success);
  border-style: solid;
  color: var(--color-success);
}

.chip.savings.selected {
  background: rgba(5, 150, 105, 0.15);
  border-color: var(--color-success);
  border-style: solid;
  color: var(--color-success);
}

/* Chip tooltips - browser native title attribute will be used */
.chip[title] {
  cursor: help;
}

/* Category Selector */
.category-grid {
  display: grid;
  gap: 0.75rem;
}

.category-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 1rem;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  color: var(--color-text);
}

.category-btn:hover {
  border-color: var(--color-primary);
}

.category-btn.selected {
  border-color: var(--color-primary);
  background: rgba(37, 99, 235, 0.05);
}

.category-btn .name {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.category-btn .examples {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.category-btn .tax-source {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  background: var(--color-bg);
  border-radius: 4px;
  color: var(--color-text-muted);
}

/* Results Stage */
.result-card {
  text-align: center;
  padding: 2rem;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.05), rgba(37, 99, 235, 0.1));
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
}

.result-card.savings {
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.05), rgba(5, 150, 105, 0.1));
}

.result-card.savings .result-amount {
  color: var(--color-success);
}

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

.result-amount {
  font-size: 3rem;
  font-weight: 700;
  color: var(--color-result);
  line-height: 1.2;
}

.result-comparison {
  font-size: 1.125rem;
  color: var(--color-text);
  margin-top: 1rem;
  font-style: italic;
}

.result-source {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  text-align: left;
}

.source-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

.source-text {
  font-size: 0.875rem;
  color: var(--color-text);
  font-weight: 500;
}

.source-text a {
  color: var(--color-primary);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.source-text a:hover {
  border-bottom-color: var(--color-primary);
}

.source-verified {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

.source-notes {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.5rem;
  font-style: italic;
  padding: 0.5rem;
  background: var(--color-bg);
  border-radius: 4px;
  border-left: 2px solid var(--color-primary);
}

/* Time Breakdown */
.time-breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.time-breakdown-item {
  background: var(--color-bg);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

.time-label {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.time-amount {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
}

.time-breakdown.savings .time-amount {
  color: var(--color-success);
}

.deficit-note,
.multi-year-note {
  background: rgba(217, 119, 6, 0.1);
  border-left: 3px solid var(--color-warning);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.multi-year-note {
  margin-top: 1rem;
}

/* Math Breakdown (Expandable) */
.math-breakdown {
  border-top: 1px solid var(--color-border);
  padding-top: 1rem;
}

.math-toggle {
  background: none;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.5rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.math-toggle:hover {
  text-decoration: underline;
}

.math-details {
  display: none;
  margin-top: 1rem;
  padding: 1rem;
  background: var(--color-bg);
  border-radius: var(--radius);
  font-size: 0.875rem;
}

.math-details.visible {
  display: block;
}

.math-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-border);
}

.math-row:last-child {
  border-bottom: none;
  font-weight: 600;
}

/* Returning User Banner */
.returning-banner {
  background: rgba(5, 150, 105, 0.1);
  border: 1px solid var(--color-success);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
}

.returning-banner button {
  background: none;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
  font-size: 0.875rem;
}

.returning-banner button:hover {
  text-decoration: underline;
}

/* Continue Button */
.continue-btn {
  width: 100%;
  padding: 1rem;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 1rem;
  transition: background 0.2s;
}

.continue-btn:hover {
  background: var(--color-primary-hover);
}

.continue-btn:disabled {
  background: var(--color-border);
  cursor: not-allowed;
}

/* Reset/Start Over */
.reset-btn {
  display: block;
  margin: 2rem auto 0;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 0.875rem;
}

.reset-btn:hover {
  color: var(--color-text);
  text-decoration: underline;
}

/* Legal Notice */
.legal-notice {
  margin-top: 2rem;
  padding: 1.5rem;
  background: var(--color-legal-bg);
  border-left: 4px solid var(--color-legal-border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  line-height: 1.6;
}

.legal-notice h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--color-text);
}

.legal-notice p {
  margin-bottom: 1rem;
  color: var(--color-text);
}

.legal-notice p:last-child {
  margin-bottom: 0;
}

.legal-notice strong {
  font-weight: 600;
  color: var(--color-legal-accent);
}

/* Disclaimers */
.disclaimers {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-align: center;
}

.disclaimers p {
  margin-bottom: 0.5rem;
}

.footer-links {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.footer-links a {
  color: var(--color-primary);
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 480px) {
  .container {
    padding: 1rem;
  }

  header h1 {
    font-size: 1.5rem;
  }

  .stage {
    padding: 1.25rem;
  }

  .result-amount {
    font-size: 2.5rem;
  }

  .toggle-group {
    flex-direction: column;
  }

  .time-breakdown {
    grid-template-columns: 1fr;
  }

  .time-amount {
    font-size: 1.25rem;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .stage {
    transition: opacity 0.1s;
    transform: none;
  }
}
