/* =========================================================
   TraininBlue — Main public navbar (layout + auth)
   ========================================================= */

:root {
  --tb-nav-height: 70px;
  --tb-nav-height-mobile: 64px;
  /* Sticky/scroll helpers only — page shell uses --tb-nav-height, not extra gap. */
  --tb-nav-content-gap: 0px;
  --tb-nav-content-gap-mobile: 0px;
  --tb-layout-top: var(--tb-nav-height);
  --tb-scroll-anchor-offset: calc(var(--tb-nav-height) + 8px);
  --tb-logo-height: 50px;
  --tb-logo-height-mobile: 42px;
  --tb-nav-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  --tb-nav-shadow-scrolled: 0 4px 12px rgba(0, 0, 0, 0.1);
}

html {
  scroll-padding-top: var(--tb-scroll-anchor-offset);
}

@media (max-width: 576px) {
  :root {
    --tb-layout-top: var(--tb-nav-height-mobile);
    --tb-scroll-anchor-offset: calc(var(--tb-nav-height-mobile) + 8px);
  }
}

#main-navbar.navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 9999;
  height: var(--tb-nav-height);
  min-height: var(--tb-nav-height);
  max-height: var(--tb-nav-height);
  background-color: #fff;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 0;
  padding-right: 0;
  box-shadow: var(--tb-nav-shadow);
  transition: box-shadow 0.2s ease;
}

#main-navbar.navbar.navbar-scrolled {
  box-shadow: var(--tb-nav-shadow-scrolled);
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: none;
  height: 100%;
  margin: 0;
  padding: 0 16px 0 8px;
  box-sizing: border-box;
}

.tb-nav-zone-logo {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  min-width: 0;
}

.logo-img {
  height: var(--tb-logo-height);
  width: auto;
  max-width: 180px;
  object-fit: contain;
  margin-left: 20px;
}

#main-navbar .navbar-toggler {
  flex-shrink: 0;
}

#navbarSupportedContent {
  align-items: center;
}

#main-navbar .tb-nav-zone-main .nav-link {
  font-size: 11px;
  color: #435268;
  white-space: nowrap;
  text-decoration: none;
}

.navbar-nav .nav-item {
  margin-left: 10px;
}

#main-navbar .tb-nav-zone-main .nav-link:hover {
  color: #456fb8;
}

main,
.main-content {
  position: relative;
  z-index: 1;
}

/* ------------------------------------------------------------------
   Global offset under fixed #main-navbar (single compensation rule).
   Apply to the page shell only — never stack margin-top on each page.
   ------------------------------------------------------------------ */
.main-content-wrapper.tb-main-content-offset,
.tb-main-content-offset {
  box-sizing: border-box;
  /* Exact navbar clearance — syncLayoutTop sets --tb-layout-top from DOM. */
  padding-top: var(--tb-layout-top) !important;
  margin-top: 0;
}

/* Workspace shell: do not stack layout margin on top of navbar offset. */
.tb-ts-workspace.tb-main-content-offset {
  margin-top: 0 !important;
}

/* Pages privées avec sidebar (index + espace) : gap contenu seulement — voir trainer_space.css */
html.tb-app-with-sidebar .main-content-wrapper.tb-main-content-offset,
html.tb-app-with-sidebar .tb-ts-workspace.tb-main-content-offset {
  padding-top: calc(
    var(--tb-layout-top, var(--tb-nav-height, 70px)) + var(--tb-private-content-below-nav, 12px)
  ) !important;
}

/*
 * Legacy pages added Bootstrap mt-* when body had no shell offset.
 * Drop top margin on common page roots only (not nested sections).
 */
