/* ===== CSS Variables ===== */
:root {
  --primary: #0066CC;
  --primary-dark: #004C99;
  --primary-light: #E6F0FA;
  --accent: #00A86B;
  --accent-dark: #008555;
  --text: #1A1A2E;
  --text-light: #555770;
  --text-muted: #8A8CA5;
  --bg: #FFFFFF;
  --bg-alt: #F5F6FA;
  --bg-card: #FFFFFF;
  --border: #E2E4EE;
  --border-light: #F0F1F6;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --max-width: 1200px;
  --header-height: 64px;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'DM Mono', 'Consolas', monospace;
}

/* ===== 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-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; height: auto; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
code { font-family: var(--font-mono); font-size: 0.9em; background: var(--bg-alt); padding: 0.15em 0.4em; border-radius: 4px; }

/* ===== Layout ===== */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.main-content { flex: 1; }

.section {
  padding: 3rem 0;
}

.section-alt {
  background: var(--bg-alt);
}

.section-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text);
}

.page-header {
  margin-bottom: 2rem;
}

.page-subtitle {
  font-size: 1.1rem;
  color: var(--text-light);
  margin-top: 0.5rem;
}

/* ===== Header ===== */
.site-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  gap: 1.5rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-icon { display: block; }

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.nav-link {
  color: var(--text-light);
  font-weight: 500;
  font-size: 0.95rem;
  white-space: nowrap;
}

.nav-link:hover { color: var(--primary); }

.nav-search {
  display: flex;
  align-items: center;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.2s;
}

.nav-search:focus-within {
  border-color: var(--primary);
}

.nav-search input {
  border: none;
  background: transparent;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  width: 200px;
  font-family: var(--font-body);
  color: var(--text);
  outline: none;
}

.nav-search button {
  border: none;
  background: transparent;
  padding: 0.5rem 0.6rem;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

.nav-search button:hover { color: var(--primary); }

/* Mobile menu */
.mobile-menu-btn {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.mobile-menu-btn span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text);
  transition: transform 0.2s;
}

/* ===== Hero ===== */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #0052A3 100%);
  color: white;
  padding: 4rem 0 3.5rem;
  text-align: center;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.hero-subtitle {
  font-size: 1.15rem;
  opacity: 0.9;
  max-width: 550px;
  margin: 0 auto 2rem;
}

.hero-search {
  display: flex;
  max-width: 560px;
  margin: 0 auto;
  background: white;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.hero-search input {
  flex: 1;
  border: none;
  padding: 1rem 1.25rem;
  font-size: 1rem;
  font-family: var(--font-body);
  color: var(--text);
  outline: none;
  min-width: 0;
}

.hero-search button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 1rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.2s;
}

.hero-search button:hover { background: var(--primary-dark); }

/* ===== Category Grid ===== */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.category-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.5rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: box-shadow 0.2s, transform 0.2s;
}

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

.category-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  line-height: 1;
}

.category-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.category-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===== Calculator Grid ===== */
.calculator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.calculator-card {
  display: block;
  padding: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: box-shadow 0.2s, transform 0.2s;
}

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

.calculator-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.calculator-card p {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.card-category {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  text-transform: capitalize;
}

/* ===== Calculator List ===== */
.calculator-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.calculator-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: box-shadow 0.2s;
  gap: 1rem;
}

.calculator-list-item:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--primary);
}

.list-item-content h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.list-item-content p {
  font-size: 0.9rem;
  color: var(--text-light);
}

.list-item-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.views-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.arrow {
  font-size: 1.5rem;
  color: var(--text-muted);
}

/* ===== Sort Bar ===== */
.sort-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.sort-link {
  color: var(--text-light);
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.sort-link:hover { background: var(--bg-alt); }
.sort-link.active { color: var(--primary); background: var(--primary-light); }

/* ===== Breadcrumb ===== */
.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

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

/* ===== Search Form ===== */
.search-form {
  display: flex;
  max-width: 600px;
  margin-bottom: 2rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.2s;
}

.search-form:focus-within { border-color: var(--primary); }

.search-form input {
  flex: 1;
  border: none;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  font-family: var(--font-body);
  color: var(--text);
  outline: none;
}

.search-form button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
}

.result-count {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ===== SEO Content ===== */
.seo-content {
  color: var(--text-light);
}

.seo-content h2 {
  color: var(--text);
  margin-bottom: 1rem;
}

.seo-content p {
  max-width: 700px;
  margin-bottom: 1rem;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* ===== Ad Units ===== */
.ad-unit {
  margin: 1.5rem 0;
  text-align: center;
  min-height: 90px;
}

/* ===== Footer ===== */
.site-footer {
  background: var(--text);
  color: #CCC;
  padding: 3rem 0 1.5rem;
  margin-top: auto;
}

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

.footer-brand p {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #999;
  max-width: 280px;
}

.footer-brand .logo-text { color: white; }

.footer-links h4 {
  color: white;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.footer-links ul { list-style: none; }
.footer-links li { margin-bottom: 0.4rem; }
.footer-links a {
  color: #999;
  font-size: 0.9rem;
  transition: color 0.2s;
}
.footer-links a:hover { color: white; }

.footer-bottom {
  border-top: 1px solid #333;
  padding-top: 1.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: #777;
}

/* ===== Alerts ===== */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error {
  background: #FFF0F0;
  color: #CC3333;
  border: 1px solid #FFD4D4;
}

/* ===== Buttons ===== */
.btn-calculate {
  display: block;
  width: 100%;
  padding: 0.9rem 2rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.2s;
  text-align: center;
  margin-top: 0.5rem;
}

.btn-calculate:hover { background: var(--accent-dark); color: white; }

.btn-primary {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  font-family: var(--font-body);
}

.btn-primary:hover { background: var(--primary-dark); color: white; }

.btn-secondary {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  font-family: var(--font-body);
}

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

/* ===== Legal / Static Pages ===== */
.legal-page {
  max-width: 800px;
  margin: 0 auto;
}

.legal-page h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.legal-updated {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.legal-page h2 {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.legal-page h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

.legal-page p {
  color: var(--text-light);
  margin-bottom: 1rem;
  line-height: 1.7;
}

.legal-page ul {
  color: var(--text-light);
  margin-bottom: 1rem;
  padding-left: 1.5rem;
  line-height: 1.8;
}

.legal-page a {
  color: var(--primary);
  text-decoration: underline;
}

.legal-page a:hover {
  color: var(--primary-dark);
}

.contact-info {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem 2rem;
  margin: 1.5rem 0;
}

.contact-info h2 {
  margin-top: 0;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .hero h1 { font-size: 1.75rem; }
  .hero-subtitle { font-size: 1rem; }
  .hero { padding: 2.5rem 0 2rem; }

  .mobile-menu-btn { display: flex; }

  .main-nav {
    display: none;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--bg);
    flex-direction: column;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    gap: 0.75rem;
  }

  .main-nav.open { display: flex; }

  .nav-search { width: 100%; }
  .nav-search input { width: 100%; }

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

  .category-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

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

  .section { padding: 2rem 0; }
}

@media (max-width: 480px) {
  .hero-search {
    flex-direction: column;
  }

  .hero-search button {
    border-radius: 0;
  }

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