/* ==========================================================================
   UNDERSAND SHIELD - NETWORK MONITOR (DESIGN & ANIMATIONS 21 ÉTATS)
   ========================================================================== */

/* Overlay d'arrière-plan avec flou moderne */
.net-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(8, 12, 22, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.net-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Carte principale de la modale - Design compact et épuré */
.net-modal-card {
  width: 100%;
  max-width: 480px;
  background: #0f172a;
  border-radius: 16px;
  padding: 20px 20px 18px 20px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  transform: scale(0.9) translateY(15px);
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275), border-color 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  overflow: hidden;
}

.net-modal-overlay.active .net-modal-card {
  transform: scale(1) translateY(0);
}

/* ==========================================================================
   BARRE DE PROGRESSION SERPENT / SCANNER D'ACTUALISATION
   ========================================================================== */

.net-snake-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 10;
}

.net-snake-bar {
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--state-color, #ef4444), #ffffff, var(--state-color, #ef4444), transparent);
  position: absolute;
  top: 0;
  left: -50%;
  border-radius: 4px;
  box-shadow: 0 0 10px var(--state-color, #ef4444);
}

/* État actif lors de l'analyse "Réessayer" */
.net-modal-card.is-scanning .net-snake-container {
  opacity: 1;
}

.net-modal-card.is-scanning .net-snake-bar {
  animation: netSnakeMove 1.3s infinite ease-in-out;
}

@keyframes netSnakeMove {
  0% { left: -50%; }
  100% { left: 110%; }
}

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

.net-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.net-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

.net-shield-tag {
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.net-icon-wrapper {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto 12px auto;
  transition: all 0.3s ease;
}

/* ==========================================================================
   CONTENU CORPS & ERREUR TECHNIQUE
   ========================================================================== */

.net-modal-body {
  text-align: center;
}

.net-modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: #ffffff;
  letter-spacing: -0.2px;
}

.net-modal-text {
  font-size: 0.82rem;
  line-height: 1.45;
  color: #94a3b8;
  margin-bottom: 12px;
}

/* Code d'erreur technique */
.net-error-code-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #090d16;
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 4px 10px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 0.7rem;
}

.net-error-code-label {
  color: #64748b;
  font-weight: 700;
}

#netErrorCode {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--state-color, #ef4444);
  font-weight: 600;
}

/* ==========================================================================
   GRILLE DES MÉTRIQUES DE DIAGNOSTIC (6 MÉTROLOGIES)
   ========================================================================== */

.net-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

