/* ===== SISTEMA DE RANKING ESPACIAL ===== */

/* Variáveis CSS para o tema espacial */
:root {
  --space-dark: #1a1a2e;
  --space-blue-dark: #16213e;
  --space-blue-medium: #0f3460;
  --space-alert: #e94560;
  --space-silver: #8e9aaf;
  --space-gold: #d4af37;
  --space-gold-bright: #ffd700;
  
  /* Cores dos ranks */
  --rank-cadete: #4A90E2;
  --rank-trainee: #357ABD;
  --rank-oficial: #2C5F8A;
  --rank-comandante: #8E9AAF;
  --rank-capitao: #D4AF37;
  --rank-almirante: #FFD700;
}

/* ===== RANKING NO HUD DO JOGO ===== */
#player-rank-hud {
  position: absolute;
  top: 60px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(26, 26, 46, 0.85);
  border: 1px solid rgba(143, 154, 175, 0.3);
  border-radius: 8px;
  padding: 6px 12px;
  backdrop-filter: blur(10px);
  font-family: 'Orbitron', monospace;
  font-weight: 600;
  letter-spacing: 1px;
  transition: all 0.3s ease;
  z-index: 1000;
}

#player-rank-hud:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 20px rgba(143, 154, 175, 0.4);
}

.rank-icon-hud {
  width: 40px;
  height: 40px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
  flex-shrink: 0;
}

.rank-title-hud {
  color: #ffffff;
  font-size: 11px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
}

.rank-subtitle-hud {
  display: none; /* Oculto no HUD para economizar espaço */
}

/* Animação de rank up */
@keyframes rankUpGlow {
  0% { box-shadow: 0 0 5px var(--space-gold); }
  50% { box-shadow: 0 0 20px var(--space-gold), 0 0 30px var(--space-gold-bright); }
  100% { box-shadow: 0 0 5px var(--space-gold); }
}

.rank-up-animation {
  animation: rankUpGlow 2s ease-in-out;
}

/* ===== RANKING NA TELA DE ESTATÍSTICAS ===== */
.ranking-info {
  background: linear-gradient(135deg, var(--space-dark) 0%, var(--space-blue-dark) 100%);
  border: 2px solid var(--space-silver);
  border-radius: 12px;
  padding: 20px;
  margin: 20px 0;
  position: relative;
  overflow: hidden;
}

.ranking-info::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--space-blue-medium), var(--space-silver), var(--space-blue-medium));
}

.rank-badge {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.rank-icon-large {
  width: 64px;
  height: 64px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
  transition: transform 0.3s ease;
}

.rank-icon-large:hover {
  transform: scale(1.1) rotate(5deg);
}

.rank-details {
  flex: 1;
}

.rank-title {
  font-family: 'Orbitron', monospace;
  font-weight: 900;
  font-size: 24px;
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  letter-spacing: 2px;
  margin: 0 0 4px 0;
}

.rank-subtitle {
  font-family: 'Orbitron', monospace;
  font-weight: 400;
  font-size: 14px;
  color: var(--space-silver);
  margin: 0;
  opacity: 0.9;
}

/* Barra de progresso para próximo rank */
.rank-progress {
  margin-top: 16px;
}

.rank-progress-label {
  font-family: 'Orbitron', monospace;
  font-size: 12px;
  color: var(--space-silver);
  margin-bottom: 8px;
  display: block;
}

.rank-progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(143, 154, 175, 0.2);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.rank-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--space-blue-medium), var(--space-gold));
  border-radius: 4px;
  transition: width 0.5s ease;
  position: relative;
}

.rank-progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: progressShine 2s infinite;
}

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

/* ===== CLASSES ESPECÍFICAS PARA CADA RANK ===== */
.rank-cadete-espacial .rank-title { color: var(--rank-cadete); }
.rank-cadete-espacial .rank-icon-hud,
.rank-cadete-espacial .rank-icon-large { 
  background-image: url("../assets/images/rank_icons/cadete_espacial.png"); 
}

.rank-piloto-trainee .rank-title { color: var(--rank-trainee); }
.rank-piloto-trainee .rank-icon-hud,
.rank-piloto-trainee .rank-icon-large { 
  background-image: url("../assets/images/rank_icons/piloto_trainee.png"); 
}

.rank-piloto-oficial .rank-title { color: var(--rank-oficial); }
.rank-piloto-oficial .rank-icon-hud,
.rank-piloto-oficial .rank-icon-large { 
  background-image: url("../assets/images/rank_icons/piloto_oficial.png"); 
}

.rank-comandante-espacial .rank-title { color: var(--rank-comandante); }
.rank-comandante-espacial .rank-icon-hud,
.rank-comandante-espacial .rank-icon-large { 
  background-image: url("../assets/images/rank_icons/comandante_espacial.png"); 
}

.rank-capitao-estelar .rank-title { color: var(--rank-capitao); }
.rank-capitao-estelar .rank-icon-hud,
.rank-capitao-estelar .rank-icon-large { 
  background-image: url("../assets/images/rank_icons/capitao_estelar.png"); 
}

.rank-almirante-galactico .rank-title { color: var(--rank-almirante); }
.rank-almirante-galactico .rank-icon-hud,
.rank-almirante-galactico .rank-icon-large { 
  background-image: url("../assets/images/rank_icons/almirante_galactico.png"); 
}

