/* ==========================================================================
   HDPC — main.css
   Modern SaaS design system on Bootstrap 5.3.
   ========================================================================== */

/* ---------- Design Tokens ---------- */
:root {
  --brand-primary: #4f46e5;
  --brand-primary-hover: #4338ca;
  --brand-primary-light: #eef2ff;
  --brand-accent: #06b6d4;
  --brand-success: #10b981;
  --brand-warning: #f59e0b;
  --brand-font: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --brand-font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --brand-radius-sm: 0.5rem;
  --brand-radius: 0.75rem;
  --brand-radius-lg: 1rem;
  --brand-radius-xl: 1.5rem;
  --brand-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --brand-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --brand-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --brand-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --brand-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.03);
  --section-gap: 4rem;
  --content-gap: 2rem;
  /* Override Bootstrap's primary palette globally */
  --bs-primary: #4f46e5;
  --bs-primary-rgb: 79, 70, 229;
  --bs-link-color: #4f46e5;
  --bs-link-color-rgb: 79, 70, 229;
  --bs-link-hover-color: #4338ca;
  --bs-link-hover-color-rgb: 67, 56, 202;
}

/* ---------- Bootstrap Primary Override ---------- */
.btn-primary {
  --bs-btn-bg: #4f46e5;
  --bs-btn-border-color: #4f46e5;
  --bs-btn-hover-bg: #4338ca;
  --bs-btn-hover-border-color: #4338ca;
  --bs-btn-active-bg: #3730a3;
  --bs-btn-active-border-color: #3730a3;
  --bs-btn-disabled-bg: #4f46e5;
  --bs-btn-disabled-border-color: #4f46e5;
}

.btn-outline-primary {
  --bs-btn-color: #4f46e5;
  --bs-btn-border-color: #4f46e5;
  --bs-btn-hover-bg: #4f46e5;
  --bs-btn-hover-border-color: #4f46e5;
  --bs-btn-active-bg: #4338ca;
  --bs-btn-active-border-color: #4338ca;
}

.text-primary {
  color: #4f46e5 !important;
}

.bg-primary {
  background-color: #4f46e5 !important;
}

/* Nav pills / tabs — override Bootstrap's default blue */
.nav-pills {
  --bs-nav-pills-link-active-bg: #4f46e5;
}

.nav-pills .nav-link.active,
.nav-pills .show > .nav-link {
  background-color: #4f46e5;
  color: #fff;
}

.nav-pills .nav-link:not(.active) {
  color: #4f46e5;
}

.nav-pills .nav-link:not(.active):hover {
  color: #4338ca;
  background-color: rgba(79, 70, 229, 0.06);
}

.nav-tabs .nav-link.active,
.nav-tabs .nav-item.show .nav-link {
  color: #4f46e5;
  border-bottom-color: #4f46e5;
}

.nav-tabs .nav-link:hover {
  color: #4338ca;
}

/* ---------- Global ---------- */
html {
  scrollbar-gutter: stable;
}

body {
  font-family: var(--brand-font);
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.011em;
  line-height: 1.6;
  overflow-x: hidden;
}

:target {
  scroll-margin-top: 5rem;
}

