/* ============================================
   FinCalc Pro - Premium Financial Calculators
   Author: FinCalc Pro
   Version: 1.0
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
  --primary: #1a56db;
  --primary-dark: #1e40af;
  --primary-light: #dbeafe;
  --success: #059669;
  --success-light: #d1fae5;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --dark: #111827;
  --gray-900: #1f2937;
  --gray-800: #374151;
  --gray-700: #4b5563;
  --gray-600: #6b7280;
  --gray-500: #9ca3af;
  --gray-400: #cbd5e1;
  --gray-300: #e2e8f0;
  --gray-200: #f1f5f9;
  --gray-100: #f8fafc;
  --white: #ffffff;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 25px rgba(0,0,0,0.1), 0 10px 10px rgba(0,0,0,0.04);
  --radius: 8px;
  --radius-lg: 12px;
  --max-width: 1200px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  color: var(--dark);
  background: var(--gray-100);
  line-height: 1.7;
  min-height: 100vh;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--primary-dark); text-decoration: underline; }

/* ---------- Typography ---------- */
h1, h2, h3, h4 { line-height: 1.3; font-weight: 700; color: var(--gray-900); }
h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); margin-bottom: 1rem; }
h2 { font-size: clamp(1.4rem, 3vw, 1.8rem); margin-bottom: 0.75rem; }
h3 { font-size: clamp(1.1rem, 2vw, 1.3rem); margin-bottom: 0.5rem; }
p { margin-bottom: 1rem; }

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 32px;
  align-items: start;
}

@media (max-width: 900px) {
  .row { grid-template-columns: 1fr; }
}

/* ---------- Header ---------- */
.header {
  background: var(--white);
  border-bottom: 3px solid var(--primary);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  max-width: var(--max-width);
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  text-decoration: none;
}

.logo:hover { text-decoration: none; }

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.3rem;
}

.nav { display: flex; gap: 8px; align-items: center; }

.nav a {
  color: var(--gray-700);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
}

.nav a:hover {
  background: var(--primary-light);
  color: var(--primary);
  text-decoration: none;
}

.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 8px; }

@media (max-width: 768px) {
  .nav:not(.open) { display: none; }
  .nav.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    padding: 16px;
    border-top: 1px solid var(--gray-300);
    box-shadow: var(--shadow-lg);
  }
  .nav-toggle { display: block; }
}

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: var(--white);
  padding: 80px 20px;
  text-align: center;
}

.hero h1 {
  color: var(--white);
  font-size: clamp(2rem, 5vw, 3rem);
  max-width: 800px;
  margin: 0 auto 16px;
}

.hero p {
  font-size: 1.15rem;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto 32px;
}

.hero-search {
  display: flex;
  max-width: 500px;
  margin: 0 auto;
  gap: 8px;
}

.hero-search input {
  flex: 1;
  padding: 14px 20px;
  border: 2px solid transparent;
  border-radius: 50px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.hero-search input:focus { border-color: var(--warning); }

.hero-search button {
  padding: 14px 28px;
  background: var(--success);
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.hero-search button:hover { background: #047857; }

/* ---------- Sections ---------- */
.section {
  padding: 64px 0;
}

.section-header {
  text-align: center;
  margin-bottom: 48px;
}

.section-header h2 { margin-bottom: 8px; }
.section-header p { color: var(--gray-600); font-size: 1.05rem; }

/* ---------- Cards Grid ---------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-300);
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.card-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 16px;
}

.card-icon.blue { background: var(--primary-light); color: var(--primary); }
.card-icon.green { background: var(--success-light); color: var(--success); }
.card-icon.orange { background: var(--warning-light); color: var(--warning); }
.card-icon.red { background: var(--danger-light); color: var(--danger); }

.card h3 { font-size: 1.1rem; margin-bottom: 8px; }
.card h3 a { color: var(--gray-900); }
.card h3 a:hover { color: var(--primary); text-decoration: none; }
.card p { color: var(--gray-600); font-size: 0.9rem; margin-bottom: 16px; }

.btn {
  display: inline-block;
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn:hover { background: var(--primary-dark); text-decoration: none; color: white; }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }

/* ---------- Calculator Form ---------- */
.calc-container {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--gray-300);
  max-width: 700px;
  margin: 0 auto 32px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--gray-800);
}

.form-group label .hint {
  font-weight: 400;
  color: var(--gray-500);
  font-size: 0.8rem;
}

.input-wrapper {
  position: relative;
}

.input-prefix {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-500);
  font-weight: 600;
  font-size: 0.9rem;
  pointer-events: none;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--gray-400);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s;
  background: var(--white);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

.has-prefix { padding-left: 40px; }

.input-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 500px) {
  .input-group { grid-template-columns: 1fr; }
}

/* ---------- Results ---------- */
.results-card {
  background: linear-gradient(135deg, var(--success-light), var(--primary-light));
  border: 1px solid var(--success);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-top: 24px;
  display: none;
}

.results-card.visible { display: block; }

.results-card h3 {
  color: var(--gray-900);
  margin-bottom: 16px;
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.result-item:last-child { border-bottom: none; }

.result-label { font-weight: 500; color: var(--gray-700); }

.result-value {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--dark);
}

