:root { --afandi-portal-shell-height: 68px; }

html.afandiPortalShellReady body { padding-top: var(--afandi-portal-shell-height); }

.afandiPortalShell {
  position: fixed;
  inset: 0 0 auto;
  z-index: 2147483000;
  width: 100%;
  height: var(--afandi-portal-shell-height);
  border-bottom: 1px solid #d8e0e4;
  background: rgba(242, 242, 243, .98);
  color: #002d47;
  font-family: Barlow, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  box-shadow: 0 5px 18px rgba(29, 31, 32, .08);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-radius: 0 !important;
}

.afandiPortalShell, .afandiPortalShell * { box-sizing: border-box; }

.afandiPortalShell__inner {
  width: min(100%, 1440px);
  height: 100%;
  margin: 0 auto;
  padding: 0 clamp(12px, 2.4vw, 30px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: 0 !important;
}

.afandiPortalShell__nav {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid #d8e0e4;
  background: rgba(248, 248, 249, .72);
  border-radius: 0 !important;
}

.afandiPortalShell__link, .afandiPortalShell__summary {
  min-height: 36px;
  padding: 8px 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #5a666c;
  font: 600 13px/1.1 Barlow, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: .015em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.afandiPortalShell__navIcon { width: 17px; height: 17px; flex: 0 0 17px; }

.afandiPortalShell__link:hover,
.afandiPortalShell__link:focus-visible,
.afandiPortalShell__summary:hover,
.afandiPortalShell__summary:focus-visible,
.afandiPortalShell__link[aria-current="page"],
.afandiPortalShell__summary[aria-current="page"] {
  border-color: #d8e0e4;
  background: rgba(29, 31, 32, .06);
  color: #002d47;
}

.afandiPortalShell__link[aria-current="page"], .afandiPortalShell__summary[aria-current="page"] {
  box-shadow: inset 0 -2px 0 #002d47;
}

.afandiPortalShell__link[aria-disabled="true"] { color: #9aa3a8; cursor: not-allowed; }
.afandiPortalShell__link[aria-disabled="true"]:hover { border-color: transparent; background: transparent; color: #9aa3a8; }

.afandiPortalShell__link:focus-visible,
.afandiPortalShell__summary:focus-visible,
.afandiPortalShell__menuButton:focus-visible,
.afandiPortalShell__close:focus-visible,
.afandiPortalShell__dropdown a:focus-visible { outline: 2px solid #002d47; outline-offset: 2px; }

.afandiPortalShell__internal { position: relative; }
.afandiPortalShell__summary { list-style: none; }
.afandiPortalShell__summary::-webkit-details-marker { display: none; }
.afandiPortalShell__chevron { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .16s ease; }
.afandiPortalShell__internal[open] .afandiPortalShell__chevron { transform: rotate(180deg); }

.afandiPortalShell__dropdown {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  z-index: 2;
  width: 236px;
  padding: 6px;
  display: grid;
  gap: 2px;
  border: 1px solid #c8d4da;
  background: #fff;
  box-shadow: 0 14px 36px rgba(0, 45, 71, .14);
  border-radius: 0 !important;
}

.afandiPortalShell__dropdown a, .afandiPortalShell__dropdown > span {
  min-height: 40px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #263943;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.afandiPortalShell__dropdown a:hover, .afandiPortalShell__dropdown a:focus-visible { background: #edf3f5; color: #002d47; }
.afandiPortalShell__dropdown > span[aria-disabled="true"] { color: #87949b; cursor: not-allowed; }

.afandiPortalShell__actions { display: flex; align-items: center; gap: 8px; }

.afandiPortalShell__menuButton, .afandiPortalShell__close {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  background: transparent;
  color: #002d47;
  text-decoration: none;
  cursor: pointer;
}
.afandiPortalShell__menuButton { display: none; }
.afandiPortalShell__menuButton:hover, .afandiPortalShell__close:hover { border-color: #c8d4da; background: rgba(29, 31, 32, .06); }
.afandiPortalShell__menuLines, .afandiPortalShell__menuLines::before, .afandiPortalShell__menuLines::after { width: 18px; height: 1.5px; display: block; background: currentColor; content: ""; }
.afandiPortalShell__menuLines { position: relative; }
.afandiPortalShell__menuLines::before { position: absolute; top: -6px; }
.afandiPortalShell__menuLines::after { position: absolute; top: 6px; }
.afandiPortalShell__close { font: 400 25px/1 Barlow, sans-serif; }

/* Öffentliche und administrative Portal-Seiten hatten durch Body-Padding plus
   sticky top einen doppelten Leerraum. Diese Seiten reservieren den Platz nur
   über den sticky Header; Login- und Chat-Seiten behalten das Body-Padding. */
html.afandiPortalShellReady body.publicBookingBody { padding-top: 0; }
html.afandiPortalShellReady body.adminBody {
  padding-top: 0;
}
.afandiPortalShellSpacer {
  width: 100%;
  height: var(--afandi-portal-shell-height);
  display: block;
  flex: 0 0 var(--afandi-portal-shell-height);
  pointer-events: none;
}
html.afandiPortalShellReady .publicHeader,
html.afandiPortalShellReady .adminTopbar { top: var(--afandi-portal-shell-height); }

/* Sauberer Abstand zwischen Verwaltungs-Kopfzeile und Seiteninhalt. */
html.afandiPortalShellReady body.adminBody .adminPage { padding-top: 34px; }
/* Die Chat-App bekommt nur den Raum unter der fixierten Portalnavigation.
   Die !important-Werte sind nötig, weil das Chat-Stylesheet eigene 100svh-Regeln
   verwendet. So bleiben Nachrichtenliste, Composer und Senden-Schaltfläche auch
   auf kleinen Mobilgeräten vollständig im sichtbaren Bereich. */
html.afandiPortalShellReady body > .authPage,
html.afandiPortalShellReady body > .appShell {
  height: calc(100svh - var(--afandi-portal-shell-height)) !important;
  height: calc(100dvh - var(--afandi-portal-shell-height)) !important;
  min-height: 0 !important;
  max-height: calc(100svh - var(--afandi-portal-shell-height)) !important;
  max-height: calc(100dvh - var(--afandi-portal-shell-height)) !important;
}
html.afandiPortalShellReady .toastRegion { top: calc(var(--afandi-portal-shell-height) + 18px); }

.chatAuthBoot {
  position: fixed;
  inset: var(--afandi-portal-shell-height) 0 0;
  z-index: 900;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: #f4f7f8;
  color: #002d47;
  font: 600 14px/1.3 Barlow, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: .03em;
}

.chatAuthBoot.hidden { display: none !important; }

.chatAuthBoot__mark {
  width: 34px;
  height: 34px;
  border: 2px solid #cbd7dd;
  border-top-color: #002d47;
  border-radius: 50%;
  animation: afandiChatBootSpin .7s linear infinite;
}

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

/* Mobile-Regeln der Fachportale dürfen ein verborgenes Profil nicht wieder einblenden. */
.publicHeaderMeta #profileLink.hidden { display: none !important; }

/* Der globale X-Schalter übernimmt den Rückweg zur Homepage. */
.publicHeaderMeta .newsHomepageBtn,
.publicHeaderMeta .episodesHomepageBtn,
a.publicNavButton[href="https://afandi.org"] { display: none !important; }

@media (max-width: 1180px) {
  .afandiPortalShell__link, .afandiPortalShell__summary { padding-inline: 8px; }
  .afandiPortalShell__link .afandiPortalShell__navIcon { display: none; }
}

@media (max-width: 900px) {
  :root { --afandi-portal-shell-height: 58px; }
  .afandiPortalShell__inner { justify-content: flex-end; gap: 7px; padding-inline: 10px; }
  .afandiPortalShell__menuButton { order: 3; display: inline-grid; }
  .afandiPortalShell__nav {
    position: absolute;
    top: 100%;
    right: 10px;
    left: 10px;
    z-index: 3;
    max-height: calc(100dvh - var(--afandi-portal-shell-height) - 16px);
    padding: 8px;
    display: none;
    overflow-y: auto;
    border: 1px solid #c8d4da;
    background: #fff;
    box-shadow: 0 15px 36px rgba(0, 45, 71, .16);
  }
  .afandiPortalShell__nav.isOpen { display: grid; grid-template-columns: 1fr; gap: 2px; }
  .afandiPortalShell__link, .afandiPortalShell__summary { width: 100%; min-height: 44px; justify-content: flex-start; padding: 10px 12px; }
  .afandiPortalShell__link .afandiPortalShell__navIcon { display: block; }
  .afandiPortalShell__dropdown { position: static; width: 100%; margin-top: 3px; border-color: #d8e0e4; box-shadow: none; background: #f7f9fa; }
  .afandiPortalShell__actions { margin-left: auto; }
  html.afandiPortalShellReady body.adminBody .adminPage { padding-top: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .afandiPortalShell *, .afandiPortalShell *::before, .afandiPortalShell *::after { scroll-behavior: auto !important; transition: none !important; }
}