/* ---------- Typography Scale ---------- */
h1, h2, h3, h4, h5, h6 {
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.display-5 {
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.display-6 {
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.lead {
  font-weight: 400;
  letter-spacing: -0.005em;
  line-height: 1.7;
}

/* ---------- Navbar ---------- */
.navbar {
  transition: box-shadow 0.3s ease, background-color 0.3s ease;
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.navbar-brand {
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  color: var(--brand-primary) !important;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 44px;
}

.navbar-brand img {
  border-radius: 6px;
}

.nav-link {
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.625rem 0.625rem !important;
  border-radius: var(--brand-radius-sm);
  transition: color 0.15s ease, background-color 0.15s ease;
  white-space: nowrap;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.nav-link:hover {
  background-color: rgba(79, 70, 229, 0.06);
  color: var(--brand-primary) !important;
}

/* Comfortable spacing at wider screens */
@media (min-width: 1200px) {
  .nav-link {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem !important;
  }
}

/* Navbar toggler (hamburger) */
.navbar-toggler {
  min-width: 44px;
  min-height: 44px;
  padding: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Theme toggle */
.theme-toggle-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--brand-radius-sm);
  flex-shrink: 0;
}

/* Navbar search */
.navbar form[role="search"] {
  flex: 1 1 auto;
  max-width: 320px;
  position: relative;
}

.navbar .form-control {
  border-radius: var(--brand-radius);
  border: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 0.8125rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-height: 44px;
  width: 100%;
}

.navbar .form-control:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

/* ---------- Section Spacing ---------- */
.section-block {
  padding: var(--section-gap) 0;
}

.section-block:nth-child(even) {
  background-color: var(--bs-tertiary-bg);
}

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

.section-label {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brand-primary);
  margin-bottom: 0.5rem;
}

/* ---------- Tool Cards ---------- */
.tool-card {
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  border-radius: var(--brand-radius-lg) !important;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.06) !important;
  background: var(--bs-body-bg);
}

.tool-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--brand-shadow-lg) !important;
  border-color: rgba(79, 70, 229, 0.15) !important;
}

.tool-card:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

.tool-card .card-body {
  padding: 1.25rem;
}

.tool-card .card-title {
  line-height: 1.35;
  font-weight: 700;
}

.tool-card .card-subtitle {
  font-size: 0.75rem;
  line-height: 1.35;
  font-weight: 400;
}

.tool-card .badge {
  font-weight: 600;
  font-size: 0.6875rem;
  letter-spacing: 0.02em;
}

.tool-card .card-text {
  line-height: 1.5;
  color: var(--bs-secondary-color) !important;
}

.tool-card .text-primary.fw-semibold {
  font-size: 0.8125rem;
  font-weight: 600;
  transition: gap 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.tool-card:hover .text-primary.fw-semibold {
  gap: 0.5rem;
}

/* Category cards (homepage) */
.category-card .card-body {
  padding: 1.75rem 1rem;
}

.category-card svg {
  transition: transform 0.2s ease;
}

.category-card:hover svg {
  transform: scale(1.15);
}

/* ---------- Tool Area (Calculator Widget) ---------- */
.tool-area {
  background: var(--bs-body-bg);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--brand-radius-lg);
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--brand-shadow);
  overflow-x: auto;          /* prevent horizontal scroll on page */
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Reset browser defaults inside tool areas */
.tool-area ul.nav,
.tool-area ul.nav-pills,
.tool-area ul.nav-tabs {
  padding-left: 0;
}

.tool-area h1:first-child,
.tool-area h2:first-child,
.tool-area h3:first-child,
.tool-area h4:first-child {
  margin-top: 0;
}

.tool-area h3.mb-3 {
  margin-top: 0;
}

.tool-area .form-label {
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bs-secondary-color);
  margin-bottom: 0.5rem;
}

.tool-area .form-control,
.tool-area .form-select {
  border-radius: var(--brand-radius);
  border: 1px solid rgba(0, 0, 0, 0.12);
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-height: 44px;
}

.tool-area .form-control:focus,
.tool-area .form-select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

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

/* Shared sizing for ALL buttons inside tool areas */
.tool-area .btn {
  padding: 0.625rem 1.5rem;
  font-weight: 600;
  border-radius: var(--brand-radius);
  font-size: 0.9375rem;
  transition: all 0.2s ease;
  min-height: 44px;
  border-width: 1.5px;
}

.tool-area .btn-primary {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.2);
}

.tool-area .btn-primary:hover {
  background: var(--brand-primary-hover);
  border-color: var(--brand-primary-hover);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
  transform: translateY(-1px);
}

.tool-area .btn-primary:active {
  transform: translateY(0);
}

.tool-area .btn-outline-danger,
.tool-area .btn-outline-secondary,
.tool-area .btn-outline-primary {
  box-shadow: none;
}

.tool-area .btn-outline-danger:hover,
.tool-area .btn-outline-secondary:hover,
.tool-area .btn-outline-primary:hover {
  transform: translateY(-1px);
}

