/* =============================================================================
   En-tête — branding | navigation | session
   ============================================================================= */

.header {
  position: sticky;
  top: 0;
  z-index: 1030;
  padding: 0;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #3b82f6 100%);
  border-bottom: none;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.18);
  overflow: visible;
}

.header::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 255, 255, 0.12), transparent 42%),
    radial-gradient(circle at 88% 100%, rgba(255, 206, 84, 0.08), transparent 38%);
  pointer-events: none;
}

.header__inner {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 20px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 20px;
}

/* — Branding — */
.header-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 0 0 auto;
  min-width: 0;
  text-decoration: none;
  color: inherit;
  transition: opacity 0.15s ease;
}

.header-brand:hover {
  opacity: 0.92;
  color: inherit;
}

.header-brand__logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
}

.header-brand__logo-img {
  display: block;
  height: 56px;
  width: auto;
  max-width: 220px;
  object-fit: contain;
  object-position: left center;
}

.header-brand__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.header-brand__org {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}

.header-brand__name {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  line-height: 1.2;
}

.header-brand__app {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.78);
}

/* — Navigation — */
.header-nav {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}

.header-nav__btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.header-nav__btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.header-nav__btn .app-icon {
  opacity: 0.9;
}

/* — Toolbar (session) — */
.header-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 4px 6px 4px 4px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.header-user {
  position: relative;
}

.header-user__trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 4px 4px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease;
}

.header-user__trigger:hover,
.header-user__trigger[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.14);
}

.header-user__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.header-user__avatar--lg {
  width: 48px;
  height: 48px;
  font-size: 16px;
}

.header-user__info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  text-align: left;
}

.header-user__name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  color: #fff;
  white-space: nowrap;
}

.header-user__name--menu {
  font-size: 15px;
  font-weight: 800;
  color: var(--app-text, #1e293b);
  white-space: normal;
  word-break: break-word;
}

.header-user__email {
  font-size: 12px;
  color: var(--app-muted, #64748b);
  word-break: break-all;
}

.header-user__role {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
}

.header-user__role--admin {
  background: rgba(180, 35, 24, 0.55);
  border-color: rgba(255, 180, 170, 0.4);
}

.header-user__role--pilote {
  background: rgba(33, 150, 243, 0.55);
  border-color: rgba(160, 198, 255, 0.4);
}

.header-user__role--lecteur {
  background: rgba(255, 255, 255, 0.16);
}

.header-user__role--menu {
  margin-top: 6px;
  background: var(--men-blue-50, #eff6ff);
  border-color: var(--men-blue-200, #bfdbfe);
  color: var(--men-blue-800, #1e40af);
}

.header-user__role--menu.header-user__role--admin {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b42318;
}

.header-user__role--menu.header-user__role--pilote {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.header-user__chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid rgba(255, 255, 255, 0.7);
  border-bottom: 2px solid rgba(255, 255, 255, 0.7);
  transform: rotate(45deg) translateY(-2px);
  flex-shrink: 0;
  margin-left: 2px;
  transition: transform 0.15s ease;
}

.header-user__trigger[aria-expanded="true"] .header-user__chevron {
  transform: rotate(-135deg) translateY(2px);
}

/* Dropdowns */
.header-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(340px, calc(100vw - 24px));
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--app-border, #e2e8f0);
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.2);
  z-index: 1060;
  overflow: hidden;
}

.header-user__menu-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 16px;
  background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
  border-bottom: 1px solid var(--app-border, #e2e8f0);
}

.header-user__menu-identity {
  flex: 1;
  min-width: 0;
}

.header-user__menu-list {
  list-style: none;
  margin: 0;
  padding: 6px;
}

.header-user__menu-foot {
  padding: 6px;
  border-top: 1px solid var(--app-border, #e2e8f0);
  background: #fafafa;
}

.header-user__menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--app-text, #1e293b);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}

.header-user__menu-item:hover {
  background: #f1f5f9;
}

.header-user__menu-item--logout {
  color: #b42318;
  font-weight: 700;
}

.header-user__menu-item--logout:hover {
  background: #fef2f2;
}

/* — Bandeau KPI — */
.header-kpi-strip {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 2px;
  padding: 8px 20px 10px;
  background: rgba(0, 0, 0, 0.1);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.header-kpi {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.92);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.header-kpi:hover {
  background: rgba(255, 255, 255, 0.16);
}

.header-kpi__icon {
  opacity: 0.85;
}

.header-kpi__value {
  font-weight: 800;
  font-size: 15px;
}

.header-kpi__label {
  font-weight: 500;
  opacity: 0.88;
}

.header-kpi--danger .header-kpi__value { color: #fca5a5; }
.header-kpi--warning .header-kpi__value { color: #fcd34d; }
.header-kpi--muted .header-kpi__value { color: #bfdbfe; }

.header-kpi__sep {
  color: rgba(255, 255, 255, 0.2);
  font-size: 12px;
  user-select: none;
  padding: 0 2px;
}

/* — Responsive — */
@media (max-width: 1100px) {
  .header-brand__app {
    display: none;
  }

  .header-nav__btn span:last-child {
    display: none;
  }

  .header-nav__btn {
    padding: 8px 10px;
  }
}

@media (max-width: 900px) {
  .header__inner {
    flex-wrap: wrap;
    padding: 10px 16px;
    gap: 12px;
  }

  .header-brand {
    flex: 1 1 auto;
  }

  .header-toolbar {
    margin-left: auto;
  }

  .header-nav {
    order: 3;
    flex: 1 1 100%;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .header-nav::-webkit-scrollbar {
    display: none;
  }

  .header-nav__btn span:last-child {
    display: inline;
  }

  .header-user__info {
    display: none;
  }

  .header-user__chevron {
    display: none;
  }

  .header-user__trigger {
    padding: 4px;
    border-radius: 50%;
  }
}

@media (max-width: 575px) {
  .header-brand__text {
    display: none;
  }

  .header-brand__logo-img {
    height: 48px;
    max-width: 160px;
  }

  .header-kpi__sep--wide {
    display: none;
  }

  .header-kpi-strip {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }

  .header-kpi-strip::-webkit-scrollbar {
    display: none;
  }
}
