/* App shell polish */
.app-header,
.app-header > .container-fluid,
.app-header > nav {
  background: transparent;
}

.dark .app-header,
.dark .app-header > .container-fluid,
.dark .app-header > nav {
  background: transparent;
}

.app-header {
  border-bottom: 0 !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.app-header__nav {
  box-sizing: border-box;
  width: min(calc(100% - 1rem), 85rem);
  min-height: 3.25rem;
  margin: 0.45rem auto 0.35rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(var(--fsm-primary-rgb), 0.1);
  border-radius: 1.15rem;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 14px 32px rgba(11, 35, 70, 0.1);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.dark .app-header__nav {
  background: rgba(16, 43, 82, 0.84);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.24);
}

.app-header__leading,
.app-header__title-group,
.app-header__actions,
.app-header__actions-host {
  min-width: 0;
}

.app-header__actions {
  gap: 0.4rem;
}

.app-header__icon-btn {
  width: 2.25rem;
  height: 2.25rem;
  min-width: 2.25rem;
  min-height: 2.25rem;
  border: 1px solid rgba(var(--fsm-primary-rgb), 0.08);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 4px 12px rgba(11, 35, 70, 0.06);
}

.dark .app-header__icon-btn {
  background: rgba(16, 43, 82, 0.72);
  border-color: rgba(255, 255, 255, 0.1);
}

.app-header__sync-host {
  display: flex;
  align-items: center;
}

.app-header__sync-host .sync-widget__button.app-header__icon-btn {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.dark .app-header__sync-host .sync-widget__button.app-header__icon-btn {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.app-header.mbs-shell-header-fixed,
.app-header.fsm-shell-header-fixed {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1030; /* above main content; below modals */
  padding-top: env(safe-area-inset-top, 0px);
}

.app-header.mbs-shell-header-fixed > .container-fluid,
.app-header.mbs-shell-header-fixed > nav,
.app-header.fsm-shell-header-fixed > .container-fluid,
.app-header.fsm-shell-header-fixed > nav {
  /* Keep header actions inside the mobile safe area on first paint. */
  padding-left: calc(1rem + env(safe-area-inset-left, 0px));
  padding-right: calc(1rem + env(safe-area-inset-right, 0px));
}

body.mbs-ios-standalone .app-header.mbs-shell-header-fixed > .container-fluid,
body.mbs-ios-standalone .app-header.mbs-shell-header-fixed > nav,
body.fsm-ios-standalone .app-header.fsm-shell-header-fixed > .container-fluid,
body.fsm-ios-standalone .app-header.fsm-shell-header-fixed > nav {
  /* iOS standalone can paint fixed headers a few px too close to the edge on initial load. */
  padding-left: calc(1rem + env(safe-area-inset-left, 0px) + 8px);
  padding-right: calc(1rem + env(safe-area-inset-right, 0px) + 8px);
}

.app-header.mbs-shell-header-fixed + #shellMain,
.app-header.fsm-shell-header-fixed + #shellMain {
  padding-top: calc(var(--fsm-shell-header-h, var(--mbs-shell-header-h, 0px)) + 0.5rem) !important;
}

.app-header.mbs-shell-header-fixed + #shellMain.fsm-shell-main--under-header,
.app-header.fsm-shell-header-fixed + #shellMain.fsm-shell-main--under-header {
  padding-top: 0 !important;
}

.mbs-shell-layout {
  min-height: 100vh;
  min-height: 100dvh;
}

.mbs-shell-layout-desktop {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
  min-height: 100dvh;
}

.mbs-shell-content-column {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.mbs-shell-layout-desktop #shellMain {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

.fsm-shell-title {
  margin: 0;
  font-size: clamp(1.625rem, 1.2rem + 1vw, 2.25rem);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.fsm-shell-title.fsm-shell-title-clamp-2 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  white-space: normal;
}

@media (max-width: 767.98px) {
  .fsm-shell-title {
    font-size: 1rem;
    line-height: 1.25;
    font-weight: 600;
    letter-spacing: 0;
  }
}

body.mbs-has-desktop-sidebar .form-footer,
body.mbs-has-desktop-sidebar .mbs-fixed-footer,
body.mbs-has-desktop-sidebar .fsm-fixed-footer,
body.fsm-has-desktop-sidebar .form-footer,
body.fsm-has-desktop-sidebar .mbs-fixed-footer,
body.fsm-has-desktop-sidebar .fsm-fixed-footer {
  left: var(--mbs-desktop-sidebar-w, 0px);
  transition: left 160ms ease;
}

/* Fixed bottom form actions footer */
.form-footer {
  bottom: var(--fsm-bottom-inset, var(--mbs-bottom-inset, 0px));
  z-index: 1030; /* Bootstrap fixed-bottom baseline */
}

/* Generic fixed bottom bar (non-form pages) */
.mbs-fixed-footer,
.fsm-fixed-footer {
  bottom: var(--fsm-bottom-inset, var(--mbs-bottom-inset, 0px));
  z-index: 1030; /* Bootstrap fixed-bottom baseline */
}

/* In PWA/standalone mode we reserve a bottom inset above system UI.
   Paint that inset with the same bar background so page content never shows through. */
.form-footer::after,
.mbs-fixed-footer::after,
.fsm-fixed-footer::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(-1 * var(--fsm-bottom-inset, var(--mbs-bottom-inset, 0px)));
  height: var(--fsm-bottom-inset, var(--mbs-bottom-inset, 0px));
  background: inherit;
  pointer-events: none;
}

/* Floating action button (FAB) */
.mbs-fab-host,
.fsm-fab-host {
  position: fixed;
  --mbs-fab-offset-x: 16px;
  --mbs-fab-offset-y: 20px;
  --fsm-fab-offset-x: var(--mbs-fab-offset-x);
  --fsm-fab-offset-y: var(--mbs-fab-offset-y);
  right: calc(var(--fsm-fab-offset-x, var(--mbs-fab-offset-x, 18px)) + env(safe-area-inset-right, 0px));
  bottom: calc(
    var(--fsm-bottom-nav-reserve, var(--mbs-bottom-nav-reserve, 0px)) +
      var(--fsm-form-footer-reserve, var(--mbs-form-footer-reserve, 0px)) +
      var(--fsm-bottom-inset, var(--mbs-bottom-inset, 0px)) +
      var(--fsm-fab-offset-y, var(--mbs-fab-offset-y, 32px))
  );
  z-index: 1040; /* above bottom nav/footer */
}

@media (min-width: 992px) {
  .mbs-fab-host,
  .fsm-fab-host {
    --mbs-fab-offset-x: 24px;
    --mbs-fab-offset-y: 24px;
  }

  body.mbs-route-tasks .mbs-fab-host {
    right: calc(var(--tasks-desktop-sidebar-width, clamp(280px, 21vw, 320px)) - 0.75rem);
  }
}

.mbs-fab-host.mbs-fab-hidden,
.fsm-fab-host.fsm-fab-hidden {
  display: none !important;
}

.mbs-fab,
.fsm-fab {
  width: 54px;
  height: 54px;
  border-radius: 999px;
  box-shadow: 0 10px 22px rgba(11, 35, 70, 0.2), 0 0 0 6px rgba(255, 255, 255, 0.72);
  background-color: var(--fsm-highlight, var(--mbs-brand-primary));
  border-color: var(--fsm-highlight, var(--mbs-brand-primary));
  color: var(--fsm-highlight-foreground, #ffffff);
}

.schedule-fab-host .fsm-fab {
  opacity: 1;
  width: 48px;
  height: 48px;
  border: 0;
  /* Figma FAB: solid #ffcb05 disc + soft drop only — no white ring/halo.
     !important beats the shared button's Tailwind `shadow-lg` (which can look
     like a pale halo on the map). */
  box-shadow: 0 8px 20px rgba(11, 35, 70, 0.22) !important;
  background: #ffcb05;
  color: #ffffff;
}

.schedule-fab-host {
  --fsm-fab-offset-x: 24px;
  --fsm-fab-offset-y: 28px;
}

.schedule-fab-host--map {
  /*
   * Figma 217:1158 FAB instance (236:588): x=340 y=629 size 48 on 412×915.
   * right = 412 - 340 - 48 = 24px
   * bottom = 915 - 629 - 48 = 238px
   * (= card bottom 104 + card 110 + 24px gap above cards)
   * Override the generic host formula (nav-reserve + offset) — that double-counts
   * chrome and drops the FAB into the card row.
   */
  right: calc(24px + env(safe-area-inset-right, 0px));
  bottom: calc(238px + env(safe-area-inset-bottom, 0px));
}

.fsm-mobile-bottom-nav-wrap {
  bottom: calc(env(safe-area-inset-bottom, 0px) + 28px);
}

.fsm-mobile-bottom-nav-shell {
  width: 288px;
  max-width: calc(100vw - 2rem);
  height: 48px;
  border-radius: 24px;
  border: 1px solid #e2e8f0;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.fsm-mobile-bottom-nav-shell > div {
  width: 100%;
  height: 100%;
  gap: 0;
  padding: 0;
}

.fsm-mobile-bottom-nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 25%;
  height: 48px;
  border-radius: 24px;
  color: var(--fsm-foreground);
  flex: 0 0 auto;
}

.fsm-mobile-bottom-nav-link__icon {
  display: inline-flex;
}

.fsm-mobile-bottom-nav-link__badge {
  position: absolute;
  top: 2px;
  right: 14px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 999px;
  background: #db372d;
  color: #ffffff;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  pointer-events: none;
}

.fsm-mobile-bottom-nav-link--active {
  background: var(--fsm-primary);
  color: var(--fsm-primary-foreground);
  box-shadow: 0 8px 18px rgba(11, 35, 70, 0.18);
}

.fsm-mobile-bottom-nav-link--inactive {
  background: transparent;
  color: var(--fsm-foreground);
}

.dark .fsm-mobile-bottom-nav-shell {
  background: rgba(16, 43, 82, 0.92);
  border-color: rgba(255, 255, 255, 0.1);
}

/* Fast, subtle transitions (purposeful only). */
@media (prefers-reduced-motion: no-preference) {
  .fade-fast {
    transition: opacity 120ms ease, transform 120ms ease;
    will-change: opacity, transform;
  }
}

/* Touch target helper */
.touch-target {
  min-height: 44px;
}

.mbs-shell-back-btn {
  width: 2.75rem;
  height: 2.75rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
}

@media (max-width: 767.98px) {
  .app-header .mbs-shell-back-btn {
    margin-inline-start: 0.125rem;
  }
}

/* Utility */
.btn-nowrap {
  white-space: nowrap;
}