.tool-area .btn-outline-danger:active,
.tool-area .btn-outline-secondary:active,
.tool-area .btn-outline-primary:active {
  transform: translateY(0);
}

.tool-area .btn-group .btn {
  min-height: 44px;
}

.tool-area .input-group-text {
  background: transparent;
  border-color: rgba(0, 0, 0, 0.12);
  font-weight: 500;
  color: var(--bs-secondary-color);
}

/* Result display */
.result-display {
  font-size: 2rem;
  font-weight: 800;
  padding: 1.25rem;
  text-align: center;
  border-radius: var(--brand-radius-lg);
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.06), rgba(6, 182, 212, 0.06));
  color: var(--brand-primary);
  border: 1px solid rgba(79, 70, 229, 0.1);
  letter-spacing: -0.02em;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Result display inside tables — smaller to fit cells */
table .result-display {
  font-size: 1.25rem;
  padding: 0.75rem;
}

/* ---------- Tables ---------- */
.tool-content table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1.5rem 0;
  border-radius: var(--brand-radius);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 0.9375rem;
}

.tool-content thead {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.04), rgba(79, 70, 229, 0.08));
}

.tool-content thead th {
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bs-secondary-color);
  padding: 0.875rem 1rem;
  border-bottom: 2px solid rgba(79, 70, 229, 0.1);
  white-space: nowrap;
}

.tool-content tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  vertical-align: middle;
}

.tool-content tbody tr {
  transition: background-color 0.15s ease;
}

.tool-content tbody tr:hover {
  background-color: rgba(79, 70, 229, 0.02);
}

.tool-content tbody tr:last-child td {
  border-bottom: none;
}

/* ---------- Tool Content Styling ---------- */
.tool-content h2 {
  margin-top: 3rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid rgba(0, 0, 0, 0.06);
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.tool-content h3 {
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--bs-body-color);
}

.tool-content h4 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 1rem;
}

.tool-content ol,
.tool-content ul:not(.nav) {
  padding-left: 1.5rem;
}

.tool-content li {
  margin-bottom: 0.625rem;
  line-height: 1.7;
  padding-left: 0.25rem;
}

.tool-content li::marker {
  color: var(--brand-primary);
}

.tool-content p {
  line-height: 1.75;
  margin-bottom: 1.25rem;
}

.tool-content code {
  background: rgba(79, 70, 229, 0.06);
  padding: 0.2em 0.5em;
  border-radius: 6px;
  font-size: 0.875em;
  font-family: var(--brand-font-mono);
  color: var(--brand-primary);
}

.tool-content pre {
  background: var(--bs-tertiary-bg);
  padding: 1.25rem;
  border-radius: var(--brand-radius);
  overflow-x: auto;
  border: 1px solid rgba(0, 0, 0, 0.06);
  margin: 1.5rem 0;
}

.tool-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.tool-content blockquote {
  border-left: 3px solid var(--brand-primary);
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  background: rgba(79, 70, 229, 0.03);
  border-radius: 0 var(--brand-radius) var(--brand-radius) 0;
  font-style: italic;
}

.tool-content hr {
  margin: 2.5rem 0;
  border-color: rgba(0, 0, 0, 0.06);
}

/* ---------- Accordions (FAQs) ---------- */
.accordion {
  --bs-accordion-border-radius: var(--brand-radius-lg);
  --bs-accordion-inner-border-radius: var(--brand-radius);
  --bs-accordion-btn-padding-x: 1.25rem;
  --bs-accordion-btn-padding-y: 1rem;
  --bs-accordion-border-color: rgba(0, 0, 0, 0.06);
  border-radius: var(--brand-radius-lg);
  overflow: hidden;
}

.accordion-item {
  border-color: rgba(0, 0, 0, 0.06);
}

.accordion-button {
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: -0.01em;
  color: var(--bs-body-color);
}

.accordion-button:not(.collapsed) {
  background-color: rgba(79, 70, 229, 0.04);
  color: var(--brand-primary);
  box-shadow: none;
}

.accordion-button:focus {
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
  border-color: var(--brand-primary);
}

.accordion-body {
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--bs-secondary-color);
}

