/* ==============================================================================
   FORNO & BRASA - PWA SUITE (INSTALL POPUP & UPDATE TOAST)
   Fielmente inspirado no Lumeaflux (PwaProvider, InstallPopup e UpdateToast)
   Zero emojis | Ícones SVG Corporativos | Touch & Click First | Dark Glassmorphism
   ============================================================================== */

:root {
  --fb-pwa-bg: #090d16;
  --fb-pwa-card: #0f172a;
  --fb-pwa-border: rgba(255, 255, 255, 0.12);
  --fb-pwa-text-main: #f8fafc;
  --fb-pwa-text-muted: #94a3b8;
  --fb-pwa-primary: #e05624;
  --fb-pwa-primary-gradient: linear-gradient(135deg, #e05624 0%, #ea580c 50%, #f97316 100%);
  --fb-pwa-amber: #fbbf24;
}

/* ------------------------------------------------------------------------------
   1. MODAL DE INSTALAÇÃO DO APLICATIVO (INSTALL POPUP)
   ------------------------------------------------------------------------------ */
.fb-pwa-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999990;
  background: rgba(4, 7, 13, 0.90);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.2s;
}

.fb-pwa-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.fb-pwa-modal {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: #0d1424;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.06);
  padding: 26px 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 20px;
  opacity: 1 !important;
  transform: none !important;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  box-sizing: border-box;
}

/* Anti-glitch: assegura fonte Outfit limpa e legível sem artefatos DirectWrite/Skia */
.fb-pwa-modal,
.fb-pwa-modal * {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  text-rendering: auto;
  text-shadow: 0 0 0 transparent;
}

/* Garante renderização 2D estática sem subpixel tile-clipping */
.fb-pwa-backdrop.active .fb-pwa-modal {
  opacity: 1 !important;
  transform: none !important;
}

/* Glow decorativo de fundo (estilo Lumeaflux) */
.fb-pwa-glow {
  position: absolute;
  top: -50px;
  right: -50px;
  width: 160px;
  height: 160px;
  background: radial-gradient(circle, rgba(224, 86, 36, 0.22) 0%, rgba(224, 86, 36, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
}

/* Cabeçalho do Modal */
.fb-pwa-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.fb-pwa-header-left {
  display: flex;
  gap: 14px;
  align-items: center;
}

.fb-pwa-icon-badge {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(224, 86, 36, 0.12);
  border: 1px solid rgba(224, 86, 36, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fb-pwa-primary);
  flex-shrink: 0;
}

.fb-pwa-icon-badge svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
}

.fb-pwa-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--fb-pwa-text-main);
  line-height: 1.25;
}

.fb-pwa-subtitle {
  margin: 4px 0 0 0;
  font-size: 0.8rem;
  color: var(--fb-pwa-text-muted);
  line-height: 1.4;
}

.fb-pwa-close-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: var(--fb-pwa-text-muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.fb-pwa-close-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

/* Mockup Visual do Celular / App (estilo Lumeaflux Phone Mockup) */
.fb-pwa-preview {
  display: flex;
  justify-content: center;
  padding: 4px 0;
}

.fb-pwa-mockup {
  position: relative;
  width: 156px;
  background: linear-gradient(180deg, #111827 0%, #090e1a 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.12);
  padding: 16px 12px 14px;
  box-sizing: border-box;
}

.fb-pwa-mockup-notch {
  position: absolute;
  top: 6px;
  width: 36px;
  height: 3px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 3px;
}

.fb-pwa-app-icon-container {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: #0f172a;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  overflow: hidden;
  box-sizing: border-box;
  flex-shrink: 0;
}

.fb-pwa-mockup-icon {
  width: 100%;
  height: 100%;
  border-radius: 15px;
  object-fit: cover;
  display: block;
  image-rendering: -webkit-optimize-contrast;
}

.fb-pwa-mockup-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #f8fafc;
  max-width: 136px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  line-height: 1.25;
}

.fb-pwa-mockup-sub {
  font-size: 0.65rem;
  font-weight: 700;
  color: #f97316;
  max-width: 136px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  line-height: 1.2;
  text-transform: uppercase;
}

/* Caixas de Instruções / Benefícios */
.fb-pwa-content-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 0.82rem;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fb-pwa-step-item {
  display: flex;
  align-items: center;
  gap: 12px;
  line-height: 1.45;
}

.fb-pwa-step-num {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--fb-pwa-primary);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.fb-pwa-step-icon {
  width: 20px;
  height: 20px;
  color: var(--fb-pwa-primary);
  flex-shrink: 0;
}

.fb-pwa-step-item strong {
  color: #f8fafc;
}

/* Ações do Modal */
.fb-pwa-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 4px;
}

.fb-pwa-btn-primary {
  width: 100%;
  padding: 14px 20px;
  background: var(--fb-pwa-primary-gradient);
  border: none;
  border-radius: 14px;
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(224, 86, 36, 0.35);
  transition: all 0.18s ease;
  user-select: none;
}

.fb-pwa-btn-primary:hover {
  filter: brightness(1.12);
  box-shadow: 0 6px 20px rgba(224, 86, 36, 0.45);
}

.fb-pwa-btn-primary:active {
  filter: brightness(0.96);
}

.fb-pwa-btn-primary svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

