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

:root {
  --primary: #0ea5e9;
  --primary-hover: #0284c7;
  --primary-light: rgba(14, 165, 233, 0.1);
  --secondary: #10b981;
  --secondary-hover: #059669;
  --secondary-light: rgba(16, 185, 129, 0.1);
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-focus: #38bdf8;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Layout Container */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Navigation Header */
body > header {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 70px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-main);
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: bold;
  font-size: 1rem;
}

.nav-links {
  display: flex;
  gap: 24px;
  list-style: none;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 1rem;
  transition: var(--transition);
}

.nav-links a:hover, .nav-links a.active {
  color: var(--primary);
}

/* Hero Section */
.hero {
  text-align: center;
  padding: 40px 0 20px;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 10px;
  letter-spacing: -0.5px;
}

.hero p {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto 20px;
}

/* Ad Unit Containers */
.ad-container {
  margin: 24px auto;
  text-align: center;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 15px;
  max-width: 728px;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Calculator Grid */
.calculator-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 30px;
  margin-bottom: 40px;
}

@media (min-width: 992px) {
  .calculator-grid {
    grid-template-columns: 1.2fr 0.8fr;
  }
}

/* Cards & Styling */
.card {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 30px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.card-title, .section-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text-main);
}

/* Input Styles */
.input-group {
  margin-bottom: 24px;
}

.input-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.input-label {
  font-weight: 500;
  color: var(--text-main);
}

.input-numeric-container {
  display: flex;
  align-items: center;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  transition: var(--transition);
}

.input-numeric-container:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.input-numeric-container span {
  font-weight: 500;
  color: var(--text-muted);
  margin-right: 4px;
}

.input-numeric-container input {
  border: none;
  background: transparent;
  width: 120px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  text-align: right;
  outline: none;
}

/* Toggle Switch (Months / Years) */
.tenure-toggle-container {
  display: flex;
  background: var(--bg-page);
  border-radius: var(--radius-sm);
  padding: 4px;
  border: 1px solid var(--border);
  gap: 4px;
}

.tenure-btn {
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.tenure-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow);
}

/* Range Sliders */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  margin: 12px 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  background: var(--primary-hover);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.15);
  background: var(--primary-hover);
}

/* Outputs Cards Layout */
.results-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.result-card {
  background: var(--bg-page);
  border-radius: var(--radius-md);
  padding: 20px;
  border: 1px solid var(--border);
  text-align: center;
  transition: var(--transition);
}

.result-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.result-label {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 6px;
}

.result-val {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-main);
}

.result-card.primary-highlight {
  border-left: 5px solid var(--primary);
}

.result-card.secondary-highlight {
  border-left: 5px solid var(--secondary);
  background: linear-gradient(to right, var(--secondary-light), transparent);
}

.result-card.secondary-highlight .result-val {
  color: var(--secondary);
}

/* Pie Chart Container */
.chart-container {
  margin: 30px auto 0;
  position: relative;
  width: 100%;
  max-width: 250px;
  height: 250px;
}

/* Collapsible Amortization Table Section */
.collapsible-section {
  margin-bottom: 40px;
}

.collapsible-trigger {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
  outline: none;
}

.collapsible-trigger:hover {
  background-color: var(--bg-page);
  border-color: var(--primary);
}

.collapsible-icon {
  transition: var(--transition);
  font-size: 1.2rem;
}

.collapsible-trigger.active .collapsible-icon {
  transform: rotate(180deg);
}

.collapsible-content {
  display: none;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  padding: 24px;
  overflow-x: auto;
}

/* Amortization Table Styling */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.amortization-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.95rem;
}

.amortization-table th {
  background-color: var(--bg-page);
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-main);
  border-bottom: 2px solid var(--border);
}

.amortization-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.amortization-table tr:hover td {
  background-color: var(--bg-page);
  color: var(--text-main);
}

/* FAQ Accordion */
.faq-section {
  margin-bottom: 40px;
}