/* ---------- Breadcrumbs ---------- */
.breadcrumb {
  font-size: 0.8125rem;
  padding: 0;
  margin-bottom: 1.5rem;
  font-weight: 500;
  min-height: 44px;
  align-items: center;
}

.breadcrumb-item a {
  color: var(--bs-secondary-color);
  text-decoration: none;
  transition: color 0.15s ease;
}


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

.breadcrumb-item.active {
  color: var(--bs-body-color);
  font-weight: 600;
}

/* ---------- Badges ---------- */
.badge {
  font-weight: 600;
  font-size: 0.6875rem;
  letter-spacing: 0.02em;
  padding: 0.35em 0.75em;
}

.badge.bg-primary {
  background-color: var(--brand-primary) !important;
}

.badge.bg-primary-subtle {
  background-color: rgba(79, 70, 229, 0.08) !important;
  color: var(--brand-primary) !important;
}

/* ---------- Category Filter Bar ---------- */
.category-filter-bar .input-group {
  border-radius: var(--brand-radius);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.1);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.category-filter-bar .input-group:focus-within {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.category-filter-bar .input-group-text {
  border: none;
  padding-left: 1rem;
}

.category-filter-bar .form-control {
  border: none;
  font-size: 0.9375rem;
  padding: 0.625rem 0.75rem;
  min-height: 44px;
}

.category-filter-bar .form-control:focus {
  box-shadow: none;
}

.category-sort-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--brand-radius-sm) !important;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.category-sort-btn.active {
  background-color: var(--brand-primary) !important;
  color: #fff !important;
  border-color: var(--brand-primary) !important;
}

.category-sort-btn:not(.active):hover {
  background-color: rgba(79, 70, 229, 0.06);
  color: var(--brand-primary);
}

[data-bs-theme="dark"] .category-filter-bar .input-group {
  border-color: rgba(255, 255, 255, 0.1);
}

/* ---------- Related Tools ---------- */
.related-tools {
  margin-top: 3.5rem;
  padding-top: 2.5rem;
  border-top: 2px solid rgba(0, 0, 0, 0.06);
}

