/* BuddyCalculator - Dark Luxury Financial Design System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:wght@600;700&display=swap');

/* ─── CSS Variables (Dark theme default) ─────────────────────────────────────*/
:root, [data-theme="dark"] {
  --bg-primary: #0d0d14;
  --bg-secondary: #12121e;
  --bg-card: #1a1a2e;
  --bg-card-hover: #1e1e35;
  --bg-input: #0f0f1c;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --gold: #c9a84c;
  --gold-light: #f0c040;
  --gold-glow: rgba(201,168,76,0.15);
  --blue: #3b82f6;
  --green: #10b981;
  --red: #ef4444;
  --border: rgba(201,168,76,0.15);
  --border-subtle: rgba(255,255,255,0.06);
  --shadow: 0 4px 24px rgba(0,0,0,0.5);
  --shadow-gold: 0 0 24px rgba(201,168,76,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: 0.25s ease;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --gold: #b8860b;
  --gold-light: #d4a017;
  --gold-glow: rgba(184,134,11,0.08);
  --blue: #2563eb;
  --green: #059669;
  --red: #dc2626;
  --border: rgba(184,134,11,0.2);
  --border-subtle: rgba(0,0,0,0.08);
  --shadow: 0 4px 24px rgba(0,0,0,0.1);
  --shadow-gold: 0 0 24px rgba(184,134,11,0.08);
}

/* ─── Reset & Base ────────────────────────────────────────────────────────────*/
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}
img { max-width: 100%; display: block; }
a { color: var(--gold); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--gold-light); }

/* ─── Scrollbar ──────────────────────────────────────────────────────────────*/
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 3px; }

/* ─── Typography ─────────────────────────────────────────────────────────────*/
h1, h2, h3 { font-family: 'Playfair Display', Georgia, serif; font-weight: 700; line-height: 1.2; }
h4, h5, h6 { font-weight: 600; line-height: 1.3; }
h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 3.5vw, 2.2rem); }
h3 { font-size: clamp(1.2rem, 2.5vw, 1.6rem); }
h4 { font-size: 1rem; }

/* ─── Layout ─────────────────────────────────────────────────────────────────*/
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* ─── Navigation ─────────────────────────────────────────────────────────────*/
.navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(13,13,20,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background var(--transition);
}
[data-theme="light"] .navbar { background: rgba(248,250,252,0.92); }

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.navbar-brand span { color: var(--gold); }

.navbar-actions { display: flex; align-items: center; gap: 8px; }

.lang-btn {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  transition: all var(--transition);
  font-family: inherit;
}
.lang-btn:hover, .lang-btn.active {
  background: var(--gold-glow);
  border-color: var(--gold);
  color: var(--gold);
}

.theme-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  color: var(--text-secondary);
}
.theme-btn:hover { border-color: var(--gold); background: var(--gold-glow); }

.navbar-back {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  transition: color var(--transition);
}
.navbar-back:hover { color: var(--gold); }

/* ─── Hero ───────────────────────────────────────────────────────────────────*/
.hero {
  padding: 80px 24px 64px;
  text-align: center;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(201,168,76,0.08) 0%, transparent 70%);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23c9a84c' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--gold-glow);
  border: 1px solid var(--border);
  color: var(--gold);
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 20px;
}
.hero h1 { color: var(--text-primary); margin-bottom: 8px; }
.hero h1 .brand { color: var(--gold); }
.hero-subtitle { font-size: clamp(1.1rem, 2.5vw, 1.4rem); color: var(--text-secondary); margin-bottom: 16px; font-weight: 300; }
.hero-desc { max-width: 580px; margin: 0 auto 40px; color: var(--text-muted); font-size: 0.95rem; }
.hero-stats { display: flex; justify-content: center; gap: 48px; flex-wrap: wrap; }
.hero-stat { text-align: center; }
.hero-stat-value {
  font-family: 'Playfair Display', serif;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}
.hero-stat-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; margin-top: 4px; }
.hero-cta {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 32px;
  padding: 14px 32px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
  color: #000;
  font-weight: 600;
  border-radius: 40px;
  font-size: 0.95rem;
  transition: all var(--transition);
  border: none;
  cursor: pointer;
}
.hero-cta:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(201,168,76,0.35); color: #000; }

