:root {
  --portal-safe-top: env(safe-area-inset-top, 0px);
  --portal-safe-bottom: env(safe-area-inset-bottom, 0px);
  --portal-safe-left: env(safe-area-inset-left, 0px);
  --portal-safe-right: env(safe-area-inset-right, 0px);
}

.portal-pwa-body {
  padding-top: var(--portal-safe-top);
  padding-bottom: var(--portal-safe-bottom);
  padding-left: var(--portal-safe-left);
  padding-right: var(--portal-safe-right);
}

body[data-connection-status="offline"]::before {
  content: 'Sem conexão';
  position: fixed;
  top: var(--portal-safe-top);
  left: 0;
  right: 0;
  z-index: 10000;
  background: #b45309;
  color: #fff;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
}

.portal-pwa-install {
  position: fixed;
  left: var(--portal-safe-left);
  right: var(--portal-safe-right);
  bottom: calc(0.75rem + var(--portal-safe-bottom));
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0.75rem;
  padding: 0.875rem 1rem;
  background: #1a3a52;
  color: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(26, 58, 82, 0.2);
  font-family: 'Manrope', ui-sans-serif, system-ui, sans-serif;
  font-size: 0.875rem;
  line-height: 1.4;
}

.portal-pwa-install[hidden] {
  display: none !important;
}

.portal-pwa-install__text {
  flex: 1;
}

.portal-pwa-install__actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.portal-pwa-install button {
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.portal-pwa-install__install {
  background: #ff6b35;
  color: #fff;
}

.portal-pwa-install__dismiss {
  background: transparent;
  color: #cbd5e1;
}

.portal-pwa-toast {
  position: fixed;
  top: calc(0.75rem + var(--portal-safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10001;
  background: #1a3a52;
  color: #fff;
  padding: 0.625rem 1rem;
  border-radius: 8px;
  font-size: 0.8125rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  max-width: calc(100vw - 2rem);
  text-align: center;
}

.portal-pwa-toast[hidden] {
  display: none !important;
}

.portal-pwa-notify {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1.25rem, var(--portal-safe-top)) max(1.25rem, var(--portal-safe-right))
    max(1.25rem, var(--portal-safe-bottom)) max(1.25rem, var(--portal-safe-left));
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.portal-pwa-notify[hidden] {
  display: none !important;
}

.portal-pwa-notify__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.portal-pwa-notify__panel {
  position: relative;
  z-index: 1;
  width: min(22.5rem, 100%);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.75rem 1.5rem 1.5rem;
  background: var(--portal-surface, #fff);
  color: var(--portal-ink, #1a3a52);
  border: 1px solid #d8e0ea;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(26, 58, 82, 0.2);
  text-align: center;
}

.portal-pwa-notify__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.portal-pwa-notify__text {
  display: block;
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
  color: #475569;
}

.portal-pwa-notify__actions {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  width: 100%;
}

.portal-pwa-notify__enable {
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: #ff6b35;
  color: #fff;
}

.portal-pwa-notify__enable:active {
  filter: brightness(0.96);
}

.portal-pwa-notify__dismiss {
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 0.625rem 1rem;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: #64748b;
}

@media (display-mode: standalone) {
  .portal-pwa-install {
    display: none !important;
  }
}
