/**
 * الفارس ERP — Mobile PWA patches (FAB + bottom nav + install banner)
 */

:root {
  --app-safe-top: env(safe-area-inset-top, 0px);
  --app-safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-safe-right: env(safe-area-inset-right, 0px);
  --mobile-bottom-nav: 72px;
}

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

body {
  min-height: 100dvh;
  min-height: -webkit-fill-available;
}

#root {
  min-height: 100dvh;
  min-height: -webkit-fill-available;
}

@media (max-width: 1023px) {
  nav[class*="fixed"][class*="bottom-0"],
  div.fixed.bottom-0.lg\:hidden {
    padding-bottom: var(--app-safe-bottom) !important;
    z-index: 9050 !important;
    pointer-events: auto !important;
  }

  div.fixed.bottom-0.lg\:hidden > button {
    z-index: 9055 !important;
    position: relative !important;
  }

  #pwa-install-banner {
    bottom: calc(var(--mobile-bottom-nav) + var(--app-safe-bottom) + 56px) !important;
    z-index: 8970 !important;
  }

  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

#pwa-install-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--mobile-bottom-nav) + var(--app-safe-bottom) + 8px);
  z-index: 99999;
  display: none;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #166534, #2e9e46);
  color: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(46, 158, 70, 0.45);
  font-family: Cairo, system-ui, sans-serif;
  direction: rtl;
  animation: pwaSlideUp 0.35s ease;
}

#pwa-install-banner.show {
  display: flex;
}

#pwa-install-banner button {
  flex-shrink: 0;
  min-height: 40px;
  padding: 8px 16px;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

#pwa-install-banner .pwa-install-btn {
  background: #fff;
  color: #166534;
}

#pwa-install-banner .pwa-dismiss-btn {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

#pwa-ios-hint {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  align-items: flex-end;
  justify-content: center;
  padding: 24px;
  padding-bottom: calc(24px + var(--app-safe-bottom));
  direction: rtl;
  font-family: Cairo, system-ui, sans-serif;
}

#pwa-ios-hint.show {
  display: flex;
}

#pwa-ios-hint .pwa-ios-card {
  background: #fff;
  border-radius: 20px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  color: #1e293b;
}

@keyframes pwaSlideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (display-mode: standalone) {
  body {
    overscroll-behavior-y: none;
  }
}
