/* Style additionnel pour la bannière PWA */

/* Cacher la bannière par défaut pour éviter le flash au chargement */
#pwaInstallBanner {
  display: none;
}

/* S'assurer que le bouton de fermeture est bien cliquable */
#dismissPwaBanner {
  cursor: pointer;
  z-index: 10;
}

/* Améliorer la zone de clic du bouton de fermeture */
#dismissPwaBanner {
  min-width: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* S'assurer que l'icône dans le bouton ne bloque pas les événements */
#dismissPwaBanner i {
  pointer-events: none;
}

/* ============================================
   NOUVELLE BANDE PWA COMPACTE
   ============================================ */
.pwa-install-banner {
  background: linear-gradient(135deg, #2a2a2a 0%, #1f1f1f 100%);
  border: 1px solid rgba(240, 185, 11, 0.3);
  border-radius: 12px;
  padding: 15px 20px;
  margin: 20px 5% 0 5%;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  animation: slideInUp 0.6s ease-out;
  z-index: 100;
}
.expanded-mode .pwa-install-banner{
  display: none !important;
}


.pwa-install-banner:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(240, 185, 11, 0.2);
  border-color: rgba(240, 185, 11, 0.5);
}

.pwa-install-banner::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(240, 185, 11, 0.1), transparent);
  transition: left 0.5s;
  pointer-events: none;
}

.pwa-install-banner:hover::before {
  left: 100%;
}

/* Icône de la bande */
.pwa-banner-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  position: relative;
  flex-shrink: 0;
}

.pwa-banner-plus {
  position: absolute;
  bottom: -3px;
  right: -3px;
  width: 20px;
  height: 20px;
  background: linear-gradient(135deg, #f0b90b 0%, #ffc107 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(240, 185, 11, 0.5);
}

.pwa-banner-plus i {
  color: white;
  font-size: 10px;
}

/* Contenu de la bande */
.pwa-banner-content {
  flex: 1;
  min-width: 0; /* Permet au texte de se tronquer si nécessaire */
}

.pwa-banner-title {
  margin: 0 0 5px 0;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
}

.pwa-banner-subtitle {
  margin: 0;
  font-size: 13px;
  color: #ccc;
  line-height: 1.3;
}

/* Bouton d'action de la bande */
.pwa-banner-action {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #f0b90b 0%, #ffc107 100%);
  color: #1a1a1a;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}
.pwa-banner-action p{
  margin:0px;
}

.pwa-banner-action:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(240, 185, 11, 0.4);
}

.pwa-banner-action:focus {
  outline: 2px solid rgba(240, 185, 11, 0.5);
  outline-offset: 2px;
}

/* Bouton de fermeture de la bande */
.pwa-banner-dismiss {
  background: transparent;
  border: none;
  color: #707070;
  cursor: pointer;
  padding: 8px;
  margin-left: 10px;
  border-radius: 50%;
  transition: all 0.3s ease;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pwa-banner-dismiss:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ccc;
  transform: scale(1.1);
}

.pwa-banner-dismiss:focus {
  outline: 2px solid rgba(255, 255, 255, 0.3);
  outline-offset: 2px;
}

/* ============================================
   POPUP PWA - VERSION CORRIGÉE POUR MOBILE
   ============================================ */
.pwa-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* ✅ CORRIGÉ - Hauteur fixe pour mobile */
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height pour mobile */
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  /* ✅ CORRIGÉ - Z-index très élevé pour s'assurer qu'il passe par-dessus tout */
  z-index: 99999;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  /* ✅ NOUVEAU - Centrage par flexbox comme fallback */
  align-items: center;
  justify-content: center;
  /* ✅ NOUVEAU - Scroll si contenu trop grand */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.pwa-popup-overlay.active {
  opacity: 1;
  display: flex !important; /* ✅ CORRIGÉ - Utiliser flex quand actif */
}

.pwa-popup {
  /* ✅ CORRIGÉ - Positionnement relatif au lieu de fixed pour meilleur centrage mobile */
  position: relative;
  /* ✅ SUPPRIMÉ - Pas de transform translate pour éviter les problèmes sur mobile */
  background: linear-gradient(135deg, #2a2a2a 0%, #1f1f1f 100%);
  border: 1px solid rgba(240, 185, 11, 0.3);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  max-width: 600px;
  width: 90%;
  /* ✅ CORRIGÉ - Hauteur flexible pour mobile */
  overflow: hidden;
  /* ✅ CORRIGÉ - Margin auto pour centrage */
  margin: auto;
  /* ✅ NOUVEAU - Transform seulement pour l'animation de scale */
  transform: scale(0.9);
  transition: transform 0.3s ease;
  /* ✅ NOUVEAU - S'assurer que le popup reste visible */
  position: relative;
  z-index: 100000;
  height: 90%;
}

/* ✅ CORRIGÉ - Animation d'ouverture avec scale seulement */
.pwa-popup-overlay.active .pwa-popup {
  transform: scale(1);
}

/* Header du popup */
.pwa-popup-header {
  position: absolute;
  right: 0;
  padding: 20px;
}

.pwa-popup-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #ccc;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  /* ✅ NOUVEAU - Z-index élevé pour s'assurer qu'il reste cliquable */
  position: relative;
  z-index: 100002;
}

.pwa-popup-close:hover {
  background: rgba(255, 107, 107, 0.5);
  color: white;
  transform: rotate(90deg);
}

.pwa-popup-close:focus {
  outline: 2px solid rgba(255, 107, 107, 0.5);
  outline-offset: 2px;
}

/* Contenu du popup */
.pwa-popup-content {
  padding: 30px;
  /* ✅ NOUVEAU - Scroll interne si nécessaire */
  max-height: calc(90vh - 100px);
  max-height: calc(90dvh - 100px);
}

.pwa-popup-icon-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 25px;
  position: relative;
}

