/* --- Variables --- */
:root {
  --header-height: 50px;
}

/* Header locally scoped mapping to Global vars */
.site-header,
.mobile-bottom-nav,
.dropdown-menu-custom {
  --hdr-hover-color: var(--primary-hover);
  --hdr-active-color: var(--primary-color);
  --hdr-text-dark: var(--theme-text-color);
  --hdr-text-light: var(--theme-text-color);
  --hdr-bg-white: var(--theme-bg-color);
  --hdr-border: var(--border-light);
}

/* Base Reset */
.site-header a,
.mobile-bottom-nav a {
  text-decoration: none;
}

/* Header Container */
.site-header {
  height: var(--header-height);
  background: var(--hdr-bg-white);
  border-bottom: none;
  position: sticky;
  top: 0;
  z-index: 1020;
  width: 100%;
  position: relative;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.site-header::after {
  content: "";
  display: none;
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0;
  background: transparent;
  z-index: 1021;
}

.global-breadcrumb-inline {
  width: 100%;
  margin: 0 0 12px 0;
}

.global-page-breadcrumb {
  margin-bottom: 0 !important;
}

/* Flex Layout Structure */
.header-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo {
  margin-right: 20px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.logo-text {
  font-size: 22px;
  font-weight: 800;
  color: var(--hdr-text-dark);
  letter-spacing: 0.5px;
}

/* Desktop Nav Wrapper */
.desktop-nav {
  display: flex;
  align-items: center;
  width: auto;
  gap: 20px;
}

/* Nav Links Group */
.nav-links-group {
  display: flex;
  gap: 20px;
  flex-shrink: 0;
}

.site-header .nav-link {
  color: var(--hdr-text-dark);
  font-size: 15px;
  font-weight: 500;
  padding: 0 5px;
  height: 50px;
  display: flex;
  align-items: center;
  position: relative;
  transition: color 0.2s;
  white-space: nowrap;
}

.site-header .nav-link:not(.active):hover {
  color: var(--hdr-hover-color) !important;
}

.site-header .nav-link.active {
  color: var(--hdr-active-color) !important;
  font-weight: bold;
}

.site-header .nav-link.active:hover {
  color: var(--hdr-active-color) !important;
}

.site-header .nav-link.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 3px;
  background-color: var(--hdr-active-color) !important;
  border-top-left-radius: 3px;
  border-top-right-radius: 3px;
  z-index: 1022;
}

/* Search Form - CENTERED */
.search-form {
  flex: 1 1 280px;
  max-width: 480px;
  margin: 0 32px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--hdr-bg-white);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 0 16px;
  height: 38px;
  overflow: hidden;
  box-shadow: none;
  transition: border-color 0.2s ease;
}

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

.site-header .search-form input[type="text"] {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  outline: none;
  padding: 0;
  margin: 0;
  font-size: 14px;
  width: 100%;
  min-width: 0;
  height: 100%;
  color: var(--theme-text-color) !important;
  -webkit-text-fill-color: var(--theme-text-color);
}

.site-header .search-form input[type="text"]:focus {
  box-shadow: none !important;
}

.site-header .search-form input[type="text"]::placeholder {
  color: var(--theme-text-color) !important;
  opacity: 0.7;
}

.site-header .search-form input[type="text"]::-webkit-input-placeholder {
  color: var(--theme-text-color) !important;
  opacity: 0.7;
}

.site-header .search-form input[type="text"]::-moz-placeholder {
  color: var(--theme-text-color) !important;
  opacity: 0.7;
}

.site-header .search-form input[type="text"]:-ms-input-placeholder {
  color: var(--theme-text-color) !important;
}

.site-header .search-form input[type="text"]::-ms-input-placeholder {
  color: var(--theme-text-color) !important;
}

.site-header .search-form button {
  border: none;
  background: transparent;
  color: var(--theme-text-color) !important;
  cursor: pointer;
  padding: 0;
  font-size: 16px;
}

.site-header .search-form button i {
  color: inherit !important;
}

/* Author & Auth Section (Right Side) */
.right-section {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-left: 0;
}

.author-link {
  font-size: 14px;
  color: var(--hdr-text-dark);
  transition: color 0.2s;
  white-space: nowrap;
  height: 50px;
  display: flex;
  align-items: center;
  position: relative;
}

.author-link:not(.active):hover {
  color: var(--hdr-hover-color) !important;
}

.author-link.active {
  color: var(--hdr-active-color) !important;
  font-weight: bold;
}

.author-link.active:hover {
  color: var(--hdr-active-color) !important;
}

