/* ==========================================================================
   SISTEMA DE GESTÃO ECLESIÁSTICO IPM - ESTILOS GLOBAIS E DESIGN SYSTEM v7.8
   ========================================================================== */

:root {
  --spring-easing: cubic-bezier(0.22, 1, 0.36, 1);
  --smooth-easing: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Área segura para smartphones modernos (iPhone e Android com navegação por gestos) */
.safe-bottom {
  padding-bottom: env(safe-area-inset-bottom, 12px);
}

/* Scrollbar moderno e elegante */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.45);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.75);
}

/* Ocultar barra de rolagem mantendo a funcionalidade nativa */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Otimizações Mobile-First e Quebra de Palavras */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

/* Prevenção de auto-zoom no iOS Safari (inputs com no mínimo 16px no mobile) */
@media screen and (max-width: 640px) {
  input[type="text"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="email"],
  input[type="date"],
  select,
  textarea,
  .form-input-enhanced {
    font-size: 16px !important;
  }
}

/* Evitar quebras de palavras desajeitadas em telas pequenas */
h1, h2, h3, h4, .text-balance {
  text-wrap: balance;
}

.truncate-mobile {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Transições suaves para componentes de interação */
button,
input,
select,
textarea {
  transition: all 0.2s var(--spring-easing);
}

/* Animação suave para surgimento de elementos */
.fade-in {
  animation: fadeIn 0.38s var(--smooth-easing);
}

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

.fade-in-up {
  animation: fadeInUp 0.42s var(--smooth-easing) backwards;
}

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

/* Efeito de vibração ao digitar credencial incorreta */
.shake {
  animation: shakeAnim 0.4s ease-in-out;
}

@keyframes shakeAnim {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* Transições globais de tema suaves */
html, body {
  transition: background-color 0.28s ease, color 0.28s ease;
}

/* ==========================================================================
   SHIMMER SKELETONS (CARREGAMENTO REFINADO)
   ========================================================================== */
.skeleton-shimmer {
  position: relative;
  overflow: hidden;
  background-color: #e2e8f0;
  border-radius: 0.5rem;
}

.skeleton-shimmer::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.65) 50%,
    transparent 100%
  );
  animation: shimmerWave 1.6s infinite;
}

.dark .skeleton-shimmer {
  background-color: #1e293b;
}

.dark .skeleton-shimmer::after {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.08) 50%,
    transparent 100%
  );
}

@keyframes shimmerWave {
  100% {
    transform: translateX(100%);
  }
}

/* ==========================================================================
   TELA DE LOGIN - DARK LUXURY ECLESIÁSTICO
   ========================================================================== */
.bg-radial-dark {
  background:
    radial-gradient(ellipse 85% 85% at 50% -15%, rgba(49, 46, 129, 0.72), #030712 75%),
    #020617;
}

.glass-card-login {
  background: rgba(15, 23, 42, 0.84);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(245, 158, 11, 0.26);
  box-shadow:
    0 25px 60px -15px rgba(0, 0, 0, 0.9),
    0 0 40px -10px rgba(99, 102, 241, 0.22),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.1);
}

/* Conexão perfeita da logo original com o fundo */
.logo-seamless {
  filter: contrast(1.08) brightness(1.04);
  animation: logoFloat 4.5s ease-in-out infinite alternate;
  will-change: transform, filter;
}

@keyframes logoFloat {
  0% {
    transform: translateY(0px) scale(1);
    filter: drop-shadow(0 0 16px rgba(129, 140, 248, 0.35));
  }
  50% {
    transform: translateY(-5px) scale(1.02);
    filter: drop-shadow(0 0 26px rgba(245, 158, 11, 0.45));
  }
  100% {
    transform: translateY(-2px) scale(1.01);
    filter: drop-shadow(0 0 18px rgba(129, 140, 248, 0.45));
  }
}

.logo-orbit-aura {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.logo-orbit-aura::before {
  content: "";
  position: absolute;
  inset: -20px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.32) 0%, rgba(245, 158, 11, 0.14) 45%, transparent 70%);
  filter: blur(24px);
  border-radius: 9999px;
  z-index: 0;
  animation: auraPulse 4s ease-in-out infinite alternate;
}

@keyframes auraPulse {
  0% {
    opacity: 0.55;
    transform: scale(0.92);
  }
  100% {
    opacity: 0.95;
    transform: scale(1.08);
  }
}

/* Brilho suave animado no botão primário */
.btn-glow-effect {
  position: relative;
  overflow: hidden;
}

