/* Header Base Styles */
.header {
  width: 100%;
  display: flex;
  padding: 24px 24px 20px;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  transition: background-color ease 0.3s;
}

.header-alt {
  width: 100%;
  display: flex;
  padding: 24px 24px 20px;
  z-index: 3;
  background-color: #ffffff;
  border-bottom: 1px solid var(--medium-light);
}

.header--sticky {
  background-color: #ffffff;
}

.top-bar {
  display: flex;
  gap: 24px;
  align-items: center;
  width: 100%;
}

/* Logo Styles */
.logo {
  display: flex;
  align-items: center;
  margin-right: 24px;
}

.logo__link {
  display: flex;
  align-items: center;
}

.logo__img {
  height: 32px;
  opacity: 1;
  transition: opacity ease 0.3s;
}

.logo__img--light {
  height: 35px;
  opacity: 1;
  transition: opacity ease 0.3s;
}

.logo__img--small {
  height: 28px;
  opacity: 1;
  transition: opacity ease 0.3s;
}

.logo__img--hidden {
  display: none;
  opacity: 0;
  transition: opacity ease 0.3s;
}

/* Small Screen Logo Display */
@media screen and (max-width: 500px) {
  .logo__img,
  .logo__img--light {
    display: none;
  }

  .logo__img--small:not(.logo__img--hidden) {
    display: block;
    opacity: 1;
  }
}

/* Navigation Styles */
.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: 1 0 0px;
}

.nav-list {
  display: flex;
  gap: 8px;
}

.nav-list__item {
  display: flex;
  align-items: center;
  position: relative;
}

.nav-list__link {
  display: block;
  padding: 8px 16px;
  font-size: 0.875rem;
  line-height: 24px;
  position: relative;
}

.nav-list__link::after {
  content: \"\";
  position: absolute;
  width: 100%;
  height: 100%;
  border: 1px solid #ffffff;
  border-radius: 999px;
  left: 0;
  top: 0;
  opacity: 0;
  transition: opacity ease 0.3s;
}

