/* ==========================================================================
   DoxKing — header.css
   LANGUAGE-SAFE RESPONSIVE HEADER
   6 languages: English, Spanish, French, Italian, German, Arabic
   Desktop / Tablet / Mobile / RTL / Dark Mode
   ========================================================================== */

html,
body {
  margin: 0 !important;
  padding: 0 !important;
  overflow-x: clip !important;
  overflow-y: visible !important;
}

/* ==========================================================================
   HEADER
   ========================================================================== */

#header-container {
  position: -webkit-sticky !important;
  position: sticky !important;
  top: 0 !important;
  left: 0;
  right: 0;
  z-index: 900 !important;
  width: 100%;
  margin: 0 !important;
  padding: 0 !important;
  background: var(--card);
}

.site-header {
  position: relative;
  width: 100%;
  margin: 0 !important;
  padding: 0 !important;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

/* ==========================================================================
   HEADER BAR
   ========================================================================== */

.header-bar {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 1400px;
  min-width: 0;
  min-height: 60px;
  margin: 0 auto;
  padding: 8px 16px;
  box-sizing: border-box;
  gap: 10px;
  position: relative;
  z-index: 2;
}

/* ==========================================================================
   LOGO
   ========================================================================== */

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: max-content;
  flex: 0 0 auto;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--ink);
  text-decoration: none;
}

.logo:hover {
  text-decoration: none;
}

.logo-mark {
  display: inline-flex;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
}

.logo-mark svg {
  width: 100%;
  height: 100%;
}

/* ==========================================================================
   MAIN NAV
   ========================================================================== */

.main-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0 4px;
  gap: 2px;
}

.main-nav > .nav-link,
.main-nav > .nav-item {
  min-width: 0;
  flex: 0 1 auto;
}

/* ==========================================================================
   NAV LINKS
   ========================================================================== */

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
  padding: 6px 8px;
  box-sizing: border-box;
  font-size: clamp(0.68rem, 0.62rem + 0.16vw, 0.82rem);
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid transparent !important;
  border-radius: 8px;
  background: transparent !important;
  white-space: nowrap;
  cursor: pointer;
  transition:
    color 0.18s ease,
    border-color 0.18s ease;
}

.nav-link:hover {
  color: var(--primary);
  background: transparent !important;
  border-color: var(--primary) !important;
  text-decoration: none;
}

.nav-link svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.main-nav > .nav-link.is-current,
.main-nav > .nav-link.is-active {
  border-color: var(--primary) !important;
}

.nav-link.is-current,
.nav-link.is-active {
  color: var(--ink);
  background: transparent !important;
}

/* ==========================================================================
   NAV ITEMS / PARENT MENUS
   ========================================================================== */

.nav-item {
  position: relative;
  min-width: 0;
}

.nav-item > .nav-link::after {
  content: "";
  width: 0;
  height: 0;
  margin-inline-start: 3px;
  flex: 0 0 auto;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-top: 3px solid currentColor;
  opacity: 0.5;
  transition: transform 0.2s ease;
}

.nav-item.expanded > .nav-link::after {
  transform: rotate(180deg);
}

.main-nav .nav-item:has(.mega-grid a.is-current) > .nav-link {
  border-color: var(--primary) !important;
}

/* ==========================================================================
   MEGA PANEL
   ========================================================================== */

.mega-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-30%);
  width: max-content;
  min-width: min(320px, calc(100vw - 24px));
  max-width: min(720px, calc(100vw - 24px));
  box-sizing: border-box;
  margin-top: 8px;
  padding: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.18s ease,
    visibility 0.18s ease;
  z-index: 100;
}

.nav-item.open > .mega-panel,
.nav-item:hover > .mega-panel {
  opacity: 1;
  visibility: visible;
}

/* Keep the panel inside the viewport near the edges. */

.nav-item:first-child .mega-panel {
  left: 0;
  transform: none;
}

.nav-item:last-child .mega-panel {
  left: auto;
  right: 0;
  transform: none;
}

/* ==========================================================================
   MEGA GRID
   ========================================================================== */

.mega-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  gap: 3px;
  min-width: 0;
}

/* DoxKing all-tools menu: responsive three-column layout */
@media (min-width: 1100px) {
  .mega-panel:has(.mega-grid) { min-width: min(760px, calc(100vw - 32px)); max-width: calc(100vw - 32px); }
  .mega-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 769px) and (max-width: 1099px) {
  .mega-panel:has(.mega-grid) { min-width: min(620px, calc(100vw - 24px)); max-width: calc(100vw - 24px); }
  .mega-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}


