/* ===== Theme tokens (light default) ===== */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --card-bg: #ffffff;
  --header-bg: #ffffff;
  --sidebar-bg: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.06);
}

/* Dark theme - toggled site-wide from Admin > Settings */
:root[data-theme="dark"] {
  --primary: #3b82f6;
  --primary-dark: #60a5fa;
  --primary-light: #1e3a5f;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: #2d3748;
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --card-bg: #1e293b;
  --header-bg: #111827;
  --sidebar-bg: #1e293b;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html { overflow-x: hidden; max-width: 100%; }
body { overflow-x: hidden; max-width: 100%; }

/* Global link reset - prevents the default browser underline from leaking
   into card titles, sidebar items, buttons, etc. Underlines are intentionally
   re-enabled only inside article/blog body text further below. */
a, a:visited, a:hover, a:active, a:focus {
  text-decoration: none;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
a { color: inherit; }

/* ===== Header ===== */
.site-header {
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--header-bg);
  z-index: 100;
  box-shadow: var(--shadow);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; gap: 20px; }
.logo { text-decoration: none; display: flex; align-items: center; }
.logo img { max-height: 42px; width: auto; display: block; }
.logo-text { font-weight: 800; font-size: 1.35rem; color: var(--primary); }

.main-nav { display: flex; flex-wrap: wrap; gap: 16px 22px; align-items: center; justify-content: flex-end; }
.main-nav a {
  color: var(--text); text-decoration: none; font-weight: 600; font-size: .92rem;
  display: flex; align-items: center; gap: 4px;
}
.main-nav a .material-icons { font-size: 20px; color: var(--muted); }
.main-nav a:hover { color: var(--primary); }
.main-nav a:hover .material-icons { color: var(--primary); }
.admin-nav-link { background: var(--primary-light); padding: 6px 12px; border-radius: 999px; }
.admin-nav-link .material-icons { color: var(--primary) !important; }

.dropdown { position: relative; cursor: pointer; }
.dropdown > span { display: flex; align-items: center; gap: 4px; font-weight: 600; font-size: .92rem; }
.dropdown > span .material-icons { font-size: 20px; color: var(--muted); }
.dropdown-menu {
  display: none; position: absolute; top: 100%; left: 0; margin-top: 0;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  min-width: 220px; box-shadow: 0 12px 28px rgba(0,0,0,.12); padding: 8px 0; max-height: 340px; overflow-y: auto;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a { display: block; padding: 9px 18px; font-weight: 500; text-decoration: none; }
.dropdown-menu a:hover { background: var(--bg-soft); }

/* ===== Main layout ===== */
.main-content { padding: 36px 20px; min-height: 60vh; }

.hero { text-align: center; margin-bottom: 40px; }
.hero h1 { font-size: 2.3rem; margin-bottom: 8px; }
.hero p { color: var(--muted); }

.category-block { margin-bottom: 44px; }
.category-block h2 {
  display: flex; align-items: center; gap: 8px;
  border-left: 4px solid var(--primary); padding-left: 12px; font-size: 1.3rem;
}

/* ===== Search widget (sidebar) ===== */
.search-widget { position: relative; margin-bottom: 20px; }
.search-box {
  display: flex; align-items: center; gap: 8px; background: var(--card-bg);
  border: 1px solid var(--border); border-radius: 999px; padding: 10px 16px;
}
.search-box .material-icons { color: var(--muted); font-size: 20px; }
.search-box input {
  border: none; outline: none; background: transparent; width: 100%;
  font-size: .9rem; color: var(--text);
}
.search-suggestions {
  display: none; position: absolute; top: 46px; left: 0; right: 0;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(0,0,0,.14); z-index: 50; overflow: hidden;
}
.search-suggestions a {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  text-decoration: none; color: var(--text); font-size: .88rem; font-weight: 500;
}
.search-suggestions a:hover { background: var(--bg-soft); }
.search-suggestions a .material-icons { font-size: 18px; color: var(--primary); }

/* ===== Calculator/tool cards (centered icon, like a tool-grid) ===== */
.calc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 16px; }
.calc-card {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 12px;
  text-decoration: none; color: var(--text); background: var(--card-bg);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.calc-card:hover { transform: translateY(-3px); box-shadow: 0 10px 22px rgba(0,0,0,.1); border-color: var(--primary); }
.calc-card .card-icon {
  width: 60px; height: 60px; border-radius: 10px;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.calc-card .card-icon .material-icons { font-size: 30px; }
.calc-card .card-icon .custom-calc-icon { width: 40px; height: 40px; object-fit: contain; border-radius: 0; background: none; }
.custom-calc-icon.sidebar-icon { width: 18px; height: 18px; object-fit: contain; flex-shrink: 0; border-radius: 3px; }
.calc-card h3 { margin: 0; color: var(--text); font-size: .88rem; font-weight: 600; line-height: 1.3; }
.calc-card p { display: none; }

/* ===== Two-column layout (calculator/category pages) ===== */
.page-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 32px; align-items: start; }
@media (max-width: 900px) { .page-layout { grid-template-columns: 1fr; } }

.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: 12px; }
.breadcrumb a { color: var(--muted); text-decoration: none; }

.calc-tool-box {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px; margin: 20px 0;
}
.calc-tool-box label { display: block; margin: 12px 0 4px; font-weight: 600; font-size: .9rem; }
.calc-tool-box input, .calc-tool-box select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 1rem; background: var(--bg); color: var(--text);
}
.calc-tool-box button {
  margin-top: 16px; background: var(--primary); color: #fff; border: none;
  padding: 12px 22px; border-radius: 8px; font-size: 1rem; cursor: pointer; font-weight: 600;
}
.calc-tool-box button:hover { background: var(--primary-dark); }
.calc-result {
  margin-top: 18px; padding: 14px; border-radius: 8px;
  background: var(--primary-light); border: 1px solid var(--primary); font-weight: 600; display: none;
}

