/**
 * fcm-notifications.css — Styles pour les notifications foreground FCM
 * 
 * Architecture :
 * - .fcm-notifications-container : conteneur racine (fixed, coin supérieur droit)
 * - .fcm-foreground-notification : carte de notification individuelle
 * - États : is-entering, is-entered, is-leaving, is-loading, is-success, is-error
 * - Responsive : desktop (max-width 420px) + mobile (largeur presque complète)
 * - Accessibilité : aria-live, focus visible, prefers-reduced-motion
 */

/* ============================================================
   CONTENEUR RACINE
   ============================================================ */

.fcm-notifications-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  pointer-events: none; /* Permettre les clics à travers le conteneur */
}

/* ============================================================
   CARTE DE NOTIFICATION
   ============================================================ */

.fcm-foreground-notification {
  pointer-events: auto; /* Réactiver les clics sur les notifications */
  background: #ffffff;
  border-radius: 14px;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 10px 15px -3px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(0, 0, 0, 0.05);
  max-width: 420px;
  min-width: 300px;
  overflow: hidden;
  transition:
    transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.2s ease;
  transform: translateX(100%);
  opacity: 0;
}

/* État : entrée (animation) */
.fcm-foreground-notification.is-entering {
  transform: translateX(100%);
  opacity: 0;
}

.fcm-foreground-notification.is-entered {
  transform: translateX(0);
  opacity: 1;
}

/* État : sortie (animation) */
.fcm-foreground-notification.is-leaving {
  transform: translateX(120%);
  opacity: 0;
}

/* État : succès */
.fcm-foreground-notification.is-success {
  box-shadow:
    0 4px 6px -1px rgba(40, 167, 69, 0.2),
    0 10px 15px -3px rgba(40, 167, 69, 0.15),
    0 0 0 2px rgba(40, 167, 69, 0.3);
}

/* État : erreur */
.fcm-foreground-notification.is-error {
  box-shadow:
    0 4px 6px -1px rgba(220, 53, 69, 0.2),
    0 10px 15px -3px rgba(220, 53, 69, 0.15),
    0 0 0 2px rgba(220, 53, 69, 0.3);
}

/* ============================================================
   EN-TÊTE
   ============================================================ */

.fcm-notif-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1rem 0.625rem;
  border-bottom: 1px solid #f0f0f0;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
}

.fcm-notif-icon {
  font-size: 0.75rem;
  color: #6c757d;
  flex-shrink: 0;
}

.fcm-notif-title {
  flex: 1;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #2d3748;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fcm-notif-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: #a0aec0;
  cursor: pointer;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s ease, background-color 0.15s ease;
  flex-shrink: 0;
}

.fcm-notif-close:hover {
  color: #2d3748;
  background-color: rgba(0, 0, 0, 0.05);
}

.fcm-notif-close:focus {
  outline: 2px solid #5c7cfa;
  outline-offset: 2px;
}

/* ============================================================
   CORPS
   ============================================================ */

.fcm-notif-body {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: #4a5568;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ============================================================
   BOUTONS D'ACTION
   ============================================================ */

.fcm-notif-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.625rem 1rem 0.875rem;
  border-top: 1px solid #f5f5f5;
  justify-content: flex-end;
}