.mega-grid a {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
  padding: 8px 10px;
  box-sizing: border-box;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid transparent !important;
  border-radius: 8px;
  background: transparent !important;
  min-height: 36px;
  transition:
    color 0.15s ease,
    border-color 0.15s ease;
}

.mega-grid a:hover {
  color: var(--primary);
  background: transparent !important;
  border-color: var(--primary) !important;
  text-decoration: none;
}

.mega-grid a.is-current {
  color: var(--primary) !important;
  background: transparent !important;
  font-weight: 600;
  border-color: var(--primary) !important;
}

.mega-grid a svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  margin-top: 0;
  color: var(--primary);
}

/* ==========================================================================
   HEADER ACTIONS
   IMPORTANT:
   No negative margins — they caused language-dependent overflow.
   ========================================================================== */

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  min-width: 0;
  gap: 6px;
  margin: 0;
  padding: 0;
  position: relative;
  z-index: 999;
}

/* ==========================================================================
   SEARCH BAR
   ========================================================================== */

.search-bar {
  display: flex;
  align-items: center;
  flex: 0 1 170px;
  width: 170px;
  max-width: 200px;
  min-width: 90px;
  height: 36px;
  padding: 0 10px;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: border-color 0.15s ease;
}

.search-bar:hover,
.search-bar:focus-within {
  border-color: var(--primary);
}

.search-bar:focus-within {
  z-index: 2;
}

.search-bar input {
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  border: none;
  outline: none;
  padding: 0 5px;
  background: transparent;
  color: var(--ink);
  font-size: 0.82rem;
}

.search-bar input::placeholder {
  color: var(--ink-soft);
}

.search-bar-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 3px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}

.search-bar-icon svg {
  width: 15px;
  height: 15px;
}

/* ==========================================================================
   LANGUAGE SWITCHER
   ========================================================================== */

.lang-switcher {
  position: relative;
  z-index: 1000;
  flex: 0 0 auto;
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: auto;
  min-width: 36px;
  height: 36px;
  padding: 0 9px;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  z-index: 1001;
  pointer-events: auto !important;
  transition:
    border-color 0.18s ease,
    color 0.18s ease;
}

.lang-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: transparent;
}

.lang-btn svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  pointer-events: none;
}

.lang-current {
  pointer-events: none;
}

/* ==========================================================================
   LANGUAGE MENU
   ========================================================================== */

.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  min-width: 200px;
  max-width: min(280px, calc(100vw - 20px));
  max-height: 400px;
  overflow-y: auto;
  padding: 6px;
  box-sizing: border-box;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition:
    opacity 0.15s ease,
    transform 0.15s ease,
    visibility 0.15s ease;
  z-index: 99999;
  pointer-events: none;
}

.lang-menu.open {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) !important;
  pointer-events: auto !important;
}

.lang-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-width: 0;
  padding: 8px 12px;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-size: 0.86rem;
  cursor: pointer;
  text-align: start;
  transition:
    color 0.12s ease,
    border-color 0.12s ease;
}

.lang-item:hover {
  color: var(--primary);
  background: transparent;
  border-color: var(--primary);
}

.lang-item.is-active {
  color: var(--primary);
  background: transparent;
  font-weight: 600;
  border-color: var(--primary);
}

.lang-name {
  font-weight: 500;
  min-width: 0;
}

.lang-code {
  flex: 0 0 auto;
  margin-inline-start: 8px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--ink-soft);
  font-size: 0.7rem;
  font-weight: 600;
  font-family: ui-monospace, monospace;
  text-transform: uppercase;
}

/* ==========================================================================
   THEME / MENU BUTTONS
   ========================================================================== */

.theme-toggle,
.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  padding: 0;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  position: relative;
  z-index: 999;
  transition:
    border-color 0.18s ease,
    color 0.18s ease;
}

.theme-toggle:hover,
.menu-toggle:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: transparent;
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
}

.theme-toggle .icon-moon {
  display: none;
}

html[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}

html[data-theme="dark"] .theme-toggle .icon-moon {
  display: block;
}

/* ==========================================================================
   DESKTOP COMPACT MODE
   1101–1280px
   ========================================================================== */