.result-value.highlight {
  font-size: 1.5rem;
  color: var(--success);
}

/* ---------- Chart ---------- */
.chart-container {
  margin-top: 24px;
  padding: 16px;
  background: var(--white);
  border-radius: var(--radius);
}

/* ---------- Table ---------- */
.table-wrapper {
  overflow-x: auto;
  margin-top: 24px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table th {
  background: var(--gray-900);
  color: white;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
}

table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-300);
}

table tr:nth-child(even) { background: var(--gray-100); }

/* ---------- Content ---------- */
.content-section {
  max-width: 800px;
  margin: 32px auto;
  padding: 0 20px;
}

.content-section h2 {
  margin-top: 40px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--gray-300);
}

.content-section ul, .content-section ol {
  margin: 0 0 1rem 1.5rem;
}

.content-section li {
  margin-bottom: 6px;
  color: var(--gray-800);
}

/* ---------- FAQ ---------- */
.faq-item {
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}

.faq-question {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  color: var(--gray-900);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}

.faq-question:hover { background: var(--gray-200); }

.faq-answer {
  padding: 0 20px 16px;
  color: var(--gray-700);
  display: none;
  line-height: 1.7;
}

.faq-item.open .faq-answer { display: block; }

/* ---------- Ads ---------- */
.adsbygoogle {
  display: block;
  margin: 24px auto;
  text-align: center;
  overflow: hidden;
  border-radius: var(--radius);
}

/* Prevent layout shift: reserve space for ad units */
ins.adsbygoogle[data-ad-format="auto"] {
  min-height: 90px;
}

@media (min-width: 768px) {
  ins.adsbygoogle[data-ad-format="auto"] {
    min-height: 90px;
  }
}

@media (min-width: 1024px) {
  ins.adsbygoogle[data-ad-format="auto"] {
    min-height: 120px;
  }
}

/* Fallback placeholder style (for ad units not yet loaded) */
.ad-placeholder {
  background: var(--gray-200);
  border: 2px dashed var(--gray-400);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-500);
  font-size: 0.85rem;
  text-align: center;
  margin: 24px 0;
  min-height: 90px;
}

/* ---------- Breadcrumbs ---------- */
.breadcrumbs {
  padding: 12px 0;
  font-size: 0.85rem;
  color: var(--gray-600);
}

.breadcrumbs a { color: var(--gray-600); text-decoration: none; }
.breadcrumbs a:hover { color: var(--primary); text-decoration: underline; }
.breadcrumbs span { color: var(--gray-900); font-weight: 500; }

/* ---------- Blog ---------- */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}

.blog-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-300);
  transition: transform 0.2s, box-shadow 0.2s;
}

.blog-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.blog-card-image {
  height: 180px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

.blog-card-body { padding: 20px; }

.blog-card-body h3 { font-size: 1.1rem; }
.blog-card-body h3 a { color: var(--gray-900); }
.blog-card-body h3 a:hover { color: var(--primary); text-decoration: none; }

.blog-card-body p { color: var(--gray-600); font-size: 0.88rem; }

.blog-meta {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-bottom: 10px;
}

/* ---------- Article ---------- */
.article { max-width: 750px; margin: 0 auto; }

.article h2 { margin-top: 36px; }
.article p { font-size: 1.05rem; color: var(--gray-800); line-height: 1.8; }
.article ul, .article ol { margin-bottom: 1rem; }

/* ---------- Related ---------- */
.related-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.related-links a {
  background: var(--primary-light);
  color: var(--primary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s;
}

.related-links a:hover {
  background: var(--primary);
  color: white;
  text-decoration: none;
}

/* ---------- CTA ---------- */
.cta-box {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  color: white;
  margin: 48px 0;
}

.cta-box h2 { color: white; }
.cta-box p { opacity: 0.9; font-size: 1.05rem; }
.cta-box .btn { background: var(--success); margin-top: 8px; }
.cta-box .btn:hover { background: #047857; }

/* ---------- Footer ---------- */
.footer {
  background: var(--gray-900);
  color: var(--gray-400);
  padding: 48px 0 24px;
  margin-top: 64px;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 32px;
  margin-bottom: 32px;
}

.footer-col h4 {
  color: var(--white);
  margin-bottom: 16px;
  font-size: 1rem;
}

.footer-col a {
  display: block;
  color: var(--gray-400);
  padding: 4px 0;
  font-size: 0.9rem;
}

.footer-col a:hover { color: var(--white); text-decoration: none; }

.footer-bottom {
  border-top: 1px solid var(--gray-800);
  padding-top: 24px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--gray-500);
}

/* ---------- Utilities ---------- */
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }
.hidden { display: none !important; }

/* ---------- Error state ---------- */
.form-control.error {
  border-color: var(--danger);
}

.error-msg {
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 4px;
  display: none;
}

.error-msg.visible { display: block; }

/* ---------- Print ---------- */
@media print {
  .header, .footer, .ad-placeholder, .nav { display: none; }
  body { background: white; }
}

/* ---------- Scroll to Top ---------- */
.scroll-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 50;
  transition: opacity 0.2s;
}

.scroll-top.visible { display: flex; align-items: center; justify-content: center; }