.calc-description { margin-top: 30px; }
.calc-description h2 { font-size: 1.3rem; }
.calc-description img { max-width: 100%; height: auto; border-radius: 8px; }

/* Universal safety net: whatever gets pasted or embedded into content (images,
   iframes, tables, or elements copy-pasted from Word/Google Docs carrying their
   own fixed pixel widths) can NEVER force this container wider than its column.
   max-width only ever shrinks an oversized element - it never enlarges a small
   one - so this is safe for every normal case (badges, small inline elements, etc). */
.post-article, .calc-description, .post-content {
  max-width: 100%;
  overflow-x: hidden;
}
.post-article *, .calc-description *, .post-content * {
  max-width: 100% !important;
  box-sizing: border-box;
}
.post-content, .calc-description {
  overflow-wrap: break-word;
  word-wrap: break-word;
}
.post-article iframe, .calc-description iframe,
.post-article video, .calc-description video {
  aspect-ratio: 16 / 9;
  height: auto !important;
  width: 100%;
  border-radius: 8px;
}
.post-article table, .calc-description table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.calc-description a, .post-content a, .contact-details-side a {
  color: var(--primary); text-decoration: underline; font-weight: 600;
}
.calc-description a:hover, .post-content a:hover, .contact-details-side a:hover {
  text-decoration: none; opacity: .85;
}
.related-tools { margin-top: 40px; }

/* ===== Sidebar ===== */
.sidebar-widget {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 20px;
}
.sidebar-widget h3 { margin: 0 0 12px; font-size: 1rem; display: flex; align-items: center; gap: 6px; }
.sidebar-widget h3 .material-icons { font-size: 20px; color: var(--primary); }
.sidebar-list { list-style: none; margin: 0; padding: 0; }
.sidebar-list li { border-bottom: 1px solid var(--border); }
.sidebar-list li:last-child { border-bottom: none; }
.sidebar-list a {
  display: flex; align-items: center; gap: 10px; padding: 10px 2px;
  text-decoration: none; color: var(--text); font-size: .9rem; font-weight: 500;
}
.sidebar-list a:hover { color: var(--primary); }
.sidebar-list a .material-icons { font-size: 18px; color: var(--muted); flex-shrink: 0; }

/* ===== Blog ===== */
.blog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; margin-top: 20px; }
.blog-card {
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  background: var(--card-bg); text-decoration: none; color: var(--text);
  transition: transform .12s ease, box-shadow .12s ease;
}
.blog-card:hover { transform: translateY(-3px); box-shadow: 0 10px 22px rgba(0,0,0,.1); }
.blog-card img { width: 100%; height: 160px; object-fit: cover; display: block; background: var(--bg-soft); }
.blog-card-body { padding: 16px; }
.blog-card-body .date { font-size: .78rem; color: var(--muted); }
.blog-card-body h3 { margin: 6px 0; font-size: 1.05rem; }
.blog-card-body p { margin: 0; font-size: .87rem; color: var(--muted); }

