/* ========================================
   LOADING DE RENDERIZAÇÃO DA PÁGINA
   ======================================== */

#page-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #4a7a8a 0%, #6393A6 50%, #7ba8b8 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  opacity: 1;
  visibility: visible;
  /* OTIMIZADO: Transição rápida de 0.3s para fade mais ágil */
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

#page-loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 25px;
  max-width: 350px;
  width: 90%;
}

.loading-logo {
  width: 200px;
  height: auto;
  opacity: 0;
  animation: fadeInLogo 0.8s ease forwards;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

/* ========================================
   BARRA DE PROGRESSO
   ======================================== */

.loading-progress-container {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  overflow: hidden;
  opacity: 0;
  animation: fadeInText 0.5s ease 0.4s forwards;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.loading-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f1c40f 0%, #f9e79f 50%, #f1c40f 100%);
  background-size: 200% 100%;
  border-radius: 10px;
  transition: width 0.3s ease;
  animation: progressShimmer 1.5s ease-in-out infinite;
  box-shadow: 0 0 10px rgba(241, 196, 15, 0.5);
}

@keyframes progressShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ========================================
   TEXTO DE STATUS
   ======================================== */

.loading-text {
  color: #ffffff;
  font-size: 14px;
  font-family: var(--fonte-corpo-padrao, 'Segoe UI', sans-serif);
  font-weight: 500;
  opacity: 0;
  animation: fadeInText 0.5s ease 0.5s forwards;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  margin: 0;
  text-align: center;
  min-height: 20px;
  transition: opacity 0.2s ease;
}

/* ========================================
   INDICADORES DE ETAPAS
   ======================================== */

.loading-steps {
  display: flex;
  justify-content: center;
  gap: 30px;
  opacity: 0;
  animation: fadeInText 0.5s ease 0.6s forwards;
}

.loading-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.loading-step .step-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.5);
  transition: all 0.3s ease;
  position: relative;
}

.loading-step.active .step-indicator {
  background: rgba(241, 196, 15, 0.5);
  border-color: #f1c40f;
  animation: stepPulse 1s ease-in-out infinite;
}

.loading-step.completed .step-indicator {
  background: #2ecc71;
  border-color: #27ae60;
  animation: none;
}

.loading-step.completed .step-indicator::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 8px;
  color: white;
  font-weight: bold;
}

.loading-step span {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: color 0.3s ease;
}

.loading-step.active span {
  color: #f1c40f;
}

.loading-step.completed span {
  color: #2ecc71;
}

@keyframes stepPulse {
  0%, 100% { 
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(241, 196, 15, 0.4);
  }
  50% { 
    transform: scale(1.1);
    box-shadow: 0 0 0 6px rgba(241, 196, 15, 0);
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes fadeInLogo {
  0% { 
    opacity: 0;
    transform: scale(0.8);
  }
  100% { 
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes fadeInText {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

/* ========================================
   RESPONSIVO - LOADING
   ======================================== */

@media (max-width: 480px) {
  .loading-content {
    gap: 20px;
  }
  
  .loading-logo {
    width: 160px;
  }
  
  .loading-steps {
    gap: 20px;
  }
  
  .loading-step span {
    font-size: 10px;
  }
  
  .loading-text {
    font-size: 13px;
  }
}


/* ========================================
   SKELETON LOADING - USUÁRIO E MENU
   ======================================== */

.skeleton-pulse {
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  background: linear-gradient(
    90deg,
    rgba(99, 147, 166, 0.3) 0%,
    rgba(99, 147, 166, 0.6) 50%,
    rgba(99, 147, 166, 0.3) 100%
  );
  background-size: 200% 100%;
  border-radius: 4px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Skeleton do usuário */
.menu-usuario {
  position: relative;
  transition: opacity 0.3s ease;
}

.menu-usuario.loading {
  pointer-events: none;
}

.menu-usuario.loading img,
.menu-usuario.loading .usuario-info {
  opacity: 0;
}

.skeleton-user-photo {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 15px;
  transform: translateY(-50%);
}

.skeleton-user-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: absolute;
  left: 75px;
  top: 50%;
  transform: translateY(-50%);
}

.skeleton-user-name {
  width: 120px;
  height: 14px;
  border-radius: 3px;
}

.skeleton-user-link {
  width: 60px;
  height: 12px;
  border-radius: 3px;
}

/* Skeleton dos itens do menu */
.menu-navegacao.loading .menu-item-principal,
.menu-navegacao.loading .accordion-item {
  opacity: 0.4;
  pointer-events: none;
}

.skeleton-menu-item {
  height: 45px;
  margin: 5px 0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  padding: 0 15px;
  gap: 12px;
}

.skeleton-menu-icon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  flex-shrink: 0;
}

.skeleton-menu-text {
  flex: 1;
  height: 14px;
  border-radius: 3px;
}

/* Container de skeletons no menu */
.menu-skeletons {
  display: none;
  padding: 10px 15px;
}

.menu-navegacao.loading + .menu-skeletons {
  display: block;
}

/* Estados de transição */
.menu-usuario,
.menu-navegacao {
  transition: opacity 0.3s ease;
}

.menu-usuario.loading,
.menu-navegacao.loading {
  position: relative;
}

/* Fade in quando carregado */
@keyframes fadeInContent {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.menu-usuario.loaded,
.menu-navegacao.loaded {
  animation: fadeInContent 0.4s ease;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .loading-logo {
    width: 150px;
  }
  
  .loading-spinner {
    width: 50px;
    height: 50px;
    border-width: 3px;
  }
  
  .loading-text {
    font-size: 14px;
  }
}