.tb-main-content-offset > [class~="mt-3"],
.tb-main-content-offset > [class~="mt-4"],
.tb-main-content-offset > [class~="mt-5"],
.tb-main-content-offset .rejoindre-page[class~="mt-5"],
.tb-main-content-offset .page-container[class~="mt-4"],
.tb-main-content-offset .gradient-background[class~="mt-5"],
.tb-main-content-offset .main-container[class~="mt-5"],
.tb-main-content-offset .contact-hero[class~="mt-5"],
.tb-main-content-offset .webinar-hero[class~="mt-5"],
.tb-main-content-offset > .container[class~="mt-3"],
.tb-main-content-offset > .container[class~="mt-4"],
.tb-main-content-offset > .container[class~="mt-5"],
.tb-main-content-offset > :is(h1, h2, h3, h4)[class~="mt-3"],
.tb-main-content-offset > :is(h1, h2, h3, h4)[class~="mt-4"],
.tb-main-content-offset > :is(h1, h2, h3, h4)[class~="mt-5"] {
  margin-top: 0 !important;
}

/* Anchors / titles must not slide under the fixed navbar when scrolled into view. */
.main-content-wrapper :is(h1, h2, h3)[id],
.tb-ts-workspace :is(h1, h2, h3)[id],
.main-content-wrapper .tb-page-header,
.tb-ts-workspace .tb-page-header,
.main-content-wrapper .tb-ts-head {
  scroll-margin-top: var(--tb-scroll-anchor-offset);
}

.main-content-wrapper > :is(h1, h2, h3, h4):first-child,
.main-content-wrapper > .bg-light > :is(h1, h2, h3, h4):first-child,
.main-content-wrapper .tb-auth-page :is(h1, h2, h3, h4):first-child {
  scroll-margin-top: var(--tb-scroll-anchor-offset);
}

@media (min-width: 992px) {
  .navbar-inner {
    justify-content: flex-start;
  }

  #navbarSupportedContent {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
  }

  .tb-nav-zone-main {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: auto;
    min-width: 0;
    margin: 0 20px 0 auto;
    padding: 0;
  }

  ul.navbar-nav.tb-nav-zone-main {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    width: auto;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .tb-nav-zone-auth {
    flex: 0 0 auto;
    width: auto;
    max-width: none;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
  }

  .tb-auth {
    margin-left: 0;
    width: auto;
    max-width: none;
  }

  .tb-auth-guest {
    flex-wrap: nowrap;
  }

  .tb-user-trigger {
    width: auto;
    max-width: none;
  }
}

@media (max-width: 1280px) and (min-width: 992px) {
  .navbar-nav .nav-item {
    margin-left: 6px;
  }

  #main-navbar .tb-nav-zone-main .nav-link {
    font-size: 11px;
  }
}

@media (max-width: 991.98px) {
  #main-navbar.navbar {
    height: var(--tb-nav-height);
    min-height: var(--tb-nav-height);
    max-height: var(--tb-nav-height);
  }

  .navbar-collapse {
    position: absolute;
    top: var(--tb-nav-height);
    left: 0;
    width: 100%;
    background-color: #fff;
    padding: 20px;
    display: none;
    z-index: 99999;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    max-height: calc(100vh - var(--tb-nav-height));
    overflow-x: hidden;
    overflow-y: auto;
  }

  .navbar-collapse.show {
    display: block;
  }

  .navbar-nav {
    flex-direction: column;
    align-items: flex-start;
  }

  .navbar-nav .nav-item {
    margin-bottom: 15px;
    margin-left: 0;
  }
}

@media (max-width: 576px) {
  #main-navbar.navbar {
    height: var(--tb-nav-height-mobile);
    min-height: var(--tb-nav-height-mobile);
    max-height: var(--tb-nav-height-mobile);
  }

  .logo-img {
    height: var(--tb-logo-height-mobile);
    margin-left: 12px;
  }

  .navbar-collapse {
    top: var(--tb-nav-height-mobile);
    max-height: calc(100vh - var(--tb-nav-height-mobile));
  }

}

/* =========================================================
   Authentication (tb-auth-* / tb-user-*)
   ========================================================= */