.fb-pwa-btn-secondary {
  width: 100%;
  padding: 10px 16px;
  background: transparent;
  border: none;
  color: var(--fb-pwa-text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.15s ease;
  text-align: center;
}

.fb-pwa-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--fb-pwa-text-main);
}

/* ------------------------------------------------------------------------------
   2. TOAST DE ATUALIZAÇÃO DISPONÍVEL (UPDATE TOAST) - APENAS PÓS-INSTALADO
   ------------------------------------------------------------------------------ */
.fb-pwa-update-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(120px) scale(0.95);
  opacity: 0;
  z-index: 999995;
  width: calc(100% - 32px);
  max-width: 480px;
  background: rgba(15, 23, 42, 0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 18px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.06);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #fff;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
  pointer-events: none;
  box-sizing: border-box;
}

.fb-pwa-update-toast.active {
  transform: translateX(-50%) translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.fb-pwa-update-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.fb-pwa-spin-badge {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(224, 86, 36, 0.15);
  border: 1px solid rgba(224, 86, 36, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fb-pwa-primary);
  flex-shrink: 0;
}

.fb-pwa-spin-badge svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  animation: fbPwaSpin 4s linear infinite;
}

@keyframes fbPwaSpin {
  100% {
    transform: rotate(360deg);
  }
}

.fb-pwa-update-title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.25;
}

.fb-pwa-update-title svg {
  width: 14px;
  height: 14px;
  color: var(--fb-pwa-amber);
}

.fb-pwa-update-desc {
  margin: 2px 0 0 0;
  font-size: 0.74rem;
  color: var(--fb-pwa-text-muted);
  line-height: 1.35;
}

.fb-pwa-update-btn {
  padding: 9px 18px;
  background: var(--fb-pwa-primary-gradient);
  border: none;
  border-radius: 12px;
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(224, 86, 36, 0.3);
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.fb-pwa-update-btn:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
}

.fb-pwa-update-btn:active {
  transform: translateY(0);
}

.fb-pwa-update-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
}

@media (max-width: 480px) {
  .fb-pwa-modal {
    padding: 22px 18px;
    border-radius: 20px;
  }
  .fb-pwa-update-toast {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    bottom: 16px;
    padding: 14px;
  }
  .fb-pwa-update-btn {
    justify-content: center;
    padding: 10px;
  }
}

/* ------------------------------------------------------------------------------
   3. BOTÃO GATILHO UNIVERSAL DE INSTALAÇÃO (DESCONTINUADO EM PROL DO CABEÇALHO)
   ------------------------------------------------------------------------------ */
#fb-pwa-install-trigger,
.fb-pwa-install-trigger {
  display: none !important;
}

/* Botão de instalação em cabeçalhos (Header Action Button) em todos os módulos */
.pwa-header-install-btn {
  appearance: none !important;
  -webkit-appearance: none !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 7px !important;
  height: 34px !important;
  max-height: 34px !important;
  padding: 0 14px !important;
  background: rgba(224, 86, 36, 0.15) !important;
  border: 1px solid rgba(224, 86, 36, 0.45) !important;
  border-radius: 8px !important;
  color: #ff9466 !important;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  cursor: pointer !important;
  outline: none !important;
  white-space: nowrap !important;
  box-sizing: border-box !important;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
  user-select: none !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
}

.pwa-header-install-btn:hover {
  background: rgba(224, 86, 36, 0.3) !important;
  border-color: rgba(224, 86, 36, 0.8) !important;
  color: #ffffff !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 14px rgba(224, 86, 36, 0.35) !important;
}

.pwa-header-install-btn:active {
  transform: translateY(0) !important;
}

.pwa-header-install-btn svg {
  width: 14px !important;
  height: 14px !important;
  min-width: 14px !important;
  min-height: 14px !important;
  max-width: 14px !important;
  max-height: 14px !important;
  stroke: currentColor !important;
  stroke-width: 2.2 !important;
  fill: none !important;
  display: inline-block !important;
  flex-shrink: 0 !important;
  margin: 0 !important;
}

.pwa-header-install-btn span {
  font-size: 13px !important;
  font-weight: 700 !important;
  color: inherit !important;
  line-height: 1 !important;
  white-space: nowrap !important;
}

@media (max-width: 640px) {
  .fb-pwa-install-trigger {
    bottom: 16px;
    right: 16px;
    padding: 8px 14px 8px 10px;
    gap: 8px;
  }
  .fb-pwa-trigger-icon {
    width: 24px;
    height: 24px;
    border-radius: 7px;
  }
  .fb-pwa-trigger-icon svg {
    width: 13px;
    height: 13px;
  }
  .fb-pwa-trigger-title {
    font-size: 0.78rem;
  }
  .fb-pwa-trigger-sub {
    display: none;
  }
  .pwa-header-install-btn {
    display: inline-flex !important;
    height: 30px !important;
    max-height: 30px !important;
    padding: 0 10px !important;
    font-size: 12px !important;
    gap: 5px !important;
    border-radius: 6px !important;
  }
  .pwa-header-install-btn svg {
    width: 13px !important;
    height: 13px !important;
    min-width: 13px !important;
    min-height: 13px !important;
  }
  .pwa-header-install-btn span {
    font-size: 12px !important;
  }
}