.faq-section h2 {
  font-size: 1.75rem;
  margin-bottom: 24px;
  text-align: center;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.faq-item {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: var(--transition);
}

.faq-question {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  outline: none;
}

.faq-question:hover {
  color: var(--primary);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
  background-color: #fafafa;
}

.faq-answer-content {
  padding: 0 24px 20px;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.faq-item.active .faq-answer {
  max-height: 300px; /* Safe upper bound */
}

.faq-item.active {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

/* Informative Text Sections */
.info-section {
  margin-bottom: 40px;
  line-height: 1.7;
}

.info-section h2 {
  font-size: 1.75rem;
  margin-bottom: 16px;
  color: var(--text-main);
}

.info-section p {
  color: var(--text-muted);
  margin-bottom: 16px;
}

.info-section ul {
  list-style-position: inside;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding-left: 8px;
}

.info-section li {
  margin-bottom: 8px;
}

.formula-card {
  background: linear-gradient(135deg, var(--bg-card), var(--bg-page));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin: 20px 0;
  text-align: center;
}

.formula-equation {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
}

.formula-legend {
  font-size: 0.9rem;
  color: var(--text-muted);
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-width: 400px;
  margin: 0 auto;
  text-align: left;
}

@media (min-width: 576px) {
  .formula-legend {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- Share Row & Button --- */
.share-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.btn-share {
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  font-size: 0.9rem;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
}

.btn-share:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.share-feedback {
  font-size: 0.85rem;
  color: var(--secondary);
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s ease;
  word-break: break-all;
  max-width: 100%;
}

/* --- Amortization Table Toolbar --- */
.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.view-toggle {
  display: flex;
  background: var(--bg-page);
  border-radius: var(--radius-sm);
  padding: 4px;
  border: 1px solid var(--border);
  gap: 4px;
}

.btn-csv {
  background-color: var(--secondary);
  font-size: 0.9rem;
  padding: 8px 18px;
}

.btn-csv:hover {
  background-color: var(--secondary-hover);
}

.static-page {
  padding: 40px 0 60px;
  max-width: 800px;
  margin: 0 auto;
}

.static-page h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--text-main);
  border-bottom: 3px solid var(--primary-light);
  padding-bottom: 10px;
}

.static-page h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 30px;
  margin-bottom: 14px;
  color: var(--text-main);
}

.static-page p {
  color: var(--text-muted);
  margin-bottom: 18px;
  font-size: 1.05rem;
}

.static-page ul {
  list-style-type: none;
  margin-bottom: 20px;
}

.static-page li {
  position: relative;
  padding-left: 20px;
  margin-bottom: 10px;
  color: var(--text-muted);
}

.static-page li::before {
  content: "•";
  color: var(--primary);
  font-weight: bold;
  font-size: 1.2rem;
  position: absolute;
  left: 0;
  top: -2px;
}

/* Contact Form Styling */
.contact-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 30px;
  margin-top: 30px;
  box-shadow: var(--shadow);
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--bg-page);
  outline: none;
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea.form-control {
  resize: vertical;
  min-height: 120px;
}

.btn {
  display: inline-block;
  background-color: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 28px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  text-align: center;
}

.btn:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--secondary);
}

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

/* Footer Section */
footer {
  background-color: #0f172a;
  color: #94a3b8;
  padding: 40px 0 20px;
  margin-top: auto;
  border-top: 1px solid #1e293b;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 30px;
  margin-bottom: 30px;
}

@media (min-width: 768px) {
  .footer-grid {
    grid-template-columns: 1.5fr 1fr;
  }
}

@media (min-width: 768px) {
  .footer-grid-3col {
    grid-template-columns: 1.5fr 1fr 1fr;
  }
}

.footer-brand h3 {
  color: #fff;
  font-size: 1.25rem;
  margin-bottom: 12px;
}

.footer-brand p {
  font-size: 0.9rem;
  line-height: 1.6;
}

.footer-links-col h4 {
  color: #fff;
  font-size: 1rem;
  margin-bottom: 16px;
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-links a {
  text-decoration: none;
  color: #94a3b8;
  font-size: 0.9rem;
  transition: var(--transition);
}

.footer-links a:hover {
  color: #fff;
}

.footer-bottom {
  text-align: center;
  border-top: 1px solid #1e293b;
  padding-top: 20px;
  font-size: 0.85rem;
}

/* --- 3-Column Footer Grid (expanded hub pages) --- */
@media (min-width: 768px) {
  .footer-grid-3col {
    grid-template-columns: 1.2fr 1fr 1fr;
  }
}

/* --- Calculator Cards Grid (More Calculators section) --- */
.calc-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.calc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.calc-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--primary);
  opacity: 0;
  transition: var(--transition);
}