@media (min-width: 1101px) and (max-width: 1280px) {

  .header-bar {
    gap: 6px;
    padding: 7px 10px;
  }

  .logo {
    gap: 6px;
    font-size: 0.96rem;
  }

  .logo-mark {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
  }

  .main-nav {
    gap: 0;
    margin: 0 2px;
  }

  .nav-link {
    gap: 3px;
    padding: 5px 5px;
    font-size: 0.68rem;
    border-radius: 7px;
  }

  .nav-link svg {
    width: 12px;
    height: 12px;
  }

  .search-bar {
    flex-basis: 125px;
    width: 125px;
    max-width: 125px;
    height: 34px;
    padding-inline: 7px;
  }

  .search-bar input {
    font-size: 0.75rem;
  }

  .lang-btn {
    height: 34px;
    padding-inline: 7px;
  }

  .theme-toggle,
  .menu-toggle {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }
}

/* ==========================================================================
   LARGE DESKTOP
   ========================================================================== */

@media (min-width: 1400px) {

  .header-bar {
    min-height: 68px;
    padding: 9px 16px;
    gap: 12px;
  }

  .logo {
    font-size: 1.08rem;
  }

  .main-nav {
    gap: 2px;
  }

  .nav-link {
    padding-inline: 8px;
    font-size: 0.78rem;
  }

  .search-bar {
    width: 190px;
    flex-basis: 190px;
    max-width: 210px;
  }
}

/* ==========================================================================
   TABLET / MOBILE
   Use one stable breakpoint so translated labels never compete with
   desktop navigation.
   ========================================================================== */

@media (max-width: 1100px) {

  .header-bar {
    min-height: 60px;
    gap: 8px;
    padding: 8px 12px;
    flex-wrap: nowrap;
    overflow: visible;
  }

  .logo {
    min-width: max-content;
    gap: 6px;
    font-size: 1rem;
  }

  .logo-mark {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
  }

  .main-nav {
    display: none;
  }

  .header-actions {
    flex: 1 1 auto;
    min-width: 0;
    gap: 5px;
  }

  .search-bar {
    order: -1;
    flex: 1 1 220px;
    width: auto;
    max-width: 280px;
    min-width: 0;
    height: 36px;
  }

  .search-bar input {
    display: block !important;
    font-size: 0.82rem;
  }

  .search-bar input::placeholder {
    font-size: 0.78rem;
  }

  .lang-btn,
  .theme-toggle,
  .menu-toggle {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
    padding: 0;
  }

  .lang-current {
    display: none;
  }

  /* ------------------------------------------------------------------------
     MOBILE MAIN NAV
     ------------------------------------------------------------------------ */

  .main-nav.open {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: auto;
    margin: 0;
    padding: 14px 14px 36px;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    gap: 5px;
    background: var(--card);
    border: none;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
    z-index: 850;
  }

  .main-nav.open > .nav-link,
  .main-nav.open > .nav-item {
    width: 100%;
    max-width: none;
    flex: 0 0 auto;
  }

  .nav-link {
    width: 100%;
    max-width: none;
    min-height: 46px;
    padding: 12px 14px;
    justify-content: flex-start;
    font-size: 0.96rem;
    font-weight: 700;
    line-height: 1.3;
    white-space: normal;
    text-align: start;
    background: var(--bg) !important;
    border: 1px solid var(--border) !important;
    border-radius: 11px;
  }

  .nav-link svg {
    width: 16px;
    height: 16px;
  }

  .nav-link:hover {
    color: var(--primary);
    border-color: var(--primary) !important;
    background: var(--bg) !important;
  }

  .main-nav > .nav-link.is-current,
  .main-nav > .nav-link.is-active,
  .main-nav .nav-item:has(.mega-grid a.is-current) > .nav-link {
    background: var(--bg) !important;
    border-color: var(--primary) !important;
  }

  .nav-item > .nav-link::after {
    margin-inline-start: auto;
  }

  /* ------------------------------------------------------------------------
     MOBILE MEGA MENU
     ------------------------------------------------------------------------ */

  .mega-panel {
    position: static;
    width: auto;
    min-width: 0;
    max-width: none;
    margin: 0 0 6px;
    padding: 0;
    transform: none;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    max-height: 0;
    overflow: hidden;
    opacity: 1;
    visibility: visible;
    transition:
      max-height 0.35s ease,
      padding 0.35s ease;
  }

  .nav-item.open > .mega-panel,
  .nav-item.expanded > .mega-panel {
    max-height: 5000px;
    padding: 6px 0 8px;
  }

  .mega-grid {
    grid-template-columns: 1fr;
    gap: 2px;
    width: 100%;
    padding-inline-start: 12px;
    border-inline-start: 2px solid var(--border);
    box-sizing: border-box;
  }

  .mega-grid a {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    font-size: 0.88rem;
    line-height: 1.35;
    color: var(--ink-soft);
    background: transparent !important;
    border: 1px solid transparent !important;
    border-radius: 8px;
  }

  .mega-grid a:hover {
    color: var(--primary);
    background: transparent !important;
    border-color: var(--primary) !important;
  }

  .mega-grid a.is-current {
    color: var(--primary) !important;
    background: transparent !important;
    border-color: var(--primary) !important;
  }

  .mega-grid a svg {
    width: 15px;
    height: 15px;
    margin-top: 1px;
  }

  /* ------------------------------------------------------------------------
     MOBILE LANGUAGE MENU
     ------------------------------------------------------------------------ */

  .lang-menu {
    position: fixed;
    top: 66px;
    inset-inline-end: 12px;
    min-width: 200px;
    max-width: calc(100vw - 24px);
    max-height: 70vh;
  }

  body.menu-open {
    overflow: hidden;
  }

  body.menu-open .sidebar-toggle {
    display: none !important;
  }
}