.author-link.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 3px;
  background-color: var(--hdr-active-color) !important;
  border-top-left-radius: 3px;
  border-top-right-radius: 3px;
  z-index: 1022;
}

.auth-buttons {
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--border-color);
  white-space: nowrap;
}

.auth-buttons a {
  color: var(--hdr-text-light);
  transition: color 0.2s;
}

.auth-buttons a:hover {
  color: var(--hdr-hover-color) !important;
}

.divider {
  margin: 0 2px;
  font-size: 12px;
}

/* Logged In User Name Link */
.user-name-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  color: var(--hdr-text-dark) !important;
  height: 50px;
  position: relative;
}

.user-name-link i {
  font-size: 18px;
  color: var(--hdr-active-color) !important;
}

.user-name-link:not(.active):hover,
.user-name-link:not(.active):hover i {
  color: var(--hdr-hover-color) !important;
}

.user-name-link.active {
  color: var(--hdr-active-color) !important;
  font-weight: bold;
}

.user-name-link.active:hover {
  color: var(--hdr-active-color) !important;
}

.user-name-link.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 3px;
  background-color: var(--hdr-active-color) !important;
  border-top-left-radius: 3px;
  border-top-right-radius: 3px;
  z-index: 1022;
}

.user-name-text {
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  vertical-align: middle;
}

/* Mobile Elements */
.mobile-top-bar {
  display: none;
  position: relative;
  margin-left: auto;
}

.mobile-bottom-nav {
  display: none;
}

.user-trigger {
  font-size: 24px;
  color: var(--hdr-active-color) !important;
  cursor: pointer;
  padding: 5px;
}

.dropdown-menu-custom {
  display: none;
  position: absolute;
  right: 0;
  top: 45px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-md);
  width: 100px;
  flex-direction: column;
  z-index: 1030;
}

.dropdown-menu-custom a {
  padding: 12px;
  text-align: center;
  border-bottom: 1px solid var(--bg-body);
  color: var(--hdr-text-dark);
  display: block;
  transition:
    color 0.2s,
    background-color 0.2s;
}

.dropdown-menu-custom a:hover {
  color: var(--hdr-hover-color) !important;
  background-color: var(--interactive-hover-bg, var(--bg-body)) !important;
}

.dropdown-menu-custom.show {
  display: flex;
}

/* Mobile Bottom Nav */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 56px;
  background: var(--bg-card);
  border-top: 1px solid var(--hdr-border);
  display: none;
  justify-content: space-around;
  align-items: center;
  z-index: 1030;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.bottom-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--hdr-text-light);
  font-size: 11px;
  flex: 1;
  transition: color 0.2s;
}

.bottom-item:not(.active):hover {
  color: var(--hdr-hover-color) !important;
}

.bottom-item i {
  font-size: 20px;
  margin-bottom: 4px;
}

.bottom-item.active {
  color: var(--hdr-active-color) !important;
}

.bottom-item.active:hover {
  color: var(--hdr-active-color) !important;
}

/* BREAKPOINTS */
body.is-tablet {
  .search-form {
    margin: 0 16px;
    max-width: 360px;
  }
  .logo {
    margin-right: 15px;
  }
  .nav-links-group {
    gap: 10px;
  }
  .author-link {
    margin-right: 15px;
  }
}

body.is-mobile {
  .global-breadcrumb-inline {
    margin-bottom: 10px;
  }
  .desktop-nav {
    display: none;
  }
  .mobile-top-bar {
    display: block;
  }
  .mobile-bottom-nav {
    display: flex;
  }
  body {
    padding-bottom: 60px;
  }

  .header-container {
    width: 100%;
    max-width: 100%;
    padding: 0 12px;
    min-width: 0;
  }

  .logo {
    margin-right: 0;
    min-width: 0;
    max-width: 100%;
  }

  .logo-text {
    display: block;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Explicit mobile fallbacks for pages using plain CSS delivery */
body.is-mobile .global-breadcrumb-inline {
  margin-bottom: 10px;
}

body.is-mobile .desktop-nav {
  display: none;
}

body.is-mobile .mobile-top-bar {
  display: block;
}

body.is-mobile .mobile-bottom-nav {
  display: flex;
}

body.is-mobile .header-container {
  width: 100%;
  max-width: 100%;
  padding: 0 12px;
  min-width: 0;
}

body.is-mobile .logo {
  margin-right: 0;
  min-width: 0;
  max-width: 100%;
}

body.is-mobile .logo-text {
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