.tb-auth {
  flex-shrink: 0;
  margin-left: 8px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.tb-auth-guest {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.tb-auth-guest__login {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 20px;
  border: 1px solid #456fb8;
  background: #fff;
  color: #456fb8;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tb-auth-guest__login:hover {
  background: #f8fafc;
  color: #345894;
  text-decoration: none;
}

.tb-auth-guest__register {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 20px;
  border: 1px solid #456fb8;
  background: #456fb8;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.tb-auth-guest__register:hover {
  background: #3a5d9a;
  border-color: #3a5d9a;
  color: #fff;
  text-decoration: none;
}

.tb-auth-user {
  position: relative;
}

.tb-user-menu-wrap {
  position: relative;
  width: 100%;
}

.tb-user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  padding: 4px 10px 4px 4px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  color: #2d3748;
  cursor: pointer;
  font: inherit;
  text-align: left;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tb-user-trigger:hover,
.tb-user-trigger:focus-visible {
  border-color: #cbd5e0;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  outline: none;
}

.tb-user-trigger[aria-expanded="true"] {
  border-color: #456fb8;
  box-shadow: 0 0 0 2px rgba(69, 111, 184, 0.15);
}

.tb-user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #456fb8;
  color: #fff;
  font-size: 16px;
}

.tb-user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  flex: 1 1 auto;
  max-width: 160px;
}

@media (min-width: 992px) {
  .tb-user-info {
    max-width: 140px;
  }
}

.tb-user-name {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.25;
  color: #2d3748;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.tb-user-role {
  font-size: 0.72rem;
  line-height: 1.3;
  color: #718096;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.tb-user-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #718096;
  font-size: 11px;
  transition: transform 0.18s ease;
}

.tb-user-trigger[aria-expanded="true"] .tb-user-chevron {
  transform: rotate(180deg);
}

.tb-user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 10050;
  width: 240px;
  max-width: min(240px, calc(100vw - 24px));
  padding: 8px 0;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.1);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}

.tb-user-menu.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.tb-user-menu-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 12px;
}

.tb-user-menu-header .tb-user-avatar {
  width: 36px;
  height: 36px;
  font-size: 14px;
}

.tb-user-menu-header-text {
  min-width: 0;
  flex: 1;
}

.tb-user-menu-header-name {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: #2d3748;
  line-height: 1.25;
  word-break: break-word;
}

.tb-user-menu-header-role {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
  color: #718096;
}

.tb-user-menu-divider {
  height: 1px;
  margin: 4px 0;
  background: #e2e8f0;
}

.tb-user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  color: #2d3748;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
  transition: background-color 0.15s ease;
}

a.tb-user-menu-item:hover,
a.tb-user-menu-item:focus-visible {
  background: #f8fafc;
  color: #2d3748;
  text-decoration: none;
  outline: none;
}

.tb-user-menu-item i {
  width: 18px;
  text-align: center;
  color: #718096;
  flex-shrink: 0;
}

.tb-user-logout {
  color: #c53030;
}

.tb-user-logout i {
  color: #c53030;
}

.tb-user-logout:hover,
.tb-user-logout:focus-visible {
  background: #fff5f5;
  color: #c53030;
}

@media (max-width: 991.98px) {
  .tb-nav-zone-auth {
    width: 100%;
  }

  .tb-auth {
    width: 100%;
    margin-left: 0;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
  }

  .tb-auth-guest {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .tb-auth-guest__login,
  .tb-auth-guest__register {
    width: 100%;
    justify-content: center;
  }

  .tb-user-info {
    max-width: none;
  }

  .tb-user-menu {
    position: static;
    width: 100%;
    max-width: 100%;
    margin-top: 8px;
    box-shadow: none;
    border: 1px solid #e2e8f0;
    transform: none;
    opacity: 1;
    visibility: hidden;
    pointer-events: none;
    display: none;
  }

  .tb-user-menu.is-open {
    display: block;
    visibility: visible;
    pointer-events: auto;
  }
}

@media (max-width: 576px) {
  .tb-user-name,
  .tb-user-role {
    white-space: normal;
  }
}