/* ==========================================================================
   SMALL MOBILE
   ========================================================================== */

@media (max-width: 700px) {

  .header-bar {
    min-height: 56px;
    gap: 5px;
    padding: 7px 9px;
  }

  .logo {
    gap: 5px;
    font-size: 0.94rem;
  }

  .logo-mark {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
  }

  .header-actions {
    gap: 4px;
  }

  .search-bar {
    flex: 1 1 auto;
    max-width: none;
    height: 34px;
    padding-inline: 6px;
  }

  .search-bar input {
    font-size: 0.76rem;
  }

  .search-bar input::placeholder {
    font-size: 0.70rem;
  }

  .search-bar-icon svg {
    width: 14px;
    height: 14px;
  }

  .lang-btn,
  .theme-toggle,
  .menu-toggle {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  .lang-btn svg {
    width: 13px;
    height: 13px;
  }

  .theme-toggle svg {
    width: 15px;
    height: 15px;
  }

  .main-nav.open {
    top: 56px;
    padding: 12px 10px 30px;
  }

  .nav-link {
    min-height: 44px;
    padding: 11px 12px;
    font-size: 0.92rem;
  }

  .mega-grid {
    padding-inline-start: 10px;
  }

  .mega-grid a {
    padding: 10px;
    font-size: 0.86rem;
  }

  .lang-menu {
    top: 54px;
    inset-inline-end: 9px;
  }
}

/* ==========================================================================
   VERY SMALL MOBILE
   ========================================================================== */

@media (max-width: 420px) {

  .header-bar {
    gap: 4px;
    padding-inline: 7px;
  }

  .logo {
    font-size: 0.88rem;
  }

  .logo-mark {
    width: 26px;
    height: 26px;
    flex-basis: 26px;
  }

  .header-actions {
    gap: 3px;
  }

  .search-bar {
    min-width: 0;
  }

  .search-bar input::placeholder {
    font-size: 0.66rem;
  }

  .lang-btn,
  .theme-toggle,
  .menu-toggle {
    width: 31px;
    height: 31px;
    flex-basis: 31px;
    border-radius: 8px;
  }
}

/* ==========================================================================
   RTL / ARABIC
   Use logical properties so Arabic does not require a second header CSS.
   ========================================================================== */

html[dir="rtl"] .header-bar,
html[dir="rtl"] .site-header {
  direction: rtl;
}

html[dir="rtl"] .main-nav,
html[dir="rtl"] .header-actions {
  direction: rtl;
}

html[dir="rtl"] .nav-link {
  text-align: right;
}

html[dir="rtl"] .nav-item > .nav-link::after {
  margin-inline-start: auto;
  margin-inline-end: 4px;
}

html[dir="rtl"] .mega-grid {
  direction: rtl;
}

html[dir="rtl"] .mega-grid a {
  text-align: right;
}

html[dir="rtl"] .mega-panel {
  direction: rtl;
}

html[dir="rtl"] .lang-menu {
  text-align: right;
}

@media (min-width: 1101px) {

  html[dir="rtl"] .nav-item:first-child .mega-panel {
    left: auto;
    right: 0;
  }

  html[dir="rtl"] .nav-item:last-child .mega-panel {
    right: auto;
    left: 0;
  }
}

@media (max-width: 1100px) {

  html[dir="rtl"] .main-nav.open {
    text-align: right;
  }

  html[dir="rtl"] .mega-grid {
    padding-inline-start: 0;
    padding-inline-end: 12px;
    border-inline-start: none;
    border-inline-end: 2px solid var(--border);
  }
}

/* ==========================================================================
   DARK MODE
   ========================================================================== */

html[data-theme="dark"] .nav-link {
  color: #e5e7eb;
  background: transparent !important;
  border-color: transparent !important;
  text-shadow: none;
  filter: none;
}

html[data-theme="dark"] .nav-link svg {
  color: #cbd5e1;
  filter: none;
  text-shadow: none;
}

html[data-theme="dark"] .nav-link:hover {
  color: var(--primary);
  background: transparent !important;
  border-color: var(--primary) !important;
}

html[data-theme="dark"] .nav-link:hover svg {
  color: var(--primary);
}

html[data-theme="dark"] .main-nav > .nav-link.is-current,
html[data-theme="dark"] .main-nav > .nav-link.is-active,
html[data-theme="dark"] .main-nav .nav-item:has(.mega-grid a.is-current) > .nav-link {
  color: #fff !important;
  background: transparent !important;
  border-color: var(--primary) !important;
}

html[data-theme="dark"] .nav-link.is-current svg,
html[data-theme="dark"] .nav-link.is-active svg {
  color: var(--primary);
}

html[data-theme="dark"] .mega-grid a {
  color: #e5e7eb;
  background: transparent !important;
  border-color: transparent !important;
  text-shadow: none;
  filter: none;
}

html[data-theme="dark"] .mega-grid a svg {
  color: #cbd5e1;
  opacity: 1;
}

html[data-theme="dark"] .mega-grid a:hover {
  color: var(--primary) !important;
  background: transparent !important;
  border-color: var(--primary) !important;
}

html[data-theme="dark"] .mega-grid a:hover svg {
  color: var(--primary);
}

html[data-theme="dark"] .mega-grid a.is-current {
  color: var(--primary) !important;
  background: transparent !important;
  border-color: var(--primary) !important;
}

html[data-theme="dark"] .mega-grid a.is-current svg {
  color: var(--primary);
  opacity: 1;
}

html[data-theme="dark"] .site-header .mega-panel,
html[data-theme="dark"] .site-header .lang-menu {
  border-color: #2a2a2a;
}

html[data-theme="dark"] .lang-item {
  color: #e5e7eb;
  border-color: transparent;
  text-shadow: none;
}

html[data-theme="dark"] .lang-item:hover {
  color: var(--primary);
  background: transparent;
  border-color: var(--primary);
}

html[data-theme="dark"] .lang-item.is-active {
  color: var(--primary);
  background: transparent;
  border-color: var(--primary);
}

html[data-theme="dark"] .theme-toggle,
html[data-theme="dark"] .menu-toggle,
html[data-theme="dark"] .lang-btn {
  color: #e5e7eb;
  text-shadow: none;
  filter: none;
}

html[data-theme="dark"] .theme-toggle:hover,
html[data-theme="dark"] .menu-toggle:hover,
html[data-theme="dark"] .lang-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: transparent;
}