/* ---------- Trust Cards (Homepage) ---------- */
.trust-card {
  border-radius: var(--brand-radius-lg) !important;
  border: 1px solid rgba(0, 0, 0, 0.04) !important;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.trust-card .card-body {
  padding: 2rem 1.5rem;
}

.trust-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

/* ---------- Hero Section ---------- */
.hero-section {
  padding: 4rem 0 3rem;
}

.hero-section .lead {
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.hero-search .input-group {
  border-radius: var(--brand-radius-lg);
  box-shadow: var(--brand-shadow-lg);
  border: 2px solid rgba(0, 0, 0, 0.06);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

/* Border-radius on first/last children instead of overflow:hidden (which clips dropdown) */
.hero-search .input-group > :first-child {
  border-top-left-radius: var(--brand-radius-lg) !important;
  border-bottom-left-radius: var(--brand-radius-lg) !important;
}
.hero-search .input-group > :last-child:not(.search-dropdown) {
  border-top-right-radius: var(--brand-radius-lg) !important;
  border-bottom-right-radius: var(--brand-radius-lg) !important;
}

.hero-search .input-group:focus-within {
  border-color: var(--brand-primary);
  box-shadow: var(--brand-shadow-lg), 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.hero-search .input-group-text {
  background: var(--bs-body-bg);
  border: none;
  padding-left: 1.25rem;
}

.hero-search .form-control {
  border: none;
  font-size: 1.0625rem;
  padding: 0.875rem 0.5rem;
}

.hero-search .form-control:focus {
  box-shadow: none;
}

.hero-search .btn-primary {
  border: none;
  border-radius: 0;
  padding: 0.875rem 1.75rem;
  font-weight: 600;
  background: var(--brand-primary);
}

.hero-search .btn-primary:hover {
  background: var(--brand-primary-hover);
}

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.12);
  border-radius: 100px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #047857;
  white-space: nowrap;
}

/* ---------- Footer ---------- */
footer {
  font-size: 0.875rem;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.footer-heading {
  text-transform: uppercase;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--bs-secondary-color);
  margin-bottom: 1rem;
}

footer li a {
  text-decoration: none;
  transition: color 0.15s ease;
  display: inline-block;
  padding: 0.5rem 0;
  min-height: 44px;
}

footer a:hover {
  color: var(--brand-primary) !important;
}

footer .footer-brand {
  font-weight: 800;
  font-size: 1.125rem;
  color: var(--brand-primary);
  letter-spacing: -0.02em;
}

footer hr {
  border-color: rgba(0, 0, 0, 0.06);
}

/* ---------- Dark Mode ---------- */
/* Dark mode primary palette:
   #818cf8 (indigo-400) — primary text/icons, ~6.4:1 on #212529 ✓ WCAG AA
   #a5b4fc (indigo-300) — code/subtle highlights, ~8.5:1 ✓ WCAG AAA
   #c7d2fe (indigo-200) — high-contrast where needed, ~11:1
   #4f46e5 (indigo-600) — buttons/fills, 6.3:1 with white text ✓ WCAG AA  */

[data-bs-theme="dark"] {
  --brand-primary: #818cf8;
  --brand-primary-hover: #a5b4fc;
  --brand-primary-light: rgba(129, 140, 248, 0.15);
  --bs-primary: #818cf8;
  --bs-primary-rgb: 129, 140, 248;
  --bs-link-color: #818cf8;
  --bs-link-color-rgb: 129, 140, 248;
  --bs-link-hover-color: #a5b4fc;
  --bs-link-hover-color-rgb: 165, 180, 252;
}

/* --- Dark: Global text-primary & bg-primary --- */
[data-bs-theme="dark"] .text-primary {
  color: #818cf8 !important;
}

[data-bs-theme="dark"] .bg-primary {
  background-color: #4f46e5 !important;
}

/* --- Dark: Buttons --- */
[data-bs-theme="dark"] .btn-primary {
  --bs-btn-bg: #4f46e5;
  --bs-btn-border-color: #4f46e5;
  --bs-btn-hover-bg: #818cf8;
  --bs-btn-hover-border-color: #818cf8;
  --bs-btn-active-bg: #a5b4fc;
  --bs-btn-active-border-color: #a5b4fc;
  --bs-btn-active-color: #1e1b4b;
  --bs-btn-disabled-bg: #4f46e5;
  --bs-btn-disabled-border-color: #4f46e5;
}

[data-bs-theme="dark"] .btn-outline-primary {
  --bs-btn-color: #818cf8;
  --bs-btn-border-color: #818cf8;
  --bs-btn-hover-bg: #818cf8;
  --bs-btn-hover-border-color: #818cf8;
  --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: #a5b4fc;
  --bs-btn-active-border-color: #a5b4fc;
  --bs-btn-active-color: #1e1b4b;
}

/* --- Dark: Badges --- */
[data-bs-theme="dark"] .badge.bg-primary {
  background-color: #4f46e5 !important;
  color: #fff !important;
}

[data-bs-theme="dark"] .badge.bg-primary-subtle {
  background-color: rgba(129, 140, 248, 0.15) !important;
  color: #a5b4fc !important;
}

/* Bootstrap's own primary-subtle badges in dark mode */
[data-bs-theme="dark"] .text-primary-emphasis {
  color: #a5b4fc !important;
}

[data-bs-theme="dark"] .bg-primary-subtle {
  background-color: rgba(129, 140, 248, 0.15) !important;
}

/* --- Dark: Bootstrap text helpers — boost contrast to pass WCAG AA --- */
[data-bs-theme="dark"] .text-body-tertiary {
  color: rgba(255, 255, 255, 0.55) !important; /* ~5.5:1 on #212529 ✓ AA */
}

[data-bs-theme="dark"] .text-body-secondary {
  color: rgba(255, 255, 255, 0.65) !important; /* ~6.5:1 on #212529 ✓ AA */
}

/* --- Dark: Navbar --- */
[data-bs-theme="dark"] .navbar {
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

[data-bs-theme="dark"] .navbar-brand {
  color: #818cf8 !important;
}

[data-bs-theme="dark"] .nav-link:hover {
  background-color: rgba(129, 140, 248, 0.1);
  color: #a5b4fc !important;
}

[data-bs-theme="dark"] .navbar .form-control {
  border-color: rgba(255, 255, 255, 0.12);
}

[data-bs-theme="dark"] .navbar .form-control:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
}

/* --- Dark: Nav pills / tabs --- */
[data-bs-theme="dark"] .nav-pills {
  --bs-nav-pills-link-active-bg: #4f46e5;
}

[data-bs-theme="dark"] .nav-pills .nav-link.active,
[data-bs-theme="dark"] .nav-pills .show > .nav-link {
  background-color: #4f46e5;
  color: #fff;
}

[data-bs-theme="dark"] .nav-pills .nav-link:not(.active) {
  color: #818cf8;
}

[data-bs-theme="dark"] .nav-pills .nav-link:not(.active):hover {
  color: #a5b4fc;
  background-color: rgba(129, 140, 248, 0.1);
}

[data-bs-theme="dark"] .nav-tabs .nav-link.active,
[data-bs-theme="dark"] .nav-tabs .nav-item.show .nav-link {
  color: #818cf8;
  border-bottom-color: #818cf8;
}

[data-bs-theme="dark"] .nav-tabs .nav-link:hover {
  color: #a5b4fc;
}

/* --- Dark: Tool cards --- */
[data-bs-theme="dark"] .tool-card {
  border-color: rgba(255, 255, 255, 0.08) !important;
  background: var(--bs-body-bg);
}

[data-bs-theme="dark"] .tool-card:hover {
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4) !important;
  border-color: rgba(129, 140, 248, 0.3) !important;
}

[data-bs-theme="dark"] .tool-card .text-primary.fw-semibold {
  color: #818cf8 !important;
}

[data-bs-theme="dark"] .tool-card:hover .text-primary.fw-semibold {
  color: #a5b4fc !important;
}

/* --- Dark: Outline button contrast --- */
[data-bs-theme="dark"] .btn-outline-secondary {
  --bs-btn-color: rgba(255, 255, 255, 0.7);
  --bs-btn-border-color: rgba(255, 255, 255, 0.3);
  --bs-btn-hover-bg: rgba(255, 255, 255, 0.12);
  --bs-btn-hover-border-color: rgba(255, 255, 255, 0.5);
  --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: rgba(255, 255, 255, 0.18);
  --bs-btn-active-border-color: rgba(255, 255, 255, 0.6);
  --bs-btn-active-color: #fff;
}

[data-bs-theme="dark"] .btn-outline-danger {
  --bs-btn-color: #f87171;
  --bs-btn-border-color: #f87171;
  --bs-btn-hover-bg: rgba(248, 113, 113, 0.15);
  --bs-btn-hover-border-color: #fca5a5;
  --bs-btn-hover-color: #fca5a5;
  --bs-btn-active-bg: rgba(248, 113, 113, 0.25);
  --bs-btn-active-border-color: #fca5a5;
  --bs-btn-active-color: #fca5a5;
}

/* --- Dark: Tool area --- */
[data-bs-theme="dark"] .tool-area {
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

[data-bs-theme="dark"] .tool-area .form-control,
[data-bs-theme="dark"] .tool-area .form-select {
  border-color: rgba(255, 255, 255, 0.12);
}

[data-bs-theme="dark"] .tool-area .form-control:focus,
[data-bs-theme="dark"] .tool-area .form-select:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
}

[data-bs-theme="dark"] .tool-area .btn-primary {
  background: #4f46e5;
  border-color: #4f46e5;
  box-shadow: 0 1px 2px rgba(99, 102, 241, 0.3);
}

[data-bs-theme="dark"] .tool-area .btn-primary:hover {
  background: #818cf8;
  border-color: #818cf8;
  box-shadow: 0 4px 12px rgba(129, 140, 248, 0.35);
}

/* --- Dark: Result display --- */
[data-bs-theme="dark"] .result-display {
  color: #a5b4fc;
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.1), rgba(6, 182, 212, 0.1));
  border-color: rgba(129, 140, 248, 0.2);
}

