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

:root {
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  
  /* Light Theme Tokens */
  --bg-primary: #f8fafc;
  --bg-card: #ffffff;
  --bg-nav: rgba(255, 255, 255, 0.8);
  --border-color: #cbd5e1;
  --border-light: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;
  --accent: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] {
  /* Dark Theme Tokens */
  --bg-primary: #030712;
  --bg-card: #0b0f19;
  --bg-nav: rgba(3, 7, 18, 0.8);
  --border-color: #1e293b;
  --border-light: #111827;
  --text-primary: #f9fafb;
  --text-secondary: #cbd5e1;
  --text-muted: #9ca3af;
  --primary: #818cf8;
  --primary-hover: #6366f1;
  --primary-light: #1e1b4b;
  --accent: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s, color 0.3s;
}

/* Header & Navigation */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background-color: var(--bg-nav);
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.3s, border-color 0.3s;
}
.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--primary);
  background: linear-gradient(135deg, var(--primary) 0%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.logo-icon {
  background: linear-gradient(135deg, var(--primary) 0%, #a855f7 100%);
  color: white;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  -webkit-text-fill-color: white;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.nav-link {
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  border-radius: 0.75rem;
  transition: all 0.2s;
}
.nav-link:hover, .nav-link.active {
  color: var(--primary);
  background-color: var(--primary-light);
}

/* Mobile Menu Toggle Button */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 24px;
  height: 18px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 100;
}
.menu-toggle .bar {
  width: 24px;
  height: 2px;
  background-color: var(--text-primary);
  border-radius: 2px;
  transition: all 0.3s ease;
}

/* Main Layout */
main {
  flex-grow: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

/* Footer */
footer {
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-card);
  padding: 3rem 1.5rem 1.5rem;
  margin-top: auto;
}
.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 3rem;
  margin-bottom: 2rem;
}
.footer-info p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 1rem;
  max-width: 24rem;
}
.footer-column h3 {
  font-family: var(--font-heading);
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1rem;
  letter-spacing: 0.05em;
}
.footer-column ul {
  list-style: none;
}
.footer-column li {
  margin-bottom: 0.75rem;
}
.footer-column a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.2s;
}
.footer-column a:hover {
  color: var(--primary);
}
.disclaimer-banner {
  background-color: rgba(245, 158, 11, 0.05);
  border: 1px solid rgba(245, 158, 11, 0.2);
  color: var(--warning);
  padding: 1rem;
  border-radius: 0.75rem;
  font-size: 0.75rem;
  line-height: 1.6;
  margin-bottom: 2rem;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}
.copyright-bar {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-light);
  padding-top: 1.5rem;
}

/* Hero Section */
.hero {
  text-align: center;
  padding: 4rem 1.5rem;
  background-color: #0f172a;
  color: white;
  border-radius: 2rem;
  margin-bottom: 3rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.hero h1 {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  font-weight: 900;
  line-height: 1.2;
  margin-bottom: 1rem;
}
.hero h1 span {
  background: linear-gradient(135deg, #a5b4fc 0%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p {
  color: #94a3b8;
  font-size: 1rem;
  max-width: 40rem;
  margin: 0 auto 2rem;
}
.search-container {
  max-width: 28rem;
  margin: 0 auto;
  position: relative;
}
.search-input {
  width: 100%;
  padding: 1rem 1rem 1rem 3rem;
  border-radius: 1rem;
  border: 1px solid #334155;
  background-color: #1e293b;
  color: white;
  font-size: 1rem;
  outline: none;
}
.search-input:focus {
  border-color: #818cf8;
}

/* Category Grid & Cards */
.category-section {
  margin-bottom: 3rem;
}
.category-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}
.category-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  margin: 0;
}
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}
.calc-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 1.25rem;
  padding: 1.5rem;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.calc-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}
.calc-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}
.calc-card-title {
  font-family: var(--font-heading);
  font-size: 1.125rem;
  font-weight: 700;
}
.calc-card-icon {
  background-color: var(--primary-light);
  color: var(--primary);
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.calc-card-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 1.5rem;
}
.calc-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
}

/* Calculator Wrapper Page */
.detail-container {
  max-width: 800px;
  margin: 0 auto;
}
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1.5rem;
}
.detail-header {
  margin-bottom: 2rem;
}
.detail-header h1 {
  font-family: var(--font-heading);
  font-size: 2.25rem;
  font-weight: 950;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}