/* ─── AdSense Placeholders ───────────────────────────────────────────────────*/
.ad-slot {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-secondary);
  border: 1px dashed var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 0 auto;
  border-radius: var(--radius-sm);
}
.ad-leaderboard { width: 100%; max-width: 728px; height: 90px; margin: 24px auto; }
.ad-sidebar { width: 300px; height: 250px; flex-shrink: 0; }
.ad-mobile { width: 100%; max-width: 320px; height: 50px; margin: 0 auto; display: none; }
@media (max-width: 768px) { .ad-mobile { display: flex; } }

/* ─── Section: Calculators ───────────────────────────────────────────────────*/
.section-calculators { padding: 0 24px 80px; }
.section-header { text-align: center; margin-bottom: 40px; }
.section-header h2 { margin-bottom: 8px; }
.section-header p { color: var(--text-muted); font-size: 0.95rem; }
.gold-line { width: 48px; height: 2px; background: var(--gold); margin: 12px auto 0; }

/* ─── Tabs ───────────────────────────────────────────────────────────────────*/
.tabs-wrapper {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.tab-nav {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-btn {
  flex: 1; min-width: 120px;
  padding: 16px 12px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  position: relative;
}
.tab-btn .tab-icon { font-size: 1.4rem; }
.tab-btn:hover { color: var(--text-secondary); background: var(--gold-glow); }
.tab-btn.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
  background: var(--gold-glow);
}

.tab-panel { display: none; padding: 32px; }
.tab-panel.active { display: block; }

/* ─── Calculator layout inside tab ──────────────────────────────────────────*/
.calc-header { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; }
.calc-icon-wrap {
  width: 56px; height: 56px;
  background: var(--gold-glow);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  flex-shrink: 0;
}
.calc-header-text h3 { color: var(--text-primary); }
.calc-header-text p { color: var(--text-muted); font-size: 0.875rem; margin-top: 2px; }

.calc-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
}
@media (max-width: 900px) { .calc-body { grid-template-columns: 1fr; } }

/* ─── Inputs Panel ───────────────────────────────────────────────────────────*/
.inputs-panel { display: flex; flex-direction: column; gap: 20px; }
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.input-row { display: flex; align-items: center; gap: 10px; }
.input-field {
  flex: 1;
  padding: 11px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
}
.input-field:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}
.input-field::placeholder { color: var(--text-muted); }
select.input-field { cursor: pointer; }

.slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border-subtle);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: var(--gold);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px var(--gold-glow);
  transition: transform var(--transition);
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
.slider::-moz-range-thumb {
  width: 16px; height: 16px;
  background: var(--gold);
  border-radius: 50%;
  border: none;
  cursor: pointer;
}
.radio-group { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-label {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.radio-label input { display: none; }
.radio-label:has(input:checked), .radio-label.checked {
  background: var(--gold-glow);
  border-color: var(--gold);
  color: var(--gold);
}

/* ─── Buttons ────────────────────────────────────────────────────────────────*/
.btn-primary {
  padding: 13px 28px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
  color: #000;
  font-weight: 700;
  font-size: 0.95rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  letter-spacing: 0.02em;
  width: 100%;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(201,168,76,0.35); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  padding: 9px 18px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  font-family: inherit;
  transition: all var(--transition);
}
.btn-secondary:hover { border-color: var(--gold); color: var(--gold); background: var(--gold-glow); }
.btn-secondary.active { border-color: var(--gold); color: var(--gold); background: var(--gold-glow); }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* ─── Results Panel ──────────────────────────────────────────────────────────*/
.results-panel {
  display: flex; flex-direction: column; gap: 20px;
  min-height: 200px;
}
.results-panel > div[id$="-results"] { display: none; }

.results-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }

.result-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  transition: all var(--transition);
}
.result-card.gold {
  background: var(--gold-glow);
  border-color: var(--border);
}
.result-card.accent {
  border-color: rgba(59,130,246,0.2);
  background: rgba(59,130,246,0.05);
}
.result-card.danger {
  border-color: rgba(239,68,68,0.3);
  background: rgba(239,68,68,0.05);
}
.result-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
.result-value { font-size: 1.3rem; font-weight: 700; color: var(--text-primary); font-family: 'Playfair Display', serif; }
.result-card.gold .result-value { color: var(--gold); }
.result-card.danger .result-value { color: var(--red); }

/* ─── Chart Canvas ───────────────────────────────────────────────────────────*/
.chart-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 16px;
  overflow: hidden;
}
.chart-wrap canvas { display: block; width: 100% !important; }