/* ===== RESPONSIVIDADE ===== */
@media (max-width: 768px) {
  #player-rank-hud {
    top: 50px;
    right: 10px;
    padding: 4px 8px;
    gap: 6px;
  }
  
  .rank-icon-hud {
    width: 20px;
    height: 20px;
  }
  
  .rank-title-hud {
    font-size: 9px;
  }
  
  .ranking-info {
    padding: 16px;
    margin: 16px 0;
  }
  
  .rank-badge {
    gap: 12px;
  }
  
  .rank-icon-large {
    width: 48px;
    height: 48px;
  }
  
  .rank-title {
    font-size: 18px;
    letter-spacing: 1px;
  }
  
  .rank-subtitle {
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  #player-rank-hud {
    display: none !important;
  }
}

/* ===== EFEITOS ESPECIAIS ===== */
.rank-glow-effect {
  position: relative;
}

.rank-glow-effect::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg, var(--space-gold), var(--space-gold-bright), var(--space-gold));
  border-radius: inherit;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.rank-glow-effect:hover::before {
  opacity: 0.7;
}

/* Partículas de fundo para ranks superiores */
.rank-particles {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  overflow: hidden;
}

.rank-particles::before,
.rank-particles::after {
  content: '✦';
  position: absolute;
  color: var(--space-gold);
  font-size: 12px;
  opacity: 0.3;
  animation: floatParticles 6s infinite ease-in-out;
}

.rank-particles::before {
  top: 20%;
  left: 10%;
  animation-delay: 0s;
}

.rank-particles::after {
  top: 60%;
  right: 15%;
  animation-delay: 3s;
}

@keyframes floatParticles {
  0%, 100% { transform: translateY(0px) rotate(0deg); opacity: 0.3; }
  50% { transform: translateY(-10px) rotate(180deg); opacity: 0.6; }
}

/* Aplicar partículas apenas nos ranks superiores */
.rank-capitao-estelar .ranking-info,
.rank-almirante-galactico .ranking-info {
  position: relative;
}

.rank-capitao-estelar .ranking-info::after,
.rank-almirante-galactico .ranking-info::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 20% 30%, rgba(212, 175, 55, 0.1) 0%, transparent 50%),
              radial-gradient(circle at 80% 70%, rgba(255, 215, 0, 0.1) 0%, transparent 50%);
  pointer-events: none;
}

/* ===== ESTILOS MELHORADOS PARA O HUD DO JOGADOR ===== */
#player-rank-hud {
    position: absolute;
    top: 26px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    border: 1px solid #333;
    font-family: 'Orbitron', monospace;
    font-weight: bold;
    color: #fff;
    text-align: center;
    z-index: 10;
    display: none; /* Oculto por padrão, será exibido via JS */
    max-width: 400px; /* <--- AQUI VOCÊ AJUSTA A LARGURA NO DESKTOP */
    max-height: 35px;
}

#player-rank-hud:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.6);
}

.rank-icon-hud {
  width: 40px;
  height: 40px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
  flex-shrink: 0;
}

.rank-info-hud {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.rank-title-hud {
  color: #ffffff;
  font-size: 14px;
  font-weight: bold;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
  font-family: 'Orbitron', monospace;
}

.rank-subtitle-hud {
  color: rgba(255, 255, 255, 0.8);
  font-size: 10px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

/* Animação de rank up melhorada */
@keyframes rankUpPulse {
  0% { 
    transform: scale(1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  }
  25% { 
    transform: scale(1.05);
    box-shadow: 0 6px 30px rgba(255, 215, 0, 0.6);
  }
  50% { 
    transform: scale(1.1);
    box-shadow: 0 8px 40px rgba(255, 215, 0, 0.8);
  }
  75% { 
    transform: scale(1.05);
    box-shadow: 0 6px 30px rgba(255, 215, 0, 0.6);
  }
  100% { 
    transform: scale(1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  }
}

.rank-up-animation {
  animation: rankUpPulse 2s ease-in-out;
}

/* Cores específicas para cada patente no HUD */
.rank-cadete-espacial {
  border-color: var(--rank-cadete);
}

.rank-cadete-espacial::before {
  background: linear-gradient(90deg, transparent, var(--rank-cadete), transparent);
}

.rank-piloto-trainee {
  border-color: var(--rank-trainee);
}

.rank-piloto-trainee::before {
  background: linear-gradient(90deg, transparent, var(--rank-trainee), transparent);
}

.rank-piloto-oficial {
  border-color: var(--rank-oficial);
}

.rank-piloto-oficial::before {
  background: linear-gradient(90deg, transparent, var(--rank-oficial), transparent);
}

.rank-comandante-espacial {
  border-color: var(--rank-comandante);
}

.rank-comandante-espacial::before {
  background: linear-gradient(90deg, transparent, var(--rank-comandante), transparent);
}

.rank-capitao-estelar {
  border-color: var(--rank-capitao);
}

.rank-capitao-estelar::before {
  background: linear-gradient(90deg, transparent, var(--rank-capitao), transparent);
}

.rank-almirante-galactico {
  border-color: var(--rank-almirante);
}

.rank-almirante-galactico::before {
  background: linear-gradient(90deg, transparent, var(--rank-almirante), transparent);
}

/* Efeito de brilho para patentes superiores */
.rank-capitao-estelar, .rank-almirante-galactico {
  position: relative;
}

.rank-capitao-estelar::after, .rank-almirante-galactico::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg, transparent, rgba(255, 215, 0, 0.3), transparent);
  border-radius: 14px;
  z-index: -1;
  animation: shimmer 3s ease-in-out infinite;
}

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

@media (max-width: 768px) {
  #player-rank-hud {
    display: none !important;
  }
}