.post-article img { max-width: 100%; height: auto; border-radius: 10px; }
.post-article .post-meta { color: var(--muted); font-size: .88rem; margin-bottom: 20px; }
.post-article h1 { margin-bottom: 6px; }

/* Contact form */
.contact-form-box {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; margin: 20px 0; max-width: 560px;
}
.contact-form-box label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: .9rem; }
.contact-form-box input, .contact-form-box textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: .95rem; font-family: inherit; background: var(--bg); color: var(--text);
}
.contact-form-box button {
  margin-top: 16px; background: var(--primary); color: #fff; border: none;
  padding: 12px 22px; border-radius: 8px; font-size: 1rem; cursor: pointer; font-weight: 600;
}
.contact-form-box button:hover { background: var(--primary-dark); }
.alert-success-box, .alert-error-box { padding: 12px 16px; border-radius: 8px; margin-bottom: 14px; font-size: .9rem; }
.alert-success-box { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error-box { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }

.contact-info { margin-bottom: 24px; }
.contact-info p { margin: 6px 0; }
.contact-info .material-icons { font-size: 18px; vertical-align: middle; color: var(--primary); margin-right: 6px; }

/* Related blog posts (with thumbnail) under a blog post */
.related-posts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-top: 16px; max-width: 660px; }
.related-post-card {
  display: block; text-decoration: none; color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; background: var(--card-bg);
  transition: transform .12s ease, box-shadow .12s ease;
}
.related-post-card:hover { transform: translateY(-3px); box-shadow: 0 10px 22px rgba(0,0,0,.1); }
.related-post-thumb { width: 100%; height: 90px; object-fit: cover; display: block; }
.related-post-thumb-placeholder {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-soft); color: var(--muted);
}
.related-post-thumb-placeholder .material-icons { font-size: 28px; }
.related-post-card h3 { margin: 10px 12px 4px; font-size: .88rem; line-height: 1.3; }
.related-post-card p { margin: 0 12px 12px; font-size: .78rem; color: var(--muted); line-height: 1.4; }

/* Contact page: form left, admin-written details right */
.contact-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: start; margin-top: 20px; }
@media (max-width: 800px) { .contact-two-col { grid-template-columns: 1fr; } }
.contact-form-side .contact-form-box { max-width: 100%; margin: 0; }
.contact-details-side { padding-top: 4px; }

