/* Pulse Team ist eine Smartphone-App. Dieselbe Shell bleibt auf breiten
   Browserfenstern sichtbar und wird dort lediglich zentriert. */
#app-mobile {
  --mobile-tabbar-height: 68px;
  --mobile-tabbar-bottom-offset: max(10px, calc(env(safe-area-inset-bottom) + 8px));
  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow-x: hidden;
  overscroll-behavior: none;
  touch-action: pan-y;
  background: var(--color-surface-app);
  box-shadow: 0 0 32px rgba(36, 36, 38, 0.1);
}

/* Der Dialog liegt als eigenes Geschwisterelement außerhalb von #app-mobile.
   Während er offen ist, bekommt der dahinterliegende Screen daher keinerlei
   Touch- oder Scroll-Ereignisse. */
.is-day-briefing-open #app-mobile {
  pointer-events: none;
  touch-action: none;
}

.mobile-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--space-3) + env(safe-area-inset-top))
    max(var(--space-4), env(safe-area-inset-right))
    var(--space-3)
    max(var(--space-4), env(safe-area-inset-left));
}

.mobile-header--hidden {
  display: none;
}

.mobile-header__logo {
  height: 22px;
  width: auto;
}

.mobile-header__avatar {
  appearance: none;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-pill);
  background: var(--color-sage);
  color: var(--color-text-on-dark);
  font-weight: 800;
  font-size: var(--fs-caption);
}

.mobile-screen {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: 0 max(var(--space-4), env(safe-area-inset-right))
    calc(var(--mobile-tabbar-height) + var(--mobile-tabbar-bottom-offset) + var(--space-3))
    max(var(--space-4), env(safe-area-inset-left));
}