.btn-glow-effect::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    60deg,
    transparent 20%,
    rgba(255, 255, 255, 0.18) 50%,
    transparent 80%
  );
  transform: rotate(25deg) translateY(-100%);
  transition: transform 0.75s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-glow-effect:hover::after {
  transform: rotate(25deg) translateY(100%);
}

/* ==========================================================================
   PAINÉIS INTERNOS - DESIGN SYSTEM PREMIUM (BENTO & ELEVATION)
   ========================================================================== */

/* Card de Métricas Elevado com Linha de Destaque Superior e Iluminação Sutil */
.metric-card {
  position: relative;
  background: #ffffff;
  border-radius: 1.25rem;
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow:
    0 1px 3px 0 rgba(15, 23, 42, 0.04),
    0 1px 2px -1px rgba(15, 23, 42, 0.04),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.8);
  overflow: hidden;
  transition: all 0.3s var(--spring-easing);
}

.metric-card:hover {
  transform: translateY(-4px);
  border-color: rgba(199, 210, 254, 0.9);
  box-shadow:
    0 16px 32px -8px rgba(15, 23, 42, 0.08),
    0 4px 10px -2px rgba(15, 23, 42, 0.04);
}

.metric-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3.5px;
  opacity: 0.9;
  transition: height 0.2s ease, opacity 0.2s ease;
}

.metric-card:hover::before {
  height: 5px;
  opacity: 1;
}