html[data-theme="dark"] .search-bar {
  box-shadow: none;
}

html[data-theme="dark"] .search-bar:hover,
html[data-theme="dark"] .search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: none;
}

html[data-theme="dark"] .site-header *::before,
html[data-theme="dark"] .site-header *::after {
  text-shadow: none;
  filter: none;
}

/* ==========================================================================
   DARK MODE — MOBILE
   ========================================================================== */

@media (max-width: 1100px) {

  html[data-theme="dark"] .main-nav.open {
    background: var(--card);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  }

  html[data-theme="dark"] .main-nav.open .nav-link {
    background: var(--bg) !important;
    border-color: #2a2a2a !important;
  }

  html[data-theme="dark"] .main-nav.open .nav-link:hover,
  html[data-theme="dark"] .main-nav.open .nav-link.is-current,
  html[data-theme="dark"] .main-nav.open .nav-link.is-active {
    background: var(--bg) !important;
    border-color: var(--primary) !important;
  }

  html[data-theme="dark"] .mega-grid a {
    color: #cbd5e1;
    background: transparent !important;
  }

  html[data-theme="dark"] .mega-grid a:hover {
    color: var(--primary);
    background: transparent !important;
    border-color: var(--primary) !important;
  }

  html[data-theme="dark"] .mega-grid a.is-current {
    color: var(--primary);
    background: transparent !important;
    border-color: var(--primary) !important;
  }
}