.calc-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.calc-card:hover::before { opacity: 1; }

.calc-card-icon { font-size: 1.6rem; line-height: 1; }
.calc-card-title { font-size: 1rem; font-weight: 700; color: var(--text-main); }
.calc-card-desc { font-size: 0.875rem; color: var(--text-muted); line-height: 1.5; }

/* --- Quick-Select Loan Type Buttons --- */
.loan-type-btns {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.loan-type-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  outline: none;
}

.loan-type-btn:hover { border-color: var(--primary); color: var(--primary); }
.loan-type-btn.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }

/* --- Winner Card (Loan Comparison) --- */
.winner-card {
  border: 2px solid var(--secondary) !important;
  background: linear-gradient(to right, var(--secondary-light), transparent) !important;
  position: relative;
}

.winner-badge {
  display: inline-block;
  background: var(--secondary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- Wide Chart Container (bar charts) --- */
.chart-container-wide {
  position: relative;
  width: 100%;
  max-width: 800px;
  height: 280px;
  margin: 30px auto;
}

.calculator-card, .chart-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 30px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  margin-bottom: 30px;
}

/* --- Blog Article Styles --- */
.article-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 0 60px;
}

.article-page h1 {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 16px;
  line-height: 1.3;
}

.article-meta {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.article-page h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 36px 0 14px;
}

.article-page p {
  color: var(--text-muted);
  margin-bottom: 18px;
  font-size: 1.05rem;
  line-height: 1.8;
}

.article-page a { color: var(--primary); text-decoration: none; font-weight: 500; }
.article-page a:hover { text-decoration: underline; }

/* --- Savings Highlight Label --- */
.savings-highlight {
  display: block;
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--secondary);
}

/* --- Navigation Dropdown Menu --- */
.nav-links li {
  position: relative;
}

.dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.dropdown-toggle .arrow {
  font-size: 0.8rem;
  transition: transform 0.2s ease;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 12px;
  min-width: 440px; /* Wider for 2-column layout */
  list-style: none;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px 10px;
}

.dropdown-menu li {
  width: 100%;
}

.dropdown-menu a {
  display: block;
  padding: 8px 16px;
  color: var(--text-muted) !important;
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
  text-align: left;
  border-radius: var(--radius-sm);
}

.dropdown-menu a:hover {
  background-color: var(--primary-light);
  color: var(--primary) !important;
}

.dropdown:hover .dropdown-menu,
.dropdown:focus-within .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.dropdown:hover .dropdown-toggle .arrow,
.dropdown:focus-within .dropdown-toggle .arrow {
  transform: rotate(180deg);
}

@media (max-width: 768px) {
  .dropdown-menu {
    left: auto;
    right: 0;
    transform: translateY(10px);
    grid-template-columns: 1fr; /* Stack vertically on mobile */
    min-width: 240px;
    padding: 10px 0;
  }
  .dropdown-menu a {
    padding: 8px 20px;
  }
  .dropdown:hover .dropdown-menu,
  .dropdown:focus-within .dropdown-menu {
    transform: translateY(0);
  }
}

/* --- 4-Column Footer Grid Layout --- */
.footer-grid-4col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 30px;
  margin-bottom: 30px;
}

@media (min-width: 576px) {
  .footer-grid-4col {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 992px) {
  .footer-grid-4col {
    grid-template-columns: 1fr 1.6fr 0.9fr 0.9fr;
    gap: 40px;
  }
}

/* Calculators link grid styling inside the 4-column footer */
@media (min-width: 576px) {
  .footer-grid-4col .footer-links-col:nth-child(2) .footer-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 24px;
  }
}

/* Active dropdown item styling */
.dropdown-menu a.active {
  color: var(--primary) !important;
  font-weight: 600;
  background-color: var(--primary-light);
}

/* Active footer link styling */
.footer-links a.active {
  color: var(--primary) !important;
  font-weight: 600;
}