.nav-list__link--selected {
  background-color: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

/* Dark Background Header Styles */
:is(.dark-bg) .nav-list__link:hover::after {
  opacity: 1;
}

:is(.dark-bg) .nav-list__link {
  color: #ffffff;
}

/* Header Alt Styles */
.header-alt .nav-list__link--selected {
  background-color: var(--light-dark);
}

.header-alt .nav-list__link::after {
  content: \"\";
  position: absolute;
  width: 100%;
  height: 100%;
  border: 1px solid var(--light-dark);
  border-radius: 999px;
  left: 0;
  top: 0;
  opacity: 0;
  transition: opacity ease 0.3s;
}

.header-alt .nav-list__link:hover::after {
  opacity: 1;
}

/* Submenu Styles */
.sub {
  position: absolute;
  background-color: var(--light-dark);
  padding-top: 16px;
  padding-bottom: 20px;
  width: 150%;
  box-shadow: 0px 10px 15px -3px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform: scale(0);
  transform-origin: top left;
  transition: transform ease 0.3s;
  opacity: 0;
  top: 100%;
  z-index: 1001; /* Ensure submenu is above other header elements */
}

.sub__item {
  font-size: 0.875rem;
}

.sub__item a:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

.sub__item a {
  display: block;
  width: 100%;
  height: 100%;
  padding: 8px 16px;
}

.nav-list__item:hover .sub {
  transform: scale(1);
  opacity: 1;
}

/* Sign Up / Login Buttons */
.sign-up {
  display: flex;
  gap: 10px;
}

.login-button-container {
  width: 90px;
  display: flex; /* Use flexbox for alignment */
  align-items: center; /* Center items vertically */
  justify-content: center; /* Center items horizontally */
}

.login-button-container .nav-list__link {
  padding: 8px 16px; /* Ensure padding is consistent */
}

/* Small screen login button */
.small-screen-login-container {
  display: none;
  margin-left: auto;
  margin-right: 10px;
  position: relative;
  min-width: 70px;
  justify-content: center;
}

.small-screen-login {
  display: none;
  font-size: 0.875rem;
  padding: 8px 16px;
  border: 1px solid var(--dark-base);
  border-radius: 999px;
}

/* Small screen login button on dark background */
:is(.dark-bg) .small-screen-login {
  color: var(--accent-base);
  border: 1px solid var(--accent-base);
}

/* Small screen login spinner container */
#small-screen-login-spinner {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Hamburger Menu Styles */
.hamburger-container {
  display: none;
  height: 48px;
  width: 48px;
  background-color: var(--accent-base);
  border-radius: 6px;
  padding: 12px;
  margin-left: 0;
  align-items: center;
  cursor: pointer;
}

.hamburger {
  flex: none;
  height: 18px;
  overflow: visible;
  position: relative;
  width: 24px;
}

.hamburger__line {
  position: absolute;
  height: 2px;
  width: 100%;
  background-color: var(--dark-base);
  border-radius: 2px;
  transition: all ease 0.3s;
}

.hamburger__line__top {
  top: 0;
  left: 0;
  right: 0;
}

.hamburger__line__middle {
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
}

.hamburger__line__bottom {
  bottom: 0;
  left: 0;
  right: 0;
}

/* Hamburger Active Animation */
.hamburger--active .hamburger__line__top {
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
}

.hamburger--active .hamburger__line__middle {
  opacity: 0;
}

.hamburger--active .hamburger__line__bottom {
  bottom: 50%;
  transform: translateY(50%) rotate(-45deg);
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  border-top-color: #3498db; /* Or your preferred spinner color */
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Hidden Utility */
.hidden {
  display: none !important; /* Use !important to ensure override */
}

/* Responsive Header Styles (Mobile/Tablet) */
@media screen and (max-width: 1190px) {
  .nav {
    display: none;
    position: absolute;
    top: 92px; /* Adjust based on actual header height */
    left: 0;
    flex-direction: column;
    width: 100%;
    align-items: flex-start;
    gap: 32px;
    padding-left: 24px;
    background-color: #ffffff;
    z-index: 999999999;
  }

  .nav--open {
    display: flex;
    padding-top: 24px;
    padding-bottom: 24px;
  }

  .nav-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .nav-list__link {
    display: block;
    font-size: 0.875rem;
    line-height: 24px;
    color: var(--dark-medium) !important;
  }

  .sign-up {
    flex-direction: row-reverse;
  }

  .hamburger-container {
    display: flex;
    margin-left: 0;
  }

  /* Show small screen login at mobile breakpoint */
  .small-screen-login-container {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .small-screen-login {
    display: block;
  }

  #small-screen-login-spinner {
    display: inline-block;
    position: static;
    top: auto;
    left: auto;
    transform: none;
  }

  .sub {
    position: relative;
    background-color: transparent; /* Submenu background on mobile */
    box-shadow: none;
    width: 100%;
    padding: 0;
    transform: scale(1);
    opacity: 1;
    display: none; /* Hidden by default */
    flex-direction: column;
    gap: 8px;
    top: unset;
    margin-top: 8px; /* Space between main item and submenu */
  }

  .sub--open {
    display: flex;
  }

  .nav-list__item:has(.sub) {
    flex-direction: column;
    align-items: flex-start;
  }

  .sub__item a {
    padding: 8px 0; /* Adjust padding for mobile submenu items */
    color: var(--dark-medium);
  }

  .sub__item a:hover {
    background-color: transparent; /* Optional: remove hover background on mobile */
    opacity: 0.8;
  }

  .nav-list__item .sub {
    z-index: auto; /* Reset z-index for mobile */
  }
}

/* Knowledge Library Specific Header Styles */
.kl-menu-toggle {
  display: none;
  height: 48px;
  width: 48px;
  background-color: var(--accent-base);
  border-radius: 6px;
  padding: 12px;
  margin-left: auto;
  align-items: center;
  cursor: pointer;
}

@media screen and (max-width: 1190px) {
  .kl-menu-toggle {
    display: flex;
  }
}

@media screen and (max-width: 500px) {
  .kl-top-bar {
    gap: 12px;
  }
  .kl-top-bar .logo {
    margin-right: 0;
  }
}
