:root {
  --pwa-primary: #007bff;
  --pwa-success: #28a745;
  --pwa-warning: #ffc107;
  --pwa-danger: #dc3545;
  --pwa-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --pwa-shadow-lg: 0 8px 25px rgba(0, 0, 0, 0.15);
  --pwa-border-radius: 0.5rem;
  --pwa-animation-speed: 0.3s;
}

/* =========================
   ÉLÉMENTS PWA GÉNÉRIQUES
========================= */

/* Bouton d'installation PWA */
.pwa-install-btn {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1050;
  display: none;
  animation: slideUp var(--pwa-animation-speed) ease-out;
  box-shadow: var(--pwa-shadow-lg);
  border: none;
  font-weight: 500;
}

.pwa-install-btn:hover {
  transform: translateX(-50%) translateY(-2px);
  box-shadow: var(--pwa-shadow-lg);
}

/* Bouton de mise à jour */
.pwa-update-btn {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1051;
  display: none;
  animation: pulse 2s infinite;
  box-shadow: var(--pwa-shadow);
}

/* Status réseau */
.network-status {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1052;
  max-width: 90%;
  min-width: 200px;
  text-align: center;
  border: none;
  border-radius: var(--pwa-border-radius);
  font-weight: 500;
  animation: slideDown var(--pwa-animation-speed) ease-out;
  box-shadow: var(--pwa-shadow);
}

/* =========================
   PROMPT NOTIFICATIONS
========================= */

.notification-prompt {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  z-index: 1049;
  display: none;
  animation: slideUp var(--pwa-animation-speed) ease-out;
  box-shadow: var(--pwa-shadow-lg);
}

.notification-prompt.show {
  display: block;
}

.notification-prompt .card {
  border: none;
  border-radius: var(--pwa-border-radius);
  background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
  border-left: 4px solid var(--pwa-primary);
}

.notification-prompt .card-body {
  padding: 1rem;
}

.notification-prompt h6 {
  color: var(--pwa-primary);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.notification-prompt .btn {
  border-radius: calc(var(--pwa-border-radius) / 2);
  font-weight: 500;
  padding: 0.375rem 0.75rem;
}

/* =========================
   BOUTONS FLOTTANTS (FAB)
========================= */

.fab {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--pwa-primary);
  color: white;
  border: none;
  box-shadow: var(--pwa-shadow-lg);
  font-size: 1.5rem;
  z-index: 1048;
  transition: all var(--pwa-animation-speed) ease;
  cursor: pointer;
}

.fab:hover {
  background: #0056b3;
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
}

.fab:active {
  transform: scale(0.95);
}

/* FAB secondaire pour les notifications */
.fab-notification {
  bottom: 5rem;
  background: var(--pwa-success);
  width: 48px;
  height: 48px;
  font-size: 1.2rem;
}

.fab-notification:hover {
  background: #1e7e34;
}

/* Badge de notification */
.fab .notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--pwa-danger);
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

/* =========================
   INTERFACES SPÉCIFIQUES
========================= */

/* Panel de paramètres notifications */
.notification-settings {
  background: white;
  border-radius: var(--pwa-border-radius);
  box-shadow: var(--pwa-shadow);
  padding: 1.5rem;
  margin: 1rem 0;
}

.notification-settings h5 {
  color: var(--pwa-primary);
  margin-bottom: 1rem;
  font-weight: 600;
}

.notification-setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid #e9ecef;
}

.notification-setting-item:last-child {
  border-bottom: none;
}

.notification-setting-item .form-check {
  margin: 0;
}

.notification-setting-item .form-check-input {
  transform: scale(1.2);
}

/* Status des permissions */
.permission-status {
  padding: 0.75rem 1rem;
  border-radius: calc(var(--pwa-border-radius) / 2);
  font-weight: 500;
  text-align: center;
  margin: 1rem 0;
}

.permission-status.granted {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.permission-status.denied {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.permission-status.default {
  background-color: #fff3cd;
  color: #856404;
  border: 1px solid #ffeaa7;
}

/* =========================
   ANIMATIONS
========================= */

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

@keyframes slideDown {
  from {
    transform: translateX(-50%) translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    transform: translate3d(0, 0, 0);
  }
  40%, 43% {
    transform: translate3d(0, -8px, 0);
  }
  70% {
    transform: translate3d(0, -4px, 0);
  }
  90% {
    transform: translate3d(0, -2px, 0);
  }
}

/* Animation pour nouveaux éléments */
.pwa-new-item {
  animation: fadeIn var(--pwa-animation-speed) ease-in,
             bounce 1s ease-in-out 0.5s;
}

/* =========================
   ADAPTATIONS MOBILES
========================= */

@media (max-width: 768px) {
  .pwa-install-btn {
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    transform: none;
    width: auto;
  }
  
  .notification-prompt {
    bottom: 6rem; /* Au-dessus du bouton install */
  }
  
  .pwa-update-btn {
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }
  
  .network-status {
    top: 0.5rem;
    left: 0.5rem;
    right: 0.5rem;
    transform: none;
    max-width: none;
  }
  
  .fab {
    bottom: 6rem; /* Au-dessus du bouton install */
    right: 1rem;
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
  }
  
  .fab-notification {
    bottom: 8rem;
  }
}

/* =========================
   MODE SOMBRE
========================= */

@media (prefers-color-scheme: dark) {
  .notification-prompt .card {
    background: linear-gradient(135deg, #343a40 0%, #495057 100%);
    color: white;
  }
  
  .notification-setting-item {
    border-bottom-color: #495057;
  }
  
  .notification-settings {
    background: #343a40;
    color: white;
  }
}

/* =========================
   ÉTATS DE FOCUS/ACCESSIBILITÉ
========================= */

.pwa-install-btn:focus,
.pwa-update-btn:focus,
.fab:focus {
  outline: 3px solid rgba(0, 123, 255, 0.5);
  outline-offset: 2px;
}

/* Réduire les animations si l'utilisateur préfère */
@media (prefers-reduced-motion: reduce) {
  .pwa-install-btn,
  .notification-prompt,
  .network-status,
  .fab {
    animation: none;
    transition: none;
  }
  
  .pwa-update-btn {
    animation: none;
  }
}

/* =========================
   UTILITAIRES PWA
========================= */

.pwa-hidden {
  display: none !important;
}

.pwa-visible {
  display: block !important;
}

.pwa-fade-in {
  animation: fadeIn var(--pwa-animation-speed) ease-in;
}

.pwa-fade-out {
  opacity: 0;
  transition: opacity var(--pwa-animation-speed) ease-out;
}

/* Indicateur de status en ligne/hors ligne */
.online-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pwa-success);
  margin-right: 0.5rem;
}

.online-indicator.offline {
  background: var(--pwa-danger);
  animation: pulse 1s infinite;
}

/* Badge de version PWA */
.pwa-version-badge {
  position: fixed;
  bottom: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border-top-right-radius: var(--pwa-border-radius);
  z-index: 1000;
}

/* Mode installation invisible (pour les tests) */
.pwa-debug {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 1rem;
  border-radius: var(--pwa-border-radius);
  z-index: 9999;
  font-family: monospace;
  white-space: pre-wrap;
  max-width: 80%;
  max-height: 80%;
  overflow: auto;
  display: none;
}