/* --- Dark: Input group --- */
[data-bs-theme="dark"] .input-group-text {
  background: var(--bs-body-bg);
}

/* --- Dark: Hero section --- */
[data-bs-theme="dark"] .hero-search .input-group {
  border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .hero-search .input-group:focus-within {
  border-color: #818cf8;
  box-shadow: var(--brand-shadow-lg), 0 0 0 3px rgba(129, 140, 248, 0.15);
}

[data-bs-theme="dark"] .hero-search .btn-primary {
  background: #4f46e5;
}

[data-bs-theme="dark"] .hero-search .btn-primary:hover {
  background: #818cf8;
}

/* --- Dark: Tables --- */
[data-bs-theme="dark"] .tool-content table {
  border-color: rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] .tool-content thead {
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.08), rgba(129, 140, 248, 0.12));
}

[data-bs-theme="dark"] .tool-content thead th {
  border-bottom-color: rgba(129, 140, 248, 0.2);
}

[data-bs-theme="dark"] .tool-content tbody td {
  border-bottom-color: rgba(255, 255, 255, 0.04);
}

[data-bs-theme="dark"] .tool-content tbody tr:hover {
  background-color: rgba(129, 140, 248, 0.06);
}

/* --- Dark: Code & blockquote --- */
[data-bs-theme="dark"] .tool-content code {
  background: rgba(129, 140, 248, 0.12);
  color: #a5b4fc;
}

