/* ============================================================
   Compound Interest Calculator - Style
   Glow UI Design System (Spotify-based dark theme)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ---------- CSS Variables ---------- */
:root {
  --bg: #121212;
  --bg-card: #181818;
  --bg-hover: #282828;
  --border: #404040;
  --text-muted: #535353;
  --text-secondary: #B3B3B3;
  --text-primary: #FFFFFF;
  --green: #1DB954;
  --green-hover: #1ed760;
  --blue: #4C5CDB;
  --red: #C0392B;
}

[data-theme="light"] {
  --bg: #FFFFFF;
  --bg-card: #F5F5F5;
  --bg-hover: #E8E8E8;
  --border: #D0D0D0;
  --text-muted: #999999;
  --text-secondary: #666666;
  --text-primary: #121212;
  --green: #1DB954;
  --green-hover: #17a347;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ---------- Global Header ---------- */
.global-header {
  background: rgba(18, 18, 18, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  height: 64px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
}

[data-theme="light"] .global-header {
  background: rgba(255, 255, 255, 0.9);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  color: var(--green);
  font-weight: 800;
  font-size: 20px;
  text-decoration: none;
  white-space: nowrap;
}

.breadcrumb {
  color: var(--text-secondary);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
}

.breadcrumb a:hover { color: var(--text-primary); }

.breadcrumb-sep { color: var(--text-muted); }

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-to-hub {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 9999px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.back-to-hub:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

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

/* ---------- 3-Column Page Layout ---------- */
.page-layout {
  display: grid;
  grid-template-columns: 180px 1fr 320px;
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 88px;
}

.sidebar--left {
  display: flex;
  justify-content: flex-end;
}

.sidebar--right {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- Ad Slots ---------- */
.ad-slot {
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.ad-slot--inline {
  margin: 24px 0;
  min-height: 100px;
  width: 100%;
}

/* ---------- Main Content ---------- */
.main-content {
  min-width: 0;
}

/* ---------- Hero ---------- */
.hero {
  margin-bottom: 24px;
}

.hero-title {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 8px;
}

.hero-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* ---------- Calculator Card ---------- */
.calculator-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 28px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}

.input-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.input-prefix-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.input-prefix-wrap:focus-within {
  border-color: var(--green);
}

.input-prefix,
.input-suffix {
  padding: 0 12px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--bg-card);
  align-self: stretch;
  display: flex;
  align-items: center;
  border-right: 1px solid var(--border);
  white-space: nowrap;
}

.input-suffix {
  border-right: none;
  border-left: 1px solid var(--border);
}

.input-prefix-wrap input,
.input-prefix-wrap select {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
}

.input-group select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s;
}

.input-group select:focus {
  border-color: var(--green);
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.btn-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-primary {
  background: var(--green);
  color: #000;
  border: none;
  border-radius: 9999px;
  padding: 12px 36px;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: var(--green-hover);
  transform: scale(1.03);
}

.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 12px 28px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

/* ---------- Results ---------- */
.results-section {
  margin-bottom: 24px;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-card--highlight {
  border-color: var(--green);
  background: rgba(29, 185, 84, 0.08);
}

.result-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.result-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.result-card--highlight .result-value {
  color: var(--green);
}

/* ---------- Comparison Bars ---------- */
.comparison-bar-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.comparison-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.comparison-spacer { flex: 1; }

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot--compound { background: var(--green); }
.legend-dot--simple { background: #4C5CDB; }
.legend-dot--contributions { background: var(--border); }

.comparison-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bar-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  width: 70px;
  flex-shrink: 0;
}

.bar-track {
  flex: 1;
  height: 10px;
  background: var(--bg-hover);
  border-radius: 9999px;
  overflow: hidden;
}

.bar {
  height: 100%;
  border-radius: 9999px;
  width: 0;
  transition: width 0.6s ease;
}

.bar--compound { background: var(--green); }
.bar--simple { background: #4C5CDB; }

.bar-amount {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  width: 90px;
  text-align: right;
  flex-shrink: 0;
}

/* ---------- Chart ---------- */
.chart-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.chart-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  min-height: 220px;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-legend {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 16px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.chart-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------- Table ---------- */
.table-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.breakdown-table thead th {
  text-align: right;
  padding: 8px 16px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.breakdown-table thead th:first-child { text-align: left; }

.breakdown-table tbody tr {
  border-bottom: 1px solid var(--bg-hover);
  transition: background 0.15s;
}

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

.breakdown-table tbody td {
  padding: 10px 16px;
  color: var(--text-secondary);
  text-align: right;
}

.breakdown-table tbody td:first-child {
  text-align: left;
  color: var(--text-primary);
  font-weight: 600;
}

.breakdown-table tbody td.cell-balance {
  color: var(--green);
  font-weight: 700;
}

.table-placeholder td {
  text-align: center !important;
  color: var(--text-muted);
  padding: 24px !important;
  font-style: italic;
}

/* ---------- Content Sections ---------- */
.content-section {
  margin-bottom: 32px;
}

.content-section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.content-section h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 20px 0 8px;
}

.content-section p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 12px;
  line-height: 1.7;
}

.content-section em {
  color: var(--text-primary);
  font-style: normal;
  font-weight: 600;
}

.content-section strong {
  color: var(--text-primary);
}

/* Formula box */
.formula-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  border-radius: 8px;
  padding: 16px 20px;
  margin: 16px 0;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.formula-box strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 12px;
  color: var(--green);
  font-family: 'Courier New', monospace;
}

.formula-legend {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.formula-legend li {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.formula-legend strong {
  color: var(--text-primary);
  display: inline;
  font-size: 0.85rem;
}

/* ---------- FAQ ---------- */
.faq-section h2 {
  /* inherits from content-section h2 */
}

.faq-item {
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
}

.faq-item:last-child { border-bottom: none; }

.faq-question {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  line-height: 1.4;
}

.faq-answer {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.7;
  margin: 0;
}

/* ---------- Cross Links ---------- */
.cross-links {
  padding: 32px 0;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.cross-links h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.cross-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.cross-link-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 16px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.2s ease;
}

.cross-link-card:hover {
  background: var(--bg-hover);
  border-color: var(--green);
  transform: translateY(-2px);
}

.cross-link-icon {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.cross-link-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.cross-link-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ---------- Global Footer ---------- */
.global-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 32px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

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

/* ---------- Responsive ---------- */

/* Tablet: hide left sidebar, keep right */
@media (max-width: 1100px) {
  .page-layout {
    grid-template-columns: 1fr 300px;
  }

  .sidebar--left {
    display: none;
  }
}

/* Mobile: single column */
@media (max-width: 768px) {
  .page-layout {
    grid-template-columns: 1fr;
    padding: 16px 12px 40px;
    gap: 16px;
  }

  .sidebar--left,
  .sidebar--right {
    display: none;
  }

  .global-header {
    padding: 0 16px;
    height: 56px;
  }

  .breadcrumb { display: none; }

  .hero-title { font-size: 1.6rem; }

  .calculator-card { padding: 20px 16px; }

  .input-grid {
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }

  .results-grid {
    grid-template-columns: 1fr 1fr;
  }

  .result-value { font-size: 1.3rem; }

  .ad-slot--inline { display: flex; }

  .cross-links-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .input-grid { grid-template-columns: 1fr; }
  .results-grid { grid-template-columns: 1fr 1fr; }
  .cross-links-grid { grid-template-columns: 1fr 1fr; }
  .btn-row { flex-direction: column; }
  .btn-primary, .btn-secondary { width: 100%; text-align: center; }
  .chart-wrap { aspect-ratio: 1 / 1; }
}
