/* PWA / mobile app shell enhancements */
:root {
  --pwa-safe-top: env(safe-area-inset-top, 0px);
  --pwa-safe-right: env(safe-area-inset-right, 0px);
  --pwa-safe-bottom: env(safe-area-inset-bottom, 0px);
  --pwa-safe-left: env(safe-area-inset-left, 0px);
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  padding-top: var(--pwa-safe-top);
  padding-right: var(--pwa-safe-right);
  padding-bottom: var(--pwa-safe-bottom);
  padding-left: var(--pwa-safe-left);
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: rgba(36, 168, 224, 0.18);
}

@media (display-mode: standalone) {
  body {
    user-select: none;
    -webkit-user-select: none;
  }

  input,
  textarea,
  [contenteditable='true'],
  .allow-text-select {
    user-select: text;
    -webkit-user-select: text;
  }
}

.pwa-install-banner,
.pwa-update-banner {
  position: fixed;
  left: max(12px, var(--pwa-safe-left));
  right: max(12px, var(--pwa-safe-right));
  z-index: 1080;
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(34, 35, 54, 0.18);
}

.pwa-install-banner {
  bottom: calc(12px + var(--pwa-safe-bottom));
  background: #fff;
  border: 1px solid rgba(34, 35, 54, 0.08);
}

.pwa-update-banner {
  top: calc(12px + var(--pwa-safe-top));
  background: linear-gradient(135deg, #222336 0%, #2f3150 100%);
  color: #fff;
}

.pwa-install-banner button,
.pwa-update-banner button {
  min-height: 44px;
  touch-action: manipulation;
}

.pwa-ios-steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  text-align: left;
}

.pwa-ios-steps li {
  line-height: 1.45;
}

@media (max-width: 767px) {
  .navbar.sticky-top,
  .portal-header {
    padding-top: calc(0.5rem + var(--pwa-safe-top));
  }
}

.app-shell {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.app-shell-header {
  min-height: calc(56px + var(--pwa-safe-top));
  padding-top: calc(0.5rem + var(--pwa-safe-top));
}

.app-shell-menu-btn {
  min-width: 44px;
  min-height: 44px;
  touch-action: manipulation;
}

.app-shell-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1040;
  border: 0;
  padding: 0;
  background: rgba(23, 24, 39, 0.55);
  backdrop-filter: blur(2px);
}

.app-shell-sidebar {
  z-index: 1050;
}

.app-shell-sidebar--mobile {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(280px, calc(100vw - 48px));
  max-width: 280px;
  transform: translateX(-105%);
  transition: transform 0.24s ease;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  padding-top: var(--pwa-safe-top);
  padding-bottom: var(--pwa-safe-bottom);
}

.app-shell-sidebar--mobile.app-shell-sidebar--open {
  transform: translateX(0);
}

.app-shell-sidebar--mobile.app-shell-sidebar--closed {
  pointer-events: none;
}

.app-shell-main {
  width: 100%;
  min-width: 0;
}

@media (min-width: 992px) {
  .app-shell-sidebar--mobile {
    position: relative;
    transform: none;
    box-shadow: none;
    padding-top: 0;
    padding-bottom: 0;
  }
}