[data-bs-theme="dark"] .tool-content blockquote {
  border-left-color: #818cf8;
  background: rgba(129, 140, 248, 0.06);
}

/* --- Dark: Content markers & section labels --- */
[data-bs-theme="dark"] .tool-content li::marker {
  color: #818cf8;
}

[data-bs-theme="dark"] .section-label {
  color: #818cf8;
}

/* --- Dark: Category cards --- */
[data-bs-theme="dark"] .category-sort-btn.active {
  background-color: #4f46e5 !important;
  border-color: #4f46e5 !important;
}

[data-bs-theme="dark"] .category-sort-btn:not(.active):hover {
  background-color: rgba(129, 140, 248, 0.1);
  color: #818cf8;
}

[data-bs-theme="dark"] .category-filter-bar .input-group {
  border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .category-filter-bar .input-group:focus-within {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.15);
}

/* --- Dark: Trust cards & privacy badge --- */
[data-bs-theme="dark"] .trust-card {
  border-color: rgba(255, 255, 255, 0.06) !important;
}

[data-bs-theme="dark"] .privacy-badge {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.25);
  color: #6ee7b7;
}

/* --- Dark: Accordions --- */
[data-bs-theme="dark"] .accordion-button:not(.collapsed) {
  background-color: rgba(129, 140, 248, 0.1);
  color: #a5b4fc;
}

[data-bs-theme="dark"] .accordion-button:focus {
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
  border-color: #818cf8;
}

/* --- Dark: Borders & dividers --- */
[data-bs-theme="dark"] .related-tools {
  border-top-color: rgba(255, 255, 255, 0.06);
}