/* ==========================================================================
   ACCESSIBILITY / INTERACTION
   ========================================================================== */

.nav-link:focus-visible,
.mega-grid a:focus-visible,
.lang-btn:focus-visible,
.lang-item:focus-visible,
.theme-toggle:focus-visible,
.menu-toggle:focus-visible,
.search-bar:focus-within {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {

  .nav-link,
  .mega-grid a,
  .mega-panel,
  .lang-menu,
  .lang-item,
  .theme-toggle,
  .menu-toggle,
  .search-bar {
    transition: none !important;
  }
}

/* Custom DoxKing brand logo — favicon intentionally unchanged */
.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 0;
  width: 88px;
  height: 64px;
  gap: 0;
  overflow: visible;
}
.logo-image {
  display: block;
  width: 88px;
  height: 50px;
  max-width: 100%;
  object-fit: contain;
  object-position: center;
}
@media (max-width: 480px) {
  .logo { width: 68px; height: 56px; }
  .logo-image { width: 68px; height: 40px; }
}

/* Dark-mode logo: use the same dimensions and layout as the original logo. */
html[data-theme="dark"] .logo-image {
  content: url("/images/doxking-logo-dark.webp");
}


/* ==========================================================================
   TRANSLATED DESKTOP NAV — prevent overlap while keeping labels on one line
   Scoped to desktop so mobile navigation and all other functionality remain
   unchanged. Slightly tighter links and explicit inter-item breathing room
   allow longer translated labels to fit without wrapping.
   ========================================================================== */
@media (min-width: 1101px) {
  .header-bar {
    gap: clamp(5px, 0.55vw, 9px);
  }

  .main-nav {
    gap: clamp(2px, 0.18vw, 4px);
    margin-inline: 2px;
  }

  .main-nav > .nav-link,
  .main-nav > .nav-item {
    flex-shrink: 1;
  }

  .nav-link {
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
    gap: 3px;
    padding-inline: clamp(3px, 0.32vw, 6px);
    font-size: clamp(0.60rem, 0.54rem + 0.10vw, 0.72rem);
    line-height: 1.15;
  }

  .nav-item > .nav-link::after {
    margin-inline-start: 2px;
  }

  .header-actions {
    gap: clamp(4px, 0.35vw, 6px);
  }
}


/* ==========================================================================
   FINAL TRANSLATED HEADER BALANCE
   Only desktop header spacing is adjusted for longer translated labels.
   Navigation data, menu categories, links, and interactions remain untouched.
   ========================================================================== */
@media (min-width: 1101px) {
  .header-bar {
    gap: 5px;
  }

  .main-nav {
    flex: 1 1 0;
    min-width: 0;
    margin-inline: 0;
    gap: 3px;
    justify-content: space-between;
  }

  .main-nav > .nav-link,
  .main-nav > .nav-item {
    flex: 0 1 auto;
    min-width: 0;
  }

  .main-nav > .nav-item > .nav-link,
  .main-nav > .nav-link {
    padding-inline: 3px;
    gap: 3px;
    font-size: clamp(0.58rem, 0.48rem + 0.12vw, 0.68rem);
    white-space: nowrap;
    letter-spacing: 0;
  }

  .main-nav .nav-link svg {
    width: 13px;
    height: 13px;
    flex: 0 0 13px;
  }

  .header-actions {
    gap: 4px;
  }

  .search-bar {
    flex: 0 1 145px;
    width: 145px;
    min-width: 82px;
  }
}

/* Longer Latin-script translations receive compact desktop spacing;
   English and Arabic styles remain unchanged. */
@media (min-width: 1101px) {
  html[lang="fr"] .main-nav,
  html[lang="it"] .main-nav,
  html[lang="de"] .main-nav,
  html[lang="es"] .main-nav {
    gap: 2px;
  }

  html[lang="fr"] .main-nav .nav-link,
  html[lang="it"] .main-nav .nav-link,
  html[lang="de"] .main-nav .nav-link,
  html[lang="es"] .main-nav .nav-link {
    padding-inline: 2px;
    font-size: clamp(0.56rem, 0.46rem + 0.11vw, 0.65rem);
  }
}