.pwa-popup-app-icon {
  width: 100px;
  height: 100px;
  border-radius: 25px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.pwa-popup-plus-icon {
  position: absolute;
  bottom: -5px;
  right: calc(50% - 55px);
  width: 35px;
  height: 35px;
  background: linear-gradient(135deg, #f0b90b 0%, #ffc107 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(240, 185, 11, 0.5);
  animation: pulse-glow 2s infinite;
}

.pwa-popup-plus-icon i {
  color: white;
  font-size: 16px;
}

@keyframes pulse-glow {
  0% { box-shadow: 0 4px 15px rgba(240, 185, 11, 0.5); }
  50% { box-shadow: 0 4px 25px rgba(240, 185, 11, 0.8); }
  100% { box-shadow: 0 4px 15px rgba(240, 185, 11, 0.5); }
}

.pwa-popup-title {
  text-align: center;
  margin: 0 0 15px 0;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
}

.pwa-popup-description {
  text-align: center;
  margin: 0 0 30px 0;
  font-size: 16px;
  color: #ccc;
  line-height: 1.6;
}

/* Avantages du popup */
.pwa-popup-benefits {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 20px;
  margin-bottom: 35px;
}

.pwa-popup-benefit {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}

.pwa-popup-benefit:hover {
  background: rgba(240, 185, 11, 0.1);
  border-color: rgba(240, 185, 11, 0.3);
  transform: translateY(-3px);
}

.pwa-popup-benefit i {
  font-size: 24px;
  color: #f0b90b;
  margin-bottom: 10px;
}

.pwa-popup-benefit span {
  font-size: 14px;
  color: #fff;
  font-weight: 500;
}

/* Actions du popup */
.pwa-popup-actions {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.pwa-popup-install-btn {
  background: linear-gradient(135deg, #f0b90b 0%, #ffc107 100%);
  color: #1a1a1a;
  border: none;
  padding: 15px 30px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
  /* ✅ NOUVEAU - Z-index pour s'assurer qu'il reste cliquable */
  z-index: 100001;
}

.pwa-popup-install-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s;
  pointer-events: none;
}

.pwa-popup-install-btn:hover::before {
  left: 100%;
}

.pwa-popup-install-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(240, 185, 11, 0.4);
}

.pwa-popup-install-btn:focus {
  outline: 2px solid rgba(240, 185, 11, 0.7);
  outline-offset: 2px;
}

.pwa-popup-dismiss-btn {
  background: transparent;
  color: #ccc;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 12px 25px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  /* ✅ NOUVEAU - Z-index pour s'assurer qu'il reste cliquable */
  z-index: 100001;
  position: relative;
}

.pwa-popup-dismiss-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.pwa-popup-dismiss-btn:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

/* ============================================
   BOUTON HEADER (optionnel)
   ============================================ */
.pwa-install-btn {
  background: linear-gradient(135deg, #f0b90b 0%, #ffc107 100%);
  color: #1a1a1a;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 10px;
}

.pwa-install-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(240, 185, 11, 0.4);
}

.pwa-install-btn:focus {
  outline: 2px solid rgba(240, 185, 11, 0.7);
  outline-offset: 2px;
}

/* ============================================
   MESSAGE DE SUCCÈS
   ============================================ */
.pwa-install-success {
  position: fixed;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #2a2a2a 0%, #1f1f1f 100%);
  border: 1px solid #4CAF50;
  border-radius: 12px;
  padding: 20px 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transition: top 0.3s ease;
  z-index: 100003;
}

.pwa-install-success.show {
  top: 30px;
}

.success-content {
  display: flex;
  align-items: center;
  gap: 15px;
  color: #fff;
}

.success-content i {
  font-size: 30px;
  color: #4CAF50;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   RESPONSIVE DESIGN - VERSION CORRIGÉE
   ============================================ */
@media (max-width: 768px) {
  .pwa-install-banner {
    padding: 12px 15px;
    gap: 12px;
    margin: 15px 3% 0 3%;
  }

  .pwa-banner-icon {
    width: 40px;
    height: 40px;
  }

  .pwa-banner-plus {
    width: 16px;
    height: 16px;
    bottom: -2px;
    right: -2px;
  }

  .pwa-banner-plus i {
    font-size: 8px;
  }

  .pwa-banner-title {
    font-size: 14px;
  }

  .pwa-banner-subtitle {
    font-size: 12px;
  }

  .pwa-banner-action {
    font-size: 12px;
    padding: 6px 12px;
  }

  /* ✅ CORRIGÉ - Popup mobile optimisé */
  .pwa-popup-overlay {
    /* ✅ Padding pour éviter que le popup touche les bords */
    padding: 10px;
    /* ✅ S'assurer que le popup reste centré même avec le clavier virtuel */
    align-items: flex-start;
    padding-top: 5vh;
  }

  .pwa-popup {
    width: 100%;
    max-width: none;
    /* ✅ Hauteur adaptée au contenu mais limitée */
    max-height: 85vh;
    max-height: 85dvh;
    margin: 0;
    border-radius: 15px;
    /* ✅ Position relative pour le centrage par flexbox */
    position: static;
  }

  .pwa-popup-header {
    padding: 15px 20px 0 20px;
  }

  .pwa-popup-content {
    padding: 20px;
    /* ✅ Hauteur adaptée pour mobile */
    max-height: calc(85vh - 80px);
    max-height: calc(85dvh - 80px);
  }

  .pwa-popup-title {
    font-size: 24px;
  }

  .pwa-popup-description {
    font-size: 14px;
  }

  .pwa-popup-benefits {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .pwa-popup-install-btn {
    font-size: 16px;
    padding: 12px 25px;
  }

  .pwa-popup-app-icon {
    width: 80px;
    height: 80px;
  }

  .pwa-popup-plus-icon {
    width: 28px;
    height: 28px;
    right: calc(50% - 44px);
  }
}

@media (max-width: 480px) {
  .pwa-install-banner {
    flex-direction: column;
    text-align: center;
    padding: 15px;
    gap: 15px;
  }

  .pwa-banner-content {
    order: 1;
  }

  .pwa-banner-action {
    order: 2;
    width: 100%;
    justify-content: center;
  }

  .pwa-banner-dismiss {
    position: absolute;
    top: 10px;
    right: 10px;
    margin: 0;
  }

  /* ✅ CORRIGÉ - Très petit écran */
  .pwa-popup-overlay {
    padding: 5px;
    padding-top: 2vh;
  }

  .pwa-popup {
    width: 100%;
    max-height: 90vh;
    max-height: 90dvh;
    border-radius: 10px;
  }

  .pwa-popup-header {
    padding: 10px 15px 0 15px;
  }

  .pwa-popup-content {
    padding: 15px;
    max-height: calc(90vh - 60px);
    max-height: calc(90dvh - 60px);
  }

  .pwa-popup-title {
    font-size: 20px;
  }

  .pwa-popup-benefits {
    margin-bottom: 25px;
  }

  .pwa-popup-benefit {
    padding: 15px;
  }

  .pwa-install-success {
    width: 90%;
    max-width: 350px;
    padding: 15px 20px;
  }

  .success-content {
    gap: 10px;
  }

  .success-content i {
    font-size: 24px;
  }
}

/* ============================================
   FIXES SPÉCIFIQUES POUR SAFARI MOBILE iOS
   ============================================ */
@supports (-webkit-touch-callout: none) {
  .pwa-popup-overlay {
    /* ✅ Fix pour Safari iOS */
    height: 100vh;
    height: -webkit-fill-available;
  }
  
  .pwa-popup {
    /* ✅ Fix pour le viewport Safari */
    max-height: 85vh;
    max-height: -webkit-fill-available;
  }
  
  .pwa-popup-content {
    max-height: calc(85vh - 80px);
    max-height: calc(-webkit-fill-available - 80px);
  }
}

/* ============================================
   ACCESSIBILITÉ
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .pwa-install-banner,
  .pwa-popup,
  .pwa-install-success {
    animation: none;
  }

  .pwa-popup-plus-icon {
    animation: none;
  }

  .pwa-install-banner::before,
  .pwa-popup-install-btn::before {
    display: none;
  }

  * {
    transition-duration: 0.1s !important;
  }
}

/* Focus visible pour l'accessibilité */
.pwa-banner-action:focus-visible,
.pwa-banner-dismiss:focus-visible,
.pwa-popup-close:focus-visible,
.pwa-popup-install-btn:focus-visible,
.pwa-popup-dismiss-btn:focus-visible,
.pwa-install-btn:focus-visible {
  outline: 3px solid rgba(240, 185, 11, 0.8);
  outline-offset: 2px;
}

/* ============================================
   ÉTATS D'INTERACTION
   ============================================ */
.pwa-banner-action:active {
  transform: scale(0.98);
}

.pwa-popup-install-btn:active {
  transform: translateY(-1px);
}

.pwa-popup-dismiss-btn:active {
  transform: scale(0.98);
}

/* Éviter la sélection du texte sur les éléments interactifs */
.pwa-install-banner,
.pwa-banner-action,
.pwa-banner-dismiss,
.pwa-popup-install-btn,
.pwa-popup-dismiss-btn {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* ============================================
   FIXES POUR LE CLAVIER VIRTUEL MOBILE
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
  /* ✅ Mode paysage sur petit écran (clavier virtuel ouvert) */
  .pwa-popup-overlay {
    padding-top: 1vh;
  }
  
  .pwa-popup {
    max-height: 95vh;
  }
  
  .pwa-popup-content {
    max-height: calc(95vh - 60px);
    padding: 10px 20px;
  }
  
  .pwa-popup-benefits {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
  }
  
  .pwa-popup-benefit {
    padding: 10px;
  }
}