[data-bs-theme="dark"] .tool-content h2 {
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

/* --- Dark: Footer --- */
[data-bs-theme="dark"] footer {
  border-top-color: rgba(255, 255, 255, 0.06);
}

[data-bs-theme="dark"] footer hr {
  border-color: rgba(255, 255, 255, 0.06);
}

[data-bs-theme="dark"] footer .footer-brand {
  color: #818cf8;
}

[data-bs-theme="dark"] footer a:hover {
  color: #818cf8 !important;
}

/* --- Dark: Breadcrumbs --- */
[data-bs-theme="dark"] .breadcrumb-item a:hover {
  color: #818cf8;
}

/* --- Dark: Sitemap --- */
[data-bs-theme="dark"] .sitemap-link:hover {
  color: #818cf8;
  background-color: rgba(129, 140, 248, 0.06);
}

/* --- Dark: Focus rings --- */
[data-bs-theme="dark"] a:focus-visible,
[data-bs-theme="dark"] button:focus-visible,
[data-bs-theme="dark"] input:focus-visible,
[data-bs-theme="dark"] select:focus-visible,
[data-bs-theme="dark"] textarea:focus-visible {
  outline-color: #818cf8;
}

/* --- Dark: Gradient text --- */
[data-bs-theme="dark"] .gradient-text {
  background: linear-gradient(135deg, #818cf8, #22d3ee);
}

/* --- Dark: Glass card --- */
[data-bs-theme="dark"] .glass-card {
  background: rgba(30, 30, 40, 0.7);
  border-color: rgba(255, 255, 255, 0.08);
}

/* ---------- Skip Link ---------- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 9999;
  padding: 0.5rem 1rem;
  background: var(--brand-primary);
  color: #fff;
  border-radius: var(--brand-radius);
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  top: 0.5rem;
}

/* ---------- Print ---------- */
@media print {
  .navbar, footer, .related-tools, .btn, #theme-toggle {
    display: none !important;
  }
  .tool-area {
    border: 1px solid #000;
    box-shadow: none;
  }
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .tool-card, .navbar, footer a, .trust-card, .category-card svg, .tool-area .btn-primary {
    transition: none !important;
  }
  .tool-card:hover {
    transform: none;
  }
}

/* ---------- Focus Visible ---------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
  :root {
    --section-gap: 3rem;
  }
}

@media (max-width: 768px) {
  :root {
    --section-gap: 2.5rem;
  }

  .tool-area {
    padding: 1.25rem;
    border-radius: var(--brand-radius);
  }

  .result-display {
    font-size: 1.25rem;
    padding: 0.75rem;
  }

  /* Clamp large Bootstrap font sizes inside tool areas on mobile */
  .tool-area .fs-1 { font-size: 1.75rem !important; }
  .tool-area .fs-2 { font-size: 1.5rem !important; }
  .tool-area .fs-3 { font-size: 1.25rem !important; }
  .tool-area .fs-4 { font-size: 1.125rem !important; }

  .display-5 {
    font-size: 1.75rem;
  }

  .hero-section {
    padding: 2.5rem 0 2rem;
  }

  .hero-search .input-group {
    border-radius: var(--brand-radius);
  }

  .tool-content h2 {
    font-size: 1.25rem;
    margin-top: 2rem;
  }

  .tool-content table {
    font-size: 0.8125rem;
  }

  .tool-content thead th,
  .tool-content tbody td {
    padding: 0.625rem 0.75rem;
  }
}

@media (max-width: 576px) {
  /* Converter swap button — fit inside col-2 */
  .tool-area .btn[id$="-swap"] {
    padding: 0.5rem;
    min-width: 44px;
    min-height: 44px;
    font-size: 1rem;
  }

  /* Ensure buttons wrap nicely */
  .tool-area .d-flex.gap-2 {
    flex-wrap: wrap;
  }

  /* Full-width primary buttons on small screens */
  .tool-area .btn-primary {
    flex: 1 1 auto;
  }

  .tool-card .card-body {
    padding: 1rem;
  }

  .category-card .card-body {
    padding: 1.25rem 0.75rem;
  }

  .tool-area {
    padding: 1rem;
  }

  .tool-area .card-body {
    padding: 1rem;
  }

  .result-display {
    font-size: 1rem;
    padding: 0.5rem;
  }

  /* Tighter font clamping on extra-small screens */
  .tool-area .fs-4 { font-size: 1rem !important; }
  .tool-area .fs-5 { font-size: 0.9375rem !important; }
  .tool-area .fs-6 { font-size: 0.875rem !important; }
}

/* ---------- Sitemap Page ---------- */
.sitemap-link {
  color: var(--bs-body-color);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.sitemap-link:hover {
  color: var(--brand-primary);
  background-color: rgba(79, 70, 229, 0.04);
}

/* ---------- Utility Classes ---------- */
.gradient-text {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.glass-card {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

[data-bs-theme="dark"] .glass-card {
  background: rgba(30, 30, 40, 0.7);
  border-color: rgba(255, 255, 255, 0.08);
}