/* ─── Smart Tip ──────────────────────────────────────────────────────────────*/
.smart-tip {
  background: linear-gradient(135deg, rgba(201,168,76,0.08) 0%, rgba(201,168,76,0.04) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}
.smart-tip strong { color: var(--gold); }

/* ─── Error Message ──────────────────────────────────────────────────────────*/
.error-msg {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: #fca5a5;
  font-size: 0.875rem;
}

/* ─── Comparator ─────────────────────────────────────────────────────────────*/
.comparator-panel {
  display: none;
  margin-top: 24px;
  padding: 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
}
.comparator-panel .section-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}
.scenario-a .result-card { border-top: 2px solid var(--blue); }
.scenario-b .result-card { border-top: 2px solid var(--gold); }

/* ─── Data Tables ────────────────────────────────────────────────────────────*/
.yearly-table-wrap { overflow-x: auto; margin-top: 4px; }
.yearly-table-wrap h4 { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 10px; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.data-table th {
  background: var(--bg-secondary);
  padding: 8px 12px;
  text-align: left;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-subtle);
}
.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}
.data-table tr:hover td { background: var(--bg-card-hover); }
.data-table tr:last-child td { border-bottom: none; }

.export-row { display: flex; gap: 8px; margin-top: 8px; }

/* ─── Footer ─────────────────────────────────────────────────────────────────*/
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  padding: 48px 24px 32px;
  margin-top: 80px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 48px;
  max-width: 1200px;
  margin: 0 auto 32px;
}
@media (max-width: 768px) { .footer-grid { grid-template-columns: 1fr; gap: 32px; } }
.footer-brand { font-family: 'Playfair Display', serif; font-size: 1.3rem; font-weight: 700; color: var(--text-primary); }
.footer-brand span { color: var(--gold); }
.footer-desc { color: var(--text-muted); font-size: 0.875rem; margin-top: 10px; line-height: 1.6; }
.footer-disclaimer { font-size: 0.75rem; color: var(--text-muted); margin-top: 12px; font-style: italic; }
.footer-links h5 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 12px; }
.footer-links ul { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.footer-links a { font-size: 0.875rem; color: var(--text-secondary); transition: color var(--transition); }
.footer-links a:hover { color: var(--gold); }
.footer-bottom {
  max-width: 1200px; margin: 0 auto;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
  font-size: 0.8rem; color: var(--text-muted);
}

/* ─── Print Area / PDF Export ────────────────────────────────────────────────*/
#print-area { display: none; }
.print-header { margin-bottom: 20px; }
.print-header h1 { font-size: 1.5rem; }
@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area {
    display: block !important;
    font-family: Georgia, serif;
    color: #000;
    padding: 20px;
  }
  .result-card { border: 1px solid #ccc; padding: 12px; margin: 8px 0; display: inline-block; min-width: 150px; }
  .result-value { font-size: 1.2rem; font-weight: bold; }
  .data-table { border-collapse: collapse; width: 100%; }
  .data-table th, .data-table td { border: 1px solid #ccc; padding: 6px 10px; font-size: 0.85rem; }
  .smart-tip { border: 1px solid #daa520; padding: 10px; margin: 10px 0; }
}

/* ─── Page-specific (individual calculator pages) ────────────────────────────*/
.single-calc-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}
.single-calc-wrap .calc-body {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
}
.single-calc-wrap .calc-header { margin-bottom: 28px; }

/* ─── Animations ─────────────────────────────────────────────────────────────*/
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes countUp { from { opacity: 0; } to { opacity: 1; } }
.tab-panel.active { animation: fadeInUp 0.3s ease; }
.result-card { animation: fadeInUp 0.25s ease; }

/* ─── Responsive ─────────────────────────────────────────────────────────────*/
@media (max-width: 768px) {
  .tab-panel { padding: 20px 16px; }
  .tab-btn { min-width: 80px; padding: 12px 8px; font-size: 0.78rem; }
  .tab-btn .tab-icon { font-size: 1.2rem; }
  .hero { padding: 60px 20px 48px; }
  .hero-stats { gap: 32px; }
  .result-value { font-size: 1.1rem; }
  .ad-sidebar { display: none; }
}
@media (max-width: 480px) {
  .tab-btn span:not(.tab-icon) { display: none; }
  .tab-btn { min-width: 56px; }
  .calc-header { flex-direction: column; text-align: center; align-items: center; }
  .results-grid { grid-template-columns: 1fr 1fr; }
  .btn-row { flex-direction: column; }
}

/* ─── Utility ────────────────────────────────────────────────────────────────*/
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.text-center { text-align: center; }
.text-gold { color: var(--gold); }
.divider { height: 1px; background: var(--border-subtle); margin: 24px 0; }