.fcm-notif-btn {
  flex: 1;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.1s ease,
    opacity 0.15s ease;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fcm-notif-btn:focus {
  outline: 2px solid #5c7cfa;
  outline-offset: 2px;
}

.fcm-notif-btn:active {
  transform: scale(0.98);
}

.fcm-notif-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Bouton Approuver (primaire) */
.fcm-notif-btn-approve {
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(40, 167, 69, 0.2);
}

.fcm-notif-btn-approve:hover:not(:disabled) {
  background: linear-gradient(135deg, #218838 0%, #1aa179 100%);
  box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

/* Bouton Refuser (secondaire) */
.fcm-notif-btn-reject {
  background: #ffffff;
  color: #dc3545;
  border: 1.5px solid #dc3545;
}

.fcm-notif-btn-reject:hover:not(:disabled) {
  background: #fff5f5;
  box-shadow: 0 2px 4px rgba(220, 53, 69, 0.15);
}

/* État loading */
.fcm-notif-btn-loading {
  position: relative;
  color: transparent !important;
}

.fcm-notif-btn-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: fcm-spinner 0.6s linear infinite;
}

/* ============================================================
   ÉTATS INTERMÉDIAIRES (loading, succès, erreur)
   ============================================================ */

.fcm-notif-loading,
.fcm-notif-success,
.fcm-notif-error {
  flex: 1;
  text-align: center;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 6px;
  animation: fcm-fade-in 0.2s ease;
}

.fcm-notif-loading {
  color: #6c757d;
  background: #f8f9fa;
}

.fcm-notif-success {
  color: #155724;
  background: #d4edda;
}

.fcm-notif-error {
  color: #721c24;
  background: #f8d7da;
}

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

@keyframes fcm-spinner {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fcm-fade-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   ACCESSIBILITÉ
   ============================================================ */

/* Réduire les animations pour les utilisateurs sensibles */
@media (prefers-reduced-motion: reduce) {
  .fcm-foreground-notification {
    transition: none;
  }
  
  .fcm-foreground-notification.is-entering {
    transform: translateX(0);
    opacity: 1;
  }
  
  .fcm-foreground-notification.is-leaving {
    transform: translateX(0);
    opacity: 0;
  }
  
  .fcm-notif-btn-loading::after {
    animation: none;
    content: '...';
    border: none;
    width: auto;
    height: auto;
    margin: 0;
    position: static;
    color: #ffffff;
  }
}

/* Focus visible pour navigation clavier */
.fcm-foreground-notification:focus-within {
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 10px 15px -3px rgba(0, 0, 0, 0.08),
    0 0 0 3px rgba(92, 124, 250, 0.4);
}

/* ============================================================
   RESPONSIVE — TABLETTE
   ============================================================ */

@media (max-width: 768px) {
  .fcm-notifications-container {
    right: 0.5rem;
    top: 0.5rem;
    left: 0.5rem;
    max-height: calc(100vh - 1rem);
  }
  
  .fcm-foreground-notification {
    max-width: 100%;
    min-width: auto;
  }
}

/* ============================================================
   RESPONSIVE — MOBILE
   ============================================================ */

@media (max-width: 480px) {
  .fcm-notifications-container {
    right: 0.25rem;
    top: 0.25rem;
    left: 0.25rem;
    gap: 0.5rem;
  }
  
  .fcm-foreground-notification {
    max-width: 100%;
    border-radius: 12px;
  }
  
  .fcm-notif-header {
    padding: 0.75rem 0.875rem 0.5rem;
  }
  
  .fcm-notif-body {
    padding: 0.625rem 0.875rem;
    font-size: 0.8125rem;
  }
  
  .fcm-notif-actions {
    padding: 0.5rem 0.875rem 0.75rem;
    flex-direction: column;
    gap: 0.375rem;
  }
  
  .fcm-notif-btn {
    width: 100%;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
  }
  
  .fcm-notif-title {
    font-size: 0.875rem;
  }
}

/* ============================================================
   CONTRASTE ÉLEVÉ (accessibilité)
   ============================================================ */

@media (forced-colors: active) {
  .fcm-foreground-notification {
    border: 2px solid ButtonText;
  }
  
  .fcm-notif-btn {
    border: 1px solid ButtonText;
  }
  
  .fcm-notif-btn-approve {
    background: Highlight;
    color: HighlightText;
  }
  
  .fcm-notif-btn-reject {
    background: ButtonFace;
    color: ButtonText;
  }
}

/* ============================================================
   THÈME SOMBRE (si l'application le supporte)
   ============================================================ */

@media (prefers-color-scheme: dark) {
  .fcm-foreground-notification {
    background: #1e293b;
    box-shadow:
      0 4px 6px -1px rgba(0, 0, 0, 0.4),
      0 10px 15px -3px rgba(0, 0, 0, 0.3),
      0 0 0 1px rgba(255, 255, 255, 0.1);
  }
  
  .fcm-notif-header {
    background: linear-gradient(135deg, #334155 0%, #1e293b 100%);
    border-bottom-color: #475569;
  }
  
  .fcm-notif-title {
    color: #f1f5f9;
  }
  
  .fcm-notif-icon {
    color: #94a3b8;
  }
  
  .fcm-notif-close {
    color: #64748b;
  }
  
  .fcm-notif-close:hover {
    color: #e2e8f0;
    background-color: rgba(255, 255, 255, 0.1);
  }
  
  .fcm-notif-body {
    color: #cbd5e1;
  }
  
  .fcm-notif-actions {
    border-top-color: #334155;
  }
  
  .fcm-notif-btn-reject {
    background: transparent;
    color: #f87171;
    border-color: #f87171;
  }
  
  .fcm-notif-btn-reject:hover:not(:disabled) {
    background: rgba(248, 113, 113, 0.1);
  }
  
  .fcm-notif-loading {
    color: #94a3b8;
    background: #334155;
  }
  
  .fcm-notif-success {
    color: #86efac;
    background: #14532d;
  }
  
  .fcm-notif-error {
    color: #fca5a5;
    background: #7f1d1d;
  }
}