.mobile-tabbar {
  position: fixed;
  z-index: 30;
  left: max(var(--space-3), calc((100vw - min(100vw, 480px)) / 2 + env(safe-area-inset-left) + var(--space-2)));
  right: max(var(--space-3), calc((100vw - min(100vw, 480px)) / 2 + env(safe-area-inset-right) + var(--space-2)));
  bottom: var(--mobile-tabbar-bottom-offset);
  height: var(--mobile-tabbar-height);
  box-sizing: border-box;
  padding: 6px 8px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
  gap: 2px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius-xl);
  background: rgba(241, 241, 241, 0.84);
  -webkit-backdrop-filter: blur(20px) saturate(135%);
  backdrop-filter: blur(20px) saturate(135%);
  box-shadow:
    0 8px 24px rgba(36, 36, 38, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.mobile-tab {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 4px 2px 3px;
  color: var(--color-granite);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.05;
  -webkit-tap-highlight-color: transparent;
  transition:
    color 210ms ease-out,
    background-color 210ms ease-out,
    border-color 210ms ease-out;
}

.mobile-tab.is-active {
  background: rgba(124, 200, 193, 0.24);
  border-color: rgba(124, 200, 193, 0.12);
  color: #397f79;
  font-weight: 800;
}

.mobile-tab:not(.mobile-tab--capture):active {
  background-color: rgba(124, 200, 193, 0.14);
  color: var(--color-shadow-grey);
}

.mobile-tab:focus-visible {
  outline: 2px solid var(--color-shadow-grey);
  outline-offset: 2px;
}

/* Nicht erlaubte Root-Aktionen bleiben semantisch und visuell verborgen,
   ihre feste Grid-Zone bleibt aber erhalten. Dadurch verschieben sich die
   übrigen Tabs für Teamkonten nicht. */
.mobile-tab.is-unavailable {
  visibility: hidden;
  pointer-events: none;
}

/* Icon färbt sich über `currentColor` automatisch mit dem Tab-Text mit
   (aktiv = Pearl Aqua, inaktiv = gedämpftes Grau, siehe .mobile-tab/
   .mobile-tab.is-active oben) – kein eigener Hintergrund mehr nötig, seit
   das harmonisierte Icon-Set echte Glyphen statt farbiger Platzhalter-
   Quadrate liefert. Das <span data-icon-slot> aus index.html wird beim
   Start durch das Icon-Element ersetzt (siehe mobileApp.js). */
.mobile-tab .icon {
  width: 22px;
  height: 22px;
}

/* Inbox-Badge: bleibt frei über der Icon-Ecke und verändert weder die Höhe
   der Navigation noch die feste Tab-Zone. */
.mobile-tab__icon-wrap {
  position: relative;
  display: flex;
}

.mobile-tab__badge {
  position: absolute;
  top: -5px;
  right: -9px;
  min-width: 16px;
  height: 16px;
  border-radius: var(--radius-pill);
  background: var(--color-danger);
  color: #ffffff;
  font-size: 9px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

.mobile-tab__badge[hidden] {
  display: none;
}

.mobile-tab--capture {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  position: relative;
  top: -0px;
  width: 56px;
  min-width: 56px;
  height: 56px;
  min-height: 56px;
  justify-self: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-pill);
  background: var(--color-carbon-black);
  color: #ffffff;
  box-shadow: 0 7px 16px rgba(28, 26, 27, 0.24);
  transition: background-color 210ms ease-out, box-shadow 210ms ease-out;
}

.mobile-tab--capture:active {
  background: var(--color-shadow-grey);
  box-shadow: 0 4px 10px rgba(28, 26, 27, 0.2);
}

.mobile-tab--capture__icon {
  width: 24px;
  height: 24px;
}

@media (prefers-reduced-motion: reduce) {
  .mobile-tab,
  .mobile-tab--capture {
    transition: none;
  }
}

/* ---- Drill-down-Screens (Stack-Navigation, siehe pushMobileScreen()/
   popMobileScreen() in state.js) ---- */

.mobile-stack-screen {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mobile-stack-screen__header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  background: var(--color-surface-app);
  z-index: 2;
  touch-action: pan-y;
  overscroll-behavior-x: none;
}

.mobile-stack-screen > .mobile-detail {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.mobile-stack-screen > .mobile-detail--event {
  overflow: hidden;
}

/* Zurück-Button und der unsichtbare Platzhalter danach sind exakt gleich
   breit, damit .mobile-stack-screen__title (flex:1, zentrierter Text)
   wirklich mittig im Kopfbereich steht statt nur zwischen Button und
   rechtem Rand (Kundenvorgabe: zentrierte Screen-Titel bei Tag-Detail/
   Ereignis-Detail/Dienstplan). */
.mobile-stack-screen__back,
.mobile-stack-screen__spacer {
  flex: 0 0 44px;
  width: 44px;
}

.mobile-stack-screen__back {
  appearance: none;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-primary);
  padding: var(--space-1);
  min-height: 44px;
}

.mobile-stack-screen__title {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  text-align: center;
  font-weight: 800;
  font-size: var(--fs-h2);
  overflow: hidden;
}

.mobile-stack-screen__title-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-stack-screen__title-icon {
  flex-shrink: 0;
  display: inline-flex;
  color: var(--color-text-primary);
}

.mobile-stack-screen__today {
  flex-shrink: 0;
}

/* ---- Animierte Screen-Transitions der Hauptnavigation ----
   Globale Regel, zentral im Screen-Router gesteuert (renderScreen() in
   js/components/mobileApp.js). Der Zielscreen wird in Navigationsrichtung
   eingeschoben, der bisherige laeuft parallel leicht in die Gegenrichtung
   hinaus – die aus nativen Mobile-Interfaces bekannte Parallaxe.

   Waehrend der Transition wird der Container kurzzeitig zum Grid, damit alter
   und neuer Screen in derselben Zelle uebereinanderliegen. Bewusst Grid statt
   position:absolute: die Screen-Roots arbeiten mit height:100%, das im
   gestreckten Grid-Item genauso aufgeht wie im bisherigen Blockfluss – so
   entsteht am Anfang und Ende der Animation kein Layoutsprung. */
.mobile-screen.is-screen-transition {
  display: grid;
  grid-template: 1fr / 1fr;
}

.mobile-screen.is-screen-transition > * {
  grid-area: 1 / 1;
  min-width: 0;
}

.screen-enter-from-right {
  animation: screen-enter-from-right var(--screen-transition-ms, 260ms) cubic-bezier(0.32, 0.72, 0, 1) both;
}

.screen-enter-from-left {
  animation: screen-enter-from-left var(--screen-transition-ms, 260ms) cubic-bezier(0.32, 0.72, 0, 1) both;
}

.screen-leave-to-left {
  animation: screen-leave-to-left var(--screen-transition-ms, 260ms) cubic-bezier(0.32, 0.72, 0, 1) both;
}

.screen-leave-to-right {
  animation: screen-leave-to-right var(--screen-transition-ms, 260ms) cubic-bezier(0.32, 0.72, 0, 1) both;
}

@keyframes screen-enter-from-right {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes screen-enter-from-left {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

/* Der abtretende Screen bewegt sich nur ein Stueck (Parallaxe), nicht voll
   aus dem Viewport – dadurch wirkt die Bewegung raeumlich statt wie ein
   harter Austausch. */
@keyframes screen-leave-to-left {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(-28%); opacity: 0; }
}

@keyframes screen-leave-to-right {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(28%); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .screen-enter-from-right,
  .screen-enter-from-left,
  .screen-leave-to-left,
  .screen-leave-to-right {
    animation: none;
  }
}