.detail-header p {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Calculator Interface Elements */
.calc-widget {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 1.5rem;
  padding: 2rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 3rem;
}
.unit-tabs {
  display: flex;
  background-color: var(--border-light);
  border-radius: 0.75rem;
  padding: 0.25rem;
  margin-bottom: 1.5rem;
  gap: 0.25rem;
}
.tab-btn {
  flex: 1;
  padding: 0.625rem;
  border: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 0.5rem;
  transition: all 0.2s;
  text-align: center;
}
.tab-btn.active {
  background-color: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.form-row {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
.form-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.form-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.input-field, .select-field {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  font-size: 1rem;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  background-color: var(--bg-card);
  color: var(--text-primary);
  font-family: var(--font-sans);
  transition: border-color 0.2s;
}
.input-field:focus, .select-field:focus {
  border-color: var(--primary);
}
.calc-btn {
  width: 100%;
  padding: 0.875rem;
  background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
  color: white;
  border: none;
  border-radius: 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
  margin-top: 1rem;
}
.calc-btn:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}
.result-section {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
  animation: fadeIn 0.4s ease-out;
}
.hidden {
  display: none !important;
}

/* Result Widgets */
.result-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 1.5rem;
}
.score-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.score-value {
  font-size: 3rem;
  font-weight: 900;
  color: var(--text-primary);
  margin: 0.25rem 0;
  line-height: 1;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.metric-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
}
.metric-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}
.metric-value {
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--text-primary);
}
.breakdown-info {
  background-color: var(--primary-light);
  border-left: 4px solid var(--primary);
  padding: 1.25rem;
  border-radius: 0 0.75rem 0.75rem 0;
  font-size: 0.875rem;
  color: var(--text-primary);
  line-height: 1.6;
}
.breakdown-info p {
  margin-bottom: 0;
}

/* Article Styling */
.article-section {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 1.5rem;
  padding: 2rem 2.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 3rem;
}
.article-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}
.article-header h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
}
.article-content {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.7;
}
.article-content h2, .article-content h3 {
  color: var(--text-primary);
  font-family: var(--font-heading);
  font-weight: 800;
  margin-top: 1.75rem;
  margin-bottom: 0.75rem;
}
.article-content h2 { font-size: 1.25rem; }
.article-content h3 { font-size: 1.125rem; }
.article-content p {
  margin-bottom: 1.25rem;
}
.article-content ul, .article-content ol {
  margin-left: 1.5rem;
  margin-bottom: 1.25rem;
}
.article-content li {
  margin-bottom: 0.5rem;
}
.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}
.article-content th, .article-content td {
  border: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.875rem;
}
.article-content th {
  background-color: var(--border-light);
  font-weight: 700;
}

/* Theme Toggle Button */
.theme-btn {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.theme-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
  .menu-toggle {
    display: flex;
  }
  .nav-links {
    display: none;
    position: absolute;
    top: 4.5rem;
    left: 0;
    right: 0;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    flex-direction: column;
    padding: 1.5rem;
    gap: 1rem;
    box-shadow: var(--shadow-lg);
    z-index: 100;
  }
  .nav-links.active {
    display: flex;
  }
  .nav-link {
    width: 100%;
    text-align: center;
  }
  .theme-btn {
    align-self: center;
    margin-top: 0.5rem;
  }
  
  /* Animate menu toggle to X */
  .menu-toggle.active .bar:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
  }
  .menu-toggle.active .bar:nth-child(2) {
    opacity: 0;
  }
  .menu-toggle.active .bar:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
  }

  .footer-container {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  .metric-grid {
    grid-template-columns: 1fr;
  }
}

/* Breadcrumbs Styling */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
.breadcrumbs a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}
.breadcrumbs a:hover {
  color: var(--primary);
}
.breadcrumbs span.separator {
  color: var(--text-muted);
  font-size: 0.75rem;
}
.breadcrumbs span.current {
  color: var(--text-primary);
  font-weight: 600;
}

/* Justified Article and FAQ Formatting */
.article-content {
  text-align: justify;
  text-justify: inter-word;
}
.article-content p, .article-content li {
  text-align: justify;
  line-height: 1.8;
  margin-bottom: 1.5rem;
  font-size: 1.05rem;
}
.article-content h3 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 800;
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}
.faq-section {
  margin-top: 3.5rem;
  border-top: 1px solid var(--border-color);
  padding-top: 2.5rem;
}
.faq-header {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  text-align: left;
}
.faq-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}
.faq-item:hover {
  border-color: var(--border-color);
  box-shadow: var(--shadow-md);
}
.faq-question {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  text-align: left;
}
.faq-answer {
  color: var(--text-secondary);
  line-height: 1.6;
  text-align: justify;
  text-justify: inter-word;
  font-size: 0.975rem;
}