/* Blog comments */
.comments-section { margin-top: 44px; padding-top: 30px; border-top: 1px solid var(--border); }
.comments-list { margin: 20px 0; }
.comment-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.comment-item:last-child { border-bottom: none; }
.comment-item-top { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.comment-item p { margin: 0; }
.comment-form-box {
  background: #fff; border: 1.5px solid var(--border); border-radius: 14px;
  padding: 22px; margin-top: 24px; max-width: 100%; box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.comment-form-box label { display: block; margin: 12px 0 6px; font-weight: 600; font-size: .9rem; }
.comment-form-box input, .comment-form-box textarea {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 10px;
  font-size: .95rem; font-family: inherit; background: var(--bg); color: var(--text);
  transition: border-color .15s ease;
}
.comment-form-box input:focus, .comment-form-box textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.comment-form-box button {
  margin-top: 16px; background: var(--primary); color: #fff; border: none;
  padding: 11px 24px; border-radius: 999px; font-size: .95rem; cursor: pointer; font-weight: 600;
  box-shadow: 0 2px 6px rgba(37,99,235,.3); transition: background .15s ease, transform .1s ease;
}
.comment-form-box button:hover { background: var(--primary-dark); transform: translateY(-1px); }

/* Staff replies to comments */
.reply-toggle-btn {
  background: none; border: none; color: var(--primary); font-weight: 600; font-size: .82rem;
  cursor: pointer; padding: 4px 0; margin-top: 4px;
}
.reply-toggle-btn:hover { text-decoration: underline; }
.reply-form {
  display: none; margin-top: 10px; max-width: 480px;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 14px;
}
.reply-form.open { display: block; }
.reply-form textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: .9rem; font-family: inherit; background: var(--bg); color: var(--text); margin-bottom: 10px;
  resize: vertical; transition: border-color .15s ease;
}
.reply-form textarea:focus { outline: none; border-color: var(--primary); }
.reply-form input[type="text"], .reply-form input[type="email"] {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: .9rem; font-family: inherit; background: var(--bg); color: var(--text); margin-bottom: 8px;
}
.reply-as-staff { display: block; font-size: .82rem; font-weight: 600; color: var(--primary); margin-bottom: 8px; }
.reply-form button {
  background: var(--primary); color: #fff; border: none; padding: 9px 20px;
  border-radius: 999px; font-size: .85rem; cursor: pointer; font-weight: 600;
}
.reply-form button:hover { background: var(--primary-dark); }
.comment-replies { margin-left: 24px; margin-top: 10px; padding-left: 14px; border-left: 2px solid var(--border); }
.comment-reply-item { border-bottom: none !important; padding: 10px 0 !important; }
.staff-badge {
  background: var(--primary-light); color: var(--primary); font-size: .68rem; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; text-transform: uppercase;
}

/* ===== Ad slots (AdSense-ready containers) =====
   Fixed max-width + overflow control so ad units never break the layout,
   even if an ad unit's actual rendered size differs from its container. */
.ad-slot {
  margin: 16px auto; max-width: 100%; overflow: hidden; text-align: center;
  min-height: 0; /* collapses to 0 height when empty, so it never leaves a blank gap */
}
.ad-slot:empty { display: none; margin: 0; }
.ad-slot-header { margin-top: 0; }
.ad-slot-sidebar { margin-bottom: 20px; }
.ad-slot-incontent { margin: 28px auto; }
.ad-slot ins, .ad-slot iframe { max-width: 100%; }

/* ===== Pagination ===== */
.pagination { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 30px 0; }
.page-link {
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: .9rem; font-weight: 600; background: var(--card-bg);
}
.page-link:hover { border-color: var(--primary); color: var(--primary); }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.view-all-link { display: inline-block; margin-top: 8px; font-weight: 600; color: var(--primary); font-size: .9rem; }
.site-footer { border-top: 1px solid var(--border); padding: 28px 0; text-align: center; color: var(--muted); font-size: .9rem; background: var(--bg-soft); }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 20px; margin-bottom: 10px; }
.footer-links a { text-decoration: none; font-weight: 600; }
.footer-links a:hover { color: var(--primary); }

/* ===== Mobile hamburger menu (hidden on desktop by default) ===== */
.mobile-menu-toggle {
  display: none; background: none; border: none; cursor: pointer;
  padding: 6px; color: var(--text); align-items: center; justify-content: center;
}
.mobile-menu-toggle .material-icons { font-size: 28px; }
.mobile-nav-close { display: none; }
.mobile-nav-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 998; opacity: 0; transition: opacity .2s ease;
}
.mobile-nav-backdrop.open { display: block; opacity: 1; }

@media (max-width: 720px) {
  .header-inner { padding: 14px 16px; }
  .mobile-menu-toggle { display: flex; }

  .main-nav {
    position: fixed; top: 0; right: 0; height: 100vh; width: min(80vw, 320px);
    background: var(--header-bg); box-shadow: -4px 0 24px rgba(0,0,0,.15);
    flex-direction: column; align-items: stretch; justify-content: flex-start;
    gap: 4px; padding: 60px 20px 24px; z-index: 999;
    transform: translateX(100%); transition: transform .25s ease;
    overflow-y: auto;
  }
  .main-nav.mobile-open { transform: translateX(0); }
  .main-nav a { padding: 12px 4px; border-bottom: 1px solid var(--border); font-size: 1rem; }
  .main-nav .dropdown { width: 100%; }
  .main-nav .dropdown > span { padding: 12px 4px; border-bottom: 1px solid var(--border); }
  .main-nav .dropdown-menu {
    position: static; box-shadow: none; border: none; display: none;
    padding-left: 16px; min-width: 0;
  }
  .main-nav .dropdown.open .dropdown-menu { display: block; }

  .mobile-nav-close {
    display: flex; position: absolute; top: 12px; right: 16px;
    background: none; border: none; cursor: pointer; color: var(--muted); padding: 6px;
  }
  .mobile-nav-close .material-icons { font-size: 26px; }
}