.metric-card-indigo::before {
  background: linear-gradient(90deg, #4f46e5, #818cf8);
}
.metric-card-emerald::before {
  background: linear-gradient(90deg, #059669, #34d399);
}
.metric-card-sky::before {
  background: linear-gradient(90deg, #0284c7, #38bdf8);
}
.metric-card-rose::before {
  background: linear-gradient(90deg, #e11d48, #fb7185);
}

/* Painel de Conteúdo com Acabamento Refinado */
.panel-card {
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 1.35rem;
  box-shadow:
    0 1px 3px 0 rgba(15, 23, 42, 0.03),
    0 1px 2px -1px rgba(15, 23, 42, 0.03);
  transition: background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

/* Indicador com Ponto Luminoso (Status Glow) */
.glow-dot-emerald {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background-color: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.85);
}

.glow-dot-indigo {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background-color: #6366f1;
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.85);
}

.glow-dot-amber {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background-color: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.85);
}

/* Avatares Modernos com Iniciais e Degradê */
.avatar-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  color: #ffffff;
  border-radius: 0.85rem;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

.avatar-indigo { background: linear-gradient(135deg, #4f46e5, #818cf8); }
.avatar-emerald { background: linear-gradient(135deg, #059669, #34d399); }
.avatar-violet { background: linear-gradient(135deg, #7c3aed, #a78bfa); }
.avatar-sky { background: linear-gradient(135deg, #0284c7, #38bdf8); }
.avatar-amber { background: linear-gradient(135deg, #d97706, #fbbf24); }
.avatar-rose { background: linear-gradient(135deg, #e11d48, #fb7185); }

/* Botões com Feedback Tátil Suave */
.btn-interactive {
  cursor: pointer;
  user-select: none;
  transform: translateZ(0);
  transition: transform 0.18s var(--spring-easing), background-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}
.btn-interactive:active {
  transform: scale(0.96);
}
.btn-interactive:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

/* Segmented Control Moderno (Abas Secundárias) */
.subtab-pill {
  position: relative;
  transition: all 0.22s var(--spring-easing);
  font-weight: 700;
  font-size: 0.8125rem;
  border-radius: 0.85rem;
  padding: 0.55rem 1.1rem;
}

.subtab-pill.active {
  background: #ffffff;
  color: #4338ca;
  box-shadow: 0 2px 8px -1px rgba(15, 23, 42, 0.1), 0 1px 3px -1px rgba(15, 23, 42, 0.06);
}

.subtab-pill:not(.active) {
  color: #64748b;
}

.subtab-pill:not(.active):hover {
  color: #0f172a;
}

/* Destaque suave em campos de formulário */
.form-input-enhanced {
  background-color: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 0.85rem;
  transition: all 0.2s var(--spring-easing);
}

.form-input-enhanced:hover {
  border-color: #94a3b8;
}

.form-input-enhanced:focus {
  background-color: #ffffff;
  border-color: #6366f1;
  box-shadow: 0 0 0 3.5px rgba(99, 102, 241, 0.16);
  outline: none;
}

/* ==========================================================================
   MODAIS & MOBILE BOTTOM SHEETS (GAVETAS DESLIZANTES ESTILO iOS / VAUL)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s var(--smooth-easing);
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content-zoom {
  transform: scale(0.95) translateY(12px);
  opacity: 0;
  transition: transform 0.34s var(--spring-easing), opacity 0.25s ease;
}

.modal-backdrop.active .modal-content-zoom {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* Em smartphones (< 640px), qualquer modal se comporta como um Bottom Sheet ergonômico */
@media screen and (max-width: 639px) {
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-content-zoom {
    max-width: 100% !important;
    width: 100% !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-top-left-radius: 1.75rem !important;
    border-top-right-radius: 1.75rem !important;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 12px)) !important;
    transform: translateY(100%);
    opacity: 1;
    max-height: 90vh !important;
  }

  .modal-backdrop.active .modal-content-zoom {
    transform: translateY(0);
  }
}

/* Alça superior de Bottom Sheet para mobile */
.bottom-sheet-handle {
  width: 42px;
  height: 5px;
  border-radius: 9999px;
  background-color: #cbd5e1;
  margin: 0 auto 0.75rem auto;
}

.dark .bottom-sheet-handle {
  background-color: #475569;
}

/* ==========================================================================
   NAVEGAÇÃO INFERIOR MOBILE COM INDICADOR ATIVO E FAB
   ========================================================================== */
.mobile-nav-btn {
  position: relative;
  min-height: 52px;
  transition: all 0.22s var(--spring-easing);
}

.mobile-nav-btn.nav-active::before {
  content: "";
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  border-radius: 9999px;
  background: linear-gradient(90deg, #4f46e5, #818cf8);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.45);
}

.mobile-nav-btn.nav-active-adm::before {
  content: "";
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  border-radius: 9999px;
  background: linear-gradient(90deg, #d97706, #fbbf24);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.5);
}

/* ==========================================================================
   CARTEIRINHA MINISTERIAL / FICHA DE MEMBRO OFICIAL (CR80 + HOLOGRAMA)
   ========================================================================== */
.carteirinha-ministerial {
  background:
    radial-gradient(circle at 100% 0%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 0% 100%, rgba(245, 158, 11, 0.08) 0%, transparent 50%),
    linear-gradient(135deg, #ffffff 0%, #f8fafc 60%, #eef2ff 100%);
  border: 1px solid rgba(199, 210, 254, 0.8);
  border-radius: 1.5rem;
  box-shadow:
    0 20px 40px -15px rgba(30, 27, 75, 0.14),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.9);
  position: relative;
  overflow: hidden;
}

.carteirinha-ministerial::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(90deg, #4f46e5, #818cf8, #f59e0b, #4f46e5);
  background-size: 200% 100%;
  animation: borderShimmer 6s linear infinite;
}

@keyframes borderShimmer {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

.carteirinha-selo-autenticidade {
  border: 1.5px dashed rgba(99, 102, 241, 0.45);
  border-radius: 9999px;
  padding: 0.3rem 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.6875rem;
  font-weight: 800;
  color: #4338ca;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(238, 242, 255, 0.85);
}

/* ==========================================================================
   RECIBO / COMPROVANTE PASTORAL DIGITAL
   ========================================================================== */
.recibo-pastoral {
  background: #ffffff;
  border-radius: 1.25rem;
  border: 1px solid #e2e8f0;
  box-shadow: 0 12px 32px -10px rgba(15, 23, 42, 0.08);
  position: relative;
}

.recibo-pastoral::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 0;
  right: 0;
  height: 6px;
  background: radial-gradient(circle, transparent 4px, #ffffff 5px);
  background-size: 12px 12px;
}

.recibo-linha-picote {
  border-bottom: 2px dashed #cbd5e1;
  position: relative;
  margin: 1.25rem 0;
}

.recibo-linha-picote::before,
.recibo-linha-picote::after {
  content: "";
  position: absolute;
  top: -8px;
  width: 16px;
  height: 16px;
  background-color: #f1f5f9;
  border-radius: 50%;
}
.recibo-linha-picote::before { left: -24px; }
.recibo-linha-picote::after { right: -24px; }

/* ==========================================================================
   CHIPS DE FILTRO RÁPIDO (FILTER PILLS)
   ========================================================================== */
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.9rem;
  min-height: 36px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #475569;
  background-color: #f1f5f9;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  transition: all 0.2s var(--spring-easing);
  user-select: none;
  white-space: nowrap;
}

.filter-chip:hover {
  background-color: #e2e8f0;
  color: #0f172a;
  transform: translateY(-1px);
}

.filter-chip.active {
  background-color: #4338ca;
  color: #ffffff;
  border-color: #4338ca;
  box-shadow: 0 4px 10px -2px rgba(67, 56, 202, 0.35);
}

/* ==========================================================================
   BARRA VISUAL DE SAÚDE FINANCEIRA & BALANÇO
   ========================================================================== */
.financial-health-bar {
  height: 11px;
  border-radius: 9999px;
  background: #f1f5f9;
  overflow: hidden;
  display: flex;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.06);
}

.financial-health-fill-entrada {
  background: linear-gradient(90deg, #059669, #10b981, #34d399);
  transition: width 0.65s var(--smooth-easing);
}

.financial-health-fill-saida {
  background: linear-gradient(90deg, #e11d48, #f43f5e, #fb7185);
  transition: width 0.65s var(--smooth-easing);
}

/* ==========================================================================
   ANIMAÇÃO REGRESSIVA DO TOAST NOTIFICATION
   ========================================================================== */
.toast-progress {
  height: 3px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.8);
  width: 100%;
  transform-origin: left;
  animation: toastCountdown 3.5s linear forwards;
}

@keyframes toastCountdown {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

/* ==========================================================================
   MODO ESCURO PASTORAL (DARK LUXURY THEME)
   ========================================================================== */
html.dark body,
html.dark #appContainer {
  background-color: #090d16 !important;
  color: #f1f5f9 !important;
}

html.dark .panel-card,
html.dark .metric-card {
  background: #111827 !important;
  border-color: rgba(51, 65, 85, 0.75) !important;
  box-shadow: 0 4px 20px -4px rgba(0, 0, 0, 0.4) !important;
}

html.dark .metric-card:hover {
  border-color: rgba(99, 102, 241, 0.5) !important;
}

html.dark .text-slate-900,
html.dark .text-slate-800 {
  color: #f8fafc !important;
}

html.dark .text-slate-700,
html.dark .text-slate-600 {
  color: #cbd5e1 !important;
}

html.dark .text-slate-500,
html.dark .text-slate-400 {
  color: #94a3b8 !important;
}

html.dark .bg-slate-50,
html.dark .bg-slate-50\/60,
html.dark .bg-slate-50\/80,
html.dark .bg-slate-100 {
  background-color: #1e293b !important;
}

html.dark .border-slate-100,
html.dark .border-slate-200,
html.dark .border-slate-200\/80,
html.dark .border-slate-200\/90,
html.dark .divide-slate-100 > :not([hidden]) ~ :not([hidden]) {
  border-color: rgba(51, 65, 85, 0.65) !important;
}

html.dark .form-input-enhanced {
  background-color: #0f172a !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}

html.dark .form-input-enhanced:focus {
  background-color: #1e293b !important;
  border-color: #6366f1 !important;
}

html.dark .filter-chip:not(.active) {
  background-color: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
}

html.dark .subtab-pill.active {
  background-color: #1e293b;
  color: #818cf8;
}

html.dark .carteirinha-ministerial {
  background: linear-gradient(135deg, #111827 0%, #1e1b4b 100%) !important;
  border-color: rgba(99, 102, 241, 0.35) !important;
}

html.dark .recibo-pastoral {
  background: #0f172a !important;
  border-color: #334155 !important;
}

html.dark #navInferiorParent {
  background-color: rgba(15, 23, 42, 0.94) !important;
  border-top-color: rgba(51, 65, 85, 0.8) !important;
}

html.dark .modal-content-zoom {
  background-color: #111827 !important;
  border: 1px solid rgba(51, 65, 85, 0.8);
}

/* ==========================================================================
   ESTILOS DE IMPRESSÃO CORRIGIDOS (CARTEIRINHA E RECIBOS)
   ========================================================================== */
@media print {
  body * {
    visibility: hidden;
  }

  .print-target-active,
  .print-target-active *,
  #modalMembro.active #modalAreaImpressaoMembro,
  #modalMembro.active #modalAreaImpressaoMembro *,
  #modalRecibo.active #modalAreaImpressaoRecibo,
  #modalRecibo.active #modalAreaImpressaoRecibo * {
    visibility: visible !important;
  }

  .print-target-active,
  #modalMembro.active #modalAreaImpressaoMembro,
  #modalRecibo.active #modalAreaImpressaoRecibo {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    max-width: 480px !important;
    margin: 0 auto !important;
    padding: 16px !important;
    box-shadow: none !important;
    background: #ffffff !important;
    color: #0f172a !important;
  }

  .no-print {
    display: none !important;
  }
}