/**
 * PEP HUB Mobile & PWA Styles v2.6.0 — Regional Norte
 * Suporte a Standalone App, Bottom Navigation Bar, Safe-Area Insets,
 * Update Toast, Modal de Instalação iOS e Banner de Instalação Android.
 */

/* Banner de Instalação do App */
.pwa-install-banner {
  position: fixed;
  bottom: -120px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 500px;
  background: rgba(27, 36, 48, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 9999;
  transition: bottom 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  color: #fff;
}

.pwa-install-banner.visible {
  bottom: 20px;
}

@media (max-width: 768px) {
  .pwa-install-banner.visible {
    bottom: calc(68px + env(safe-area-inset-bottom, 0px)); /* Acima da bottom nav */
  }
}

.pwa-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.pwa-banner-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.pwa-banner-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pwa-banner-text strong {
  font-size: 13.5px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pwa-banner-text span {
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pwa-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pwa-banner-dismiss {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 4px;
  transition: color 0.15s;
}

.pwa-banner-dismiss:hover {
  color: #ffffff;
}

.pwa-banner-btn {
  background: #c0191f;
  color: #ffffff;
  border: none;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  box-shadow: 0 2px 8px rgba(192, 25, 31, 0.4);
}

.pwa-banner-btn:hover {
  background: #da291c;
  transform: translateY(-1px);
}

/* Toast de Atualização Disponível */
.pwa-update-toast {
  position: fixed;
  top: -80px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 30px;
  padding: 8px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  font-size: 12px;
  font-weight: 600;
  transition: top 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.pwa-update-toast.visible {
  top: 20px;
}

.pwa-update-toast button {
  background: #c0191f;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

/* Modal de Instalação iOS */
.pwa-ios-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10001;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.pwa-ios-modal.visible {
  display: flex;
}

.pwa-ios-card {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 24px 20px;
  max-width: 380px;
  width: 100%;
  color: #f8fafc;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.pwa-ios-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.pwa-ios-logo {
  width: 40px;
  height: 40px;
  border-radius: 8px;
}

.pwa-ios-header h3 {
  font-size: 15px;
  font-weight: 700;
  flex: 1;
  margin: 0;
}

.pwa-ios-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}

.pwa-ios-steps {
  padding-left: 20px;
  margin: 14px 0;
  font-size: 13px;
  line-height: 1.6;
  color: #cbd5e1;
}

.pwa-ios-steps li {
  margin-bottom: 8px;
}

.ios-share-ico {
  display: inline-block;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.15);
  padding: 1px 5px;
  border-radius: 4px;
}

.pwa-ios-footer {
  font-size: 11.5px;
  color: #94a3b8;
  margin-bottom: 16px;
  text-align: center;
}

.pwa-ios-done-btn {
  width: 100%;
  background: #c0191f;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

/* Badge Flutuante de Status de Rede */
.pwa-network-badge {
  position: fixed;
  top: 14px;
  right: 14px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 9998;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.pwa-network-badge.online {
  background: rgba(240, 253, 244, 0.95);
  border: 1px solid #bbf7d0;
  color: #15803d;
}

.pwa-network-badge.offline {
  background: rgba(254, 242, 242, 0.95);
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.pwa-network-badge.faded {
  opacity: 0;
  transform: translateY(-8px);
}

.net-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.net-dot.online {
  background: #16a34a;
  box-shadow: 0 0 6px #22c55e;
}

.net-dot.offline {
  background: #dc2626;
  box-shadow: 0 0 6px #ef4444;
}

/* Barra de Navegação Inferior (Mobile Bottom Nav) */
.pwa-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  body {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .pwa-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #ffffff;
    border-top: 1px solid #dfe3e8;
    z-index: 9000;
    align-items: center;
    justify-content: space-around;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  }

  .pwa-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex: 1;
    height: 100%;
    color: #5b6675;
    text-decoration: none;
    font-size: 10px;
    font-weight: 600;
    transition: color 0.15s, transform 0.1s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  .pwa-nav-item:active {
    transform: scale(0.95);
  }

  .pwa-nav-item.active,
  .pwa-nav-item:hover {
    color: #c0191f;
  }

  .pwa-nav-item svg {
    display: block;
  }
}

/* Otimizações para PWA Standalone */
.is-pwa-standalone {
  -webkit-user-select: none;
  user-select: none;
}

.is-pwa-standalone input,
.is-pwa-standalone textarea,
.is-pwa-standalone select {
  -webkit-user-select: auto;
  user-select: auto;
}

@supports (padding-top: env(safe-area-inset-top)) {
  .is-pwa-standalone header {
    padding-top: env(safe-area-inset-top);
  }
}