@media (max-width: 480px) {
  .net-metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.net-metric-card {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.net-metric-label {
  color: #64748b;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 3px;
}

.net-metric-val {
  font-size: 0.8rem;
  font-weight: 700;
  color: #f1f5f9;
}

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

.net-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.net-btn {
  flex: 1;
  padding: 9px 14px;
  border-radius: 10px;
  border: none;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.net-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--state-color, #ef4444);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.15);
  box-shadow: 0 0 15px var(--state-color, #ef4444);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

/* ==========================================================================
   THÈMES DE COULEURS ET ANIMATIONS POUR LES 21 ALERTES
   ========================================================================== */

/* 1. OFFLINE (ROUGE FEU) */
.net-modal-card.state-offline { --state-color: #ef4444; border-color: rgba(239, 68, 68, 0.4); box-shadow: 0 0 25px rgba(239, 68, 68, 0.18); }
.state-offline .net-badge { background: rgba(239, 68, 68, 0.12); color: #ef4444; border-color: rgba(239, 68, 68, 0.25); }
.state-offline .net-icon-wrapper { background: radial-gradient(circle, rgba(239,68,68,0.18) 0%, transparent 70%); color: #ef4444; }
.state-offline .net-icon-animated { animation: netShakePulse 1.8s infinite ease-in-out; }

/* 2. SLOW_2G_3G (ORANGE ENAMEL) */
.net-modal-card.state-slow { --state-color: #f59e0b; border-color: rgba(245, 158, 11, 0.4); box-shadow: 0 0 25px rgba(245, 158, 11, 0.18); }
.state-slow .net-badge { background: rgba(245, 158, 11, 0.12); color: #f59e0b; border-color: rgba(245, 158, 11, 0.25); }
.state-slow .net-icon-wrapper { background: radial-gradient(circle, rgba(245,158,11,0.18) 0%, transparent 70%); color: #f59e0b; }
.state-slow .net-icon-animated { animation: netSlowWave 2s infinite ease-in-out; }

/* 3. HIGH_LATENCY (VIOLET NEON) */
.net-modal-card.state-latency { --state-color: #a855f7; border-color: rgba(168, 85, 247, 0.4); box-shadow: 0 0 25px rgba(168, 85, 247, 0.18); }
.state-latency .net-badge { background: rgba(168, 85, 247, 0.12); color: #a855f7; border-color: rgba(168, 85, 247, 0.25); }
.state-latency .net-icon-wrapper { background: radial-gradient(circle, rgba(168,85,247,0.18) 0%, transparent 70%); color: #a855f7; }
.state-latency .net-icon-animated { animation: netFlicker 1.2s infinite alternate; }

/* 4. PACKET_LOSS (ROSE PINK) */
.net-modal-card.state-packetloss { --state-color: #ec4899; border-color: rgba(236, 72, 153, 0.4); box-shadow: 0 0 25px rgba(236, 72, 153, 0.18); }
.state-packetloss .net-badge { background: rgba(236, 72, 153, 0.12); color: #ec4899; border-color: rgba(236, 72, 153, 0.25); }
.state-packetloss .net-icon-wrapper { background: radial-gradient(circle, rgba(236,72,153,0.18) 0%, transparent 70%); color: #ec4899; }
.state-packetloss .net-icon-animated { animation: netGlitched 1s infinite steps(2); }

/* 5. SUPABASE_DOWN (ÉMERAUDE SUPABASE) */
.net-modal-card.state-supabase-down { --state-color: #10b981; border-color: rgba(16, 185, 129, 0.4); box-shadow: 0 0 25px rgba(16, 185, 129, 0.18); }
.state-supabase-down .net-badge { background: rgba(16, 185, 129, 0.12); color: #10b981; border-color: rgba(16, 185, 129, 0.25); }
.state-supabase-down .net-icon-wrapper { background: radial-gradient(circle, rgba(16,185,129,0.18) 0%, transparent 70%); color: #10b981; }
.state-supabase-down .net-icon-animated { animation: netPulseGlow 1.6s infinite ease-in-out; }

/* 6. AUTH_EXPIRED (JAUNE OR) */
.net-modal-card.state-auth-expired { --state-color: #eab308; border-color: rgba(234, 179, 8, 0.4); box-shadow: 0 0 25px rgba(234, 179, 8, 0.18); }
.state-auth-expired .net-badge { background: rgba(234, 179, 8, 0.12); color: #eab308; border-color: rgba(234, 179, 8, 0.25); }
.state-auth-expired .net-icon-wrapper { background: radial-gradient(circle, rgba(234,179,8,0.18) 0%, transparent 70%); color: #eab308; }
.state-auth-expired .net-icon-animated { animation: netLockRotate 2.5s infinite ease; }

/* 7. RATE_LIMIT (CYAN ELECTRIQUE) */
.net-modal-card.state-rate-limit { --state-color: #06b6d4; border-color: rgba(6, 182, 212, 0.4); box-shadow: 0 0 25px rgba(6, 182, 212, 0.18); }
.state-rate-limit .net-badge { background: rgba(6, 182, 212, 0.12); color: #06b6d4; border-color: rgba(6, 182, 212, 0.25); }
.state-rate-limit .net-icon-wrapper { background: radial-gradient(circle, rgba(6,182,212,0.18) 0%, transparent 70%); color: #06b6d4; }
.state-rate-limit .net-icon-animated { animation: netRapidFlash 0.8s infinite alternate; }

/* 8. SERVER_ERROR_5XX (ROUGE CRIMSON) */
.net-modal-card.state-server-error { --state-color: #dc2626; border-color: rgba(220, 38, 38, 0.4); box-shadow: 0 0 25px rgba(220, 38, 38, 0.22); }
.state-server-error .net-badge { background: rgba(220, 38, 38, 0.12); color: #dc2626; border-color: rgba(220, 38, 38, 0.25); }
.state-server-error .net-icon-wrapper { background: radial-gradient(circle, rgba(220,38,38,0.18) 0%, transparent 70%); color: #dc2626; }
.state-server-error .net-icon-animated { animation: netShakePulse 1.5s infinite; }

/* 9. TIMEOUT_EXCEEDED (LAGOON TEAL) */
.net-modal-card.state-timeout { --state-color: #14b8a6; border-color: rgba(20, 184, 166, 0.4); box-shadow: 0 0 25px rgba(20, 184, 166, 0.18); }
.state-timeout .net-badge { background: rgba(20, 184, 166, 0.12); color: #14b8a6; border-color: rgba(20, 184, 166, 0.25); }
.state-timeout .net-icon-wrapper { background: radial-gradient(circle, rgba(20,184,166,0.18) 0%, transparent 70%); color: #14b8a6; }
.state-timeout .net-icon-animated { animation: netSpinSlow 4s linear infinite; }

/* 10. CORS_BLOCKED (INDIGO SÉCURITÉ) */
.net-modal-card.state-cors { --state-color: #6366f1; border-color: rgba(99, 102, 241, 0.4); box-shadow: 0 0 25px rgba(99, 102, 241, 0.18); }
.state-cors .net-badge { background: rgba(99, 102, 241, 0.12); color: #6366f1; border-color: rgba(99, 102, 241, 0.25); }
.state-cors .net-icon-wrapper { background: radial-gradient(circle, rgba(99,102,241,0.18) 0%, transparent 70%); color: #6366f1; }
.state-cors .net-icon-animated { animation: netShieldPulse 2s infinite ease-in-out; }

/* 11. DNS_FAILURE (SLATE BLUE) */
.net-modal-card.state-dns { --state-color: #64748b; border-color: rgba(100, 116, 139, 0.4); box-shadow: 0 0 25px rgba(100, 116, 139, 0.18); }
.state-dns .net-badge { background: rgba(100, 116, 139, 0.12); color: #94a3b8; border-color: rgba(100, 116, 139, 0.25); }
.state-dns .net-icon-wrapper { background: radial-gradient(circle, rgba(100,116,139,0.18) 0%, transparent 70%); color: #94a3b8; }
.state-dns .net-icon-animated { animation: netSlowWave 2.2s infinite; }

/* 12. PAYLOAD_TOO_LARGE (AMBRE CHAUD) */
.net-modal-card.state-payload { --state-color: #d97706; border-color: rgba(217, 119, 6, 0.4); box-shadow: 0 0 25px rgba(217, 119, 6, 0.18); }
.state-payload .net-badge { background: rgba(217, 119, 6, 0.12); color: #fbbf24; border-color: rgba(217, 119, 6, 0.25); }
.state-payload .net-icon-wrapper { background: radial-gradient(circle, rgba(217,119,6,0.18) 0%, transparent 70%); color: #fbbf24; }
.state-payload .net-icon-animated { animation: netPulseGlow 1.8s infinite; }

/* 13. MAINTENANCE_MODE (SKY BLUE) */
.net-modal-card.state-maintenance { --state-color: #0284c7; border-color: rgba(2, 132, 199, 0.4); box-shadow: 0 0 25px rgba(2, 132, 199, 0.18); }
.state-maintenance .net-badge { background: rgba(2, 132, 199, 0.12); color: #38bdf8; border-color: rgba(2, 132, 199, 0.25); }
.state-maintenance .net-icon-wrapper { background: radial-gradient(circle, rgba(2,132,199,0.18) 0%, transparent 70%); color: #38bdf8; }
.state-maintenance .net-icon-animated { animation: netLockRotate 3s infinite ease-in-out; }

/* 14. CDN_EDGE_ERROR (CLOUDFLARE ORANGE) */
.net-modal-card.state-cdn { --state-color: #f97316; border-color: rgba(249, 115, 22, 0.4); box-shadow: 0 0 25px rgba(249, 115, 22, 0.18); }
.state-cdn .net-badge { background: rgba(249, 115, 22, 0.12); color: #f97316; border-color: rgba(249, 115, 22, 0.25); }
.state-cdn .net-icon-wrapper { background: radial-gradient(circle, rgba(249,115,22,0.18) 0%, transparent 70%); color: #f97316; }
.state-cdn .net-icon-animated { animation: netFlicker 1.4s infinite alternate; }

/* 15. WEBSOCKET_DISCONNECTED (LIME NEON) */
.net-modal-card.state-websocket { --state-color: #84cc16; border-color: rgba(132, 204, 22, 0.4); box-shadow: 0 0 25px rgba(132, 204, 22, 0.18); }
.state-websocket .net-badge { background: rgba(132, 204, 22, 0.12); color: #84cc16; border-color: rgba(132, 204, 22, 0.25); }
.state-websocket .net-icon-wrapper { background: radial-gradient(circle, rgba(132,204,22,0.18) 0%, transparent 70%); color: #84cc16; }
.state-websocket .net-icon-animated { animation: netGlitched 1.2s infinite steps(2); }

/* 16. STORAGE_QUOTA_EXCEEDED (BRONZE BRUN) */
.net-modal-card.state-storage { --state-color: #a16207; border-color: rgba(161, 98, 7, 0.4); box-shadow: 0 0 25px rgba(161, 98, 7, 0.18); }
.state-storage .net-badge { background: rgba(161, 98, 7, 0.12); color: #eab308; border-color: rgba(161, 98, 7, 0.25); }
.state-storage .net-icon-wrapper { background: radial-gradient(circle, rgba(161,98,7,0.18) 0%, transparent 70%); color: #eab308; }
.state-storage .net-icon-animated { animation: netPulseGlow 1.5s infinite; }

/* 17. SSL_HANDSHAKE_FAILED (ROSE CORAIL) */
.net-modal-card.state-ssl { --state-color: #f43f5e; border-color: rgba(244, 63, 94, 0.4); box-shadow: 0 0 25px rgba(244, 63, 94, 0.18); }
.state-ssl .net-badge { background: rgba(244, 63, 94, 0.12); color: #f43f5e; border-color: rgba(244, 63, 94, 0.25); }
.state-ssl .net-icon-wrapper { background: radial-gradient(circle, rgba(244,63,94,0.18) 0%, transparent 70%); color: #f43f5e; }
.state-ssl .net-icon-animated { animation: netShieldPulse 1.8s infinite; }

/* 18. FEATURE_EXECUTION_ERROR (FUCHSIA VIOLET) */
.net-modal-card.state-feature-error { --state-color: #d946ef; border-color: rgba(217, 70, 239, 0.4); box-shadow: 0 0 25px rgba(217, 70, 239, 0.18); }
.state-feature-error .net-badge { background: rgba(217, 70, 239, 0.12); color: #d946ef; border-color: rgba(217, 70, 239, 0.25); }
.state-feature-error .net-icon-wrapper { background: radial-gradient(circle, rgba(217,70,239,0.18) 0%, transparent 70%); color: #d946ef; }
.state-feature-error .net-icon-animated { animation: netShakePulse 1.4s infinite; }

/* 19. ADBLOCK_INTERFERENCE (DEEP VIOLET) */
.net-modal-card.state-adblock { --state-color: #7c3aed; border-color: rgba(124, 58, 237, 0.4); box-shadow: 0 0 25px rgba(124, 58, 237, 0.18); }
.state-adblock .net-badge { background: rgba(124, 58, 237, 0.12); color: #a78bfa; border-color: rgba(124, 58, 237, 0.25); }
.state-adblock .net-icon-wrapper { background: radial-gradient(circle, rgba(124,58,237,0.18) 0%, transparent 70%); color: #a78bfa; }
.state-adblock .net-icon-animated { animation: netPulseGlow 2s infinite; }

/* 20. SERVICE_WORKER_STALE (BLEU ROYAL) */
.net-modal-card.state-serviceworker { --state-color: #3b82f6; border-color: rgba(59, 130, 246, 0.4); box-shadow: 0 0 25px rgba(59, 130, 246, 0.18); }
.state-serviceworker .net-badge { background: rgba(59, 130, 246, 0.12); color: #60a5fa; border-color: rgba(59, 130, 246, 0.25); }
.state-serviceworker .net-icon-wrapper { background: radial-gradient(circle, rgba(59,130,246,0.18) 0%, transparent 70%); color: #60a5fa; }
.state-serviceworker .net-icon-animated { animation: netSpinSlow 6s linear infinite; }

/* 21. RESTORED (VERT EMERAUDE VIF) */
.net-modal-card.state-restored { --state-color: #22c55e; border-color: rgba(34, 197, 94, 0.45); box-shadow: 0 0 25px rgba(34, 197, 94, 0.2); }
.state-restored .net-badge { background: rgba(34, 197, 94, 0.12); color: #22c55e; border-color: rgba(34, 197, 94, 0.25); }
.state-restored .net-icon-wrapper { background: radial-gradient(circle, rgba(34,197,94,0.2) 0%, transparent 70%); color: #22c55e; }
.state-restored .net-icon-animated { animation: netSuccessBounce 0.8s ease-out; }

/* ==========================================================================
   KEYFRAMES DES ANIMATIONS D'ICÔNES
   ========================================================================== */

@keyframes netShakePulse {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
  10%, 30% { transform: scale(1.08) rotate(-7deg); }
  20%, 40% { transform: scale(1.08) rotate(7deg); }
  50% { transform: scale(0.95); opacity: 0.7; }
}

@keyframes netSlowWave {
  0%, 100% { transform: translateY(0) scale(1); filter: brightness(1); }
  50% { transform: translateY(-5px) scale(1.05); filter: brightness(1.3); }
}

@keyframes netFlicker {
  0% { transform: scale(0.92); opacity: 0.5; }
  100% { transform: scale(1.1); opacity: 1; filter: drop-shadow(0 0 10px var(--state-color)); }
}

@keyframes netSuccessBounce {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); }
}

@keyframes netGlitched {
  0% { transform: translate(0); }
  50% { transform: translate(-2px, 2px); }
  100% { transform: translate(2px, -1px); }
}

@keyframes netPulseGlow {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 2px var(--state-color)); }
  50% { transform: scale(1.08); filter: drop-shadow(0 0 12px var(--state-color)); }
}

@keyframes netLockRotate {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-10deg); }
  75% { transform: rotate(10deg); }
}

@keyframes netRapidFlash {
  0% { opacity: 0.3; transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1.06); }
}

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

@keyframes netShieldPulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.1); opacity: 1; filter: drop-shadow(0 0 8px var(--state-color)); }
}
