/* ════════════════════════════════════════════════════════════════════════════
   MAVEN — MODO CRISE CSS
   ════════════════════════════════════════════════════════════════════════════ */

/* ──────────────────────────────────────────────────────────────────────────
   ANIMAÇÕES
   ────────────────────────────────────────────────────────────────────────── */

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

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
  }
  50% {
    box-shadow: 0 0 40px rgba(239, 68, 68, 0.6);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* ──────────────────────────────────────────────────────────────────────────
   ESTADO GLOBAL DO BODY
   ────────────────────────────────────────────────────────────────────────── */

body.modo-crise {
  /* Gradiente sutil de alerta no fundo */
  background: linear-gradient(
    135deg,
    rgba(239, 68, 68, 0.03) 0%,
    var(--bg) 50%,
    rgba(239, 68, 68, 0.03) 100%
  );
}

/* Nível 1 - Alerta (Laranja) */
body.modo-crise[data-nivel-crise="1"] {
  --crise-cor-principal: #f59e0b;
  --crise-cor-secundaria: rgba(245, 158, 11, 0.1);
}

/* Nível 2 - Crítico (Vermelho) */
body.modo-crise[data-nivel-crise="2"] {
  --crise-cor-principal: #ef4444;
  --crise-cor-secundaria: rgba(239, 68, 68, 0.1);
}

/* Nível 3 - Emergência (Vermelho Escuro) */
body.modo-crise[data-nivel-crise="3"] {
  --crise-cor-principal: #dc2626;
  --crise-cor-secundaria: rgba(220, 38, 38, 0.15);
}

/* ──────────────────────────────────────────────────────────────────────────
   BANNER DE CRISE
   ────────────────────────────────────────────────────────────────────────── */

.banner-modo-crise {
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.banner-modo-crise > div:first-child {
  flex: 1;
}

@keyframes bannerPulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
}

/* ──────────────────────────────────────────────────────────────────────────
   CARDS DESTACADOS EM MODO CRISE
   ────────────────────────────────────────────────────────────────────────── */

body.modo-crise #db-saldo {
  animation: pulseGlow 2s ease-in-out infinite;
  position: relative;
  overflow: visible;
}

body.modo-crise #db-saldo::before {
  content: '🚨 ATENÇÃO';
  position: absolute;
  top: -12px;
  right: 16px;
  background: var(--crise-cor-principal, #ef4444);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  animation: shake 3s ease-in-out infinite;
}

/* ──────────────────────────────────────────────────────────────────────────
   PAINEL DE URGÊNCIAS
   ────────────────────────────────────────────────────────────────────────── */

#painel-urgencias {
  box-shadow: 0 8px 32px rgba(239, 68, 68, 0.2);
  position: relative;
}

#painel-urgencias::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(
    90deg,
    transparent,
    #ef4444,
    transparent
  );
  animation: shimmerAlert 2s infinite;
}

@keyframes shimmerAlert {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* ──────────────────────────────────────────────────────────────────────────
   ELEMENTOS OCULTOS EM MODO CRISE
   ────────────────────────────────────────────────────────────────────────── */

body.modo-crise [data-oculto-crise="true"] {
  display: none !important;
}

/* ──────────────────────────────────────────────────────────────────────────
   BOTÕES E AÇÕES URGENTES
   ────────────────────────────────────────────────────────────────────────── */

body.modo-crise .btn-primary {
  background: var(--crise-cor-principal, #ef4444);
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ──────────────────────────────────────────────────────────────────────────
   VALORES NEGATIVOS DESTACADOS
   ────────────────────────────────────────────────────────────────────────── */

body.modo-crise .db-saldo-valor {
  color: var(--crise-cor-principal, #ef4444) !important;
  font-size: 2.2rem !important;
  animation: pulse 2s ease-in-out infinite;
}

/* ──────────────────────────────────────────────────────────────────────────
   SIDEBAR SIMPLIFICADA
   ────────────────────────────────────────────────────────────────────────── */

body.modo-crise .sidebar-nav .nav-item:not([data-tela="inicio"]):not([data-tela="gastos"]):not([data-tela="compromissos"]) {
  opacity: 0.4;
  pointer-events: none;
}

/* ──────────────────────────────────────────────────────────────────────────
   INDICADOR DE SEVERIDADE
   ────────────────────────────────────────────────────────────────────────── */

.indicador-severidade {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.indicador-severidade.alerta {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.indicador-severidade.critico {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.indicador-severidade.emergencia {
  background: rgba(220, 38, 38, 0.2);
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, 0.4);
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ──────────────────────────────────────────────────────────────────────────
   TOOLTIPS DE AJUDA
   ────────────────────────────────────────────────────────────────────────── */

.tooltip-crise {
  position: relative;
  cursor: help;
}

.tooltip-crise::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 1000;
}

.tooltip-crise:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

/* ──────────────────────────────────────────────────────────────────────────
   GRÁFICOS EM MODO CRISE
   ────────────────────────────────────────────────────────────────────────── */

body.modo-crise .chart-card {
  border-color: var(--crise-cor-principal, #ef4444);
  border-width: 1px;
}

/* ──────────────────────────────────────────────────────────────────────────
   SCROLL SUAVE PARA URGÊNCIAS
   ────────────────────────────────────────────────────────────────────────── */

html {
  scroll-behavior: smooth;
}

/* ──────────────────────────────────────────────────────────────────────────
   RESPONSIVO
   ────────────────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .banner-modo-crise {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 12px;
    padding: 16px;
  }

  .banner-modo-crise button {
    width: 100%;
  }

  body.modo-crise .main {
    margin-top: 120px !important;
  }
}

/* ──────────────────────────────────────────────────────────────────────────
   ACESSIBILIDADE
   ────────────────────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  body.modo-crise *,
  .banner-modo-crise,
  #painel-urgencias,
  body.modo-crise #db-saldo {
    animation: none !important;
  }
}

/* ──────────────────────────────────────────────────────────────────────────
   PRINT (OCULTAR MODO CRISE AO IMPRIMIR)
   ────────────────────────────────────────────────────────────────────────── */

@media print {
  .banner-modo-crise,
  #painel-urgencias {
    display: none !important;
  }

  body.modo-crise {
    background: white;
  }
}
