/* ============================================
   ULTRA SOPHISTICATED DARK ERROR PAGES
   Theme: Midnight Eclipse
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* CSS Variables */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a25;
  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-tertiary: #ec4899;
  --accent-glow: rgba(99, 102, 241, 0.5);
  --text-primary: #ffffff;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --error-400: #f59e0b;
  --error-401: #f97316;
  --error-403: #ef4444;
  --error-404: #3b82f6;
  --error-500: #dc2626;
  --gradient-start: #6366f1;
  --gradient-end: #ec4899;
}

/* Reset & Base */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
  position: relative;
}

/* Animated Background */
.bg-animation {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  background: 
    radial-gradient(ellipse at 20% 80%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(236, 72, 153, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(139, 92, 246, 0.05) 0%, transparent 70%),
    var(--bg-primary);
}

/* Grid Pattern Overlay */
.grid-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background-image: 
    linear-gradient(rgba(99, 102, 241, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 102, 241, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  animation: gridPulse 8s ease-in-out infinite;
}

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

/* Floating Particles */
.particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--accent-primary);
  border-radius: 50%;
  opacity: 0.3;
  animation: float 15s infinite;
  box-shadow: 0 0 10px var(--accent-glow);
}

.particle:nth-child(1) { left: 10%; animation-delay: 0s; animation-duration: 20s; }
.particle:nth-child(2) { left: 20%; animation-delay: 2s; animation-duration: 18s; }
.particle:nth-child(3) { left: 30%; animation-delay: 4s; animation-duration: 22s; }
.particle:nth-child(4) { left: 40%; animation-delay: 1s; animation-duration: 16s; }
.particle:nth-child(5) { left: 50%; animation-delay: 3s; animation-duration: 24s; }
.particle:nth-child(6) { left: 60%; animation-delay: 5s; animation-duration: 19s; }
.particle:nth-child(7) { left: 70%; animation-delay: 2.5s; animation-duration: 21s; }
.particle:nth-child(8) { left: 80%; animation-delay: 4.5s; animation-duration: 17s; }
.particle:nth-child(9) { left: 90%; animation-delay: 1.5s; animation-duration: 23s; }
.particle:nth-child(10) { left: 5%; animation-delay: 6s; animation-duration: 20s; }

@keyframes float {
  0% {
    transform: translateY(100vh) scale(0);
    opacity: 0;
  }
  10% {
    opacity: 0.3;
  }
  90% {
    opacity: 0.3;
  }
  100% {
    transform: translateY(-100vh) scale(1.5);
    opacity: 0;
  }
}

/* Main Container */
.error-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center; /* Centraliza o erro no ecrã */
  align-items: center;
  padding: 2rem;
  position: relative;
  z-index: 1;
}

/* Error Code Display */
.error-code-wrapper {
  position: relative;
  margin-bottom: 2rem;
}

.error-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(8rem, 20vw, 15rem);
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative;
  z-index: 2;
  text-shadow: none;
  animation: codeGlow 3s ease-in-out infinite;
}

@keyframes codeGlow {
  0%, 100% {
    filter: drop-shadow(0 0 30px var(--accent-glow));
  }
  50% {
    filter: drop-shadow(0 0 60px var(--accent-glow));
  }
}

/* Glitch Effect for Error Code */
.error-code::before,
.error-code::after {
  content: attr(data-code);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.error-code::before {
  animation: glitch-1 3s infinite;
  clip-path: polygon(0 0, 100% 0, 100% 35%, 0 35%);
  opacity: 0.8;
}

.error-code::after {
  animation: glitch-2 3s infinite;
  clip-path: polygon(0 65%, 100% 65%, 100% 100%, 0 100%);
  opacity: 0.8;
}

@keyframes glitch-1 {
  0%, 90%, 100% { transform: translate(0); }
  92% { transform: translate(-5px, 2px); }
  94% { transform: translate(5px, -2px); }
  96% { transform: translate(-3px, 1px); }
}

@keyframes glitch-2 {
  0%, 90%, 100% { transform: translate(0); }
  91% { transform: translate(5px, -2px); }
  93% { transform: translate(-5px, 2px); }
  95% { transform: translate(3px, -1px); }
}

/* Error Icon */
.error-icon {
  width: 120px;
  height: 120px;
  margin-bottom: 2rem;
  position: relative;
  animation: iconFloat 4s ease-in-out infinite;
}

@keyframes iconFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}

.error-icon svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 30px var(--accent-glow));
}

/* Error Title */
.error-title {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 700;
  text-align: center;
  margin-bottom: 1rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

/* Error Description */
.error-description {
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--text-secondary);
  text-align: center;
  max-width: 600px;
  margin-bottom: 2.5rem;
  line-height: 1.7;
}

/* Error Details Box */
.error-details {
  background: rgba(26, 26, 37, 0.6);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 12px;
  padding: 1.5rem 2rem;
  margin-bottom: 2.5rem;
  backdrop-filter: blur(10px);
  max-width: 500px;
  width: 100%;
}

.error-details-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(99, 102, 241, 0.1);
}

.error-details-row:last-child {
  border-bottom: none;
}

.error-details-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.error-details-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  color: var(--text-primary);
  font-weight: 500;
}

/* Action Buttons */
.error-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 2rem;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 12px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  border: none;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.btn:hover::before {
  left: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  color: white;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(99, 102, 241, 0.6);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 2px solid rgba(99, 102, 241, 0.3);
}

.btn-secondary:hover {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.1);
  transform: translateY(-2px);
}

/* Status Indicator */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 50px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: #ef4444;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 2rem;
}

.status-indicator::before {
  content: '';
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

/* Footer */
.error-footer {
  margin-top: auto;      /* O segredo: empurra o footer para o fim do espaço livre */
  padding-top: 3rem;     /* Distância mínima de segurança dos botões */
  padding-bottom: 2rem;
  width: 100%;
  text-align: center;
  position: relative;    /* MUDAR DE ABSOLUTE PARA RELATIVE */
  bottom: auto;          /* Reset aos valores antigos */
  left: auto;            /* Reset aos valores antigos */
  transform: none;       /* Remove o translateX(50%) que causava desalinhamento */
}

.error-footer p {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.error-footer a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color 0.3s;
}

.error-footer a:hover {
  color: var(--accent-secondary);
}

/* Error-specific color themes */
.error-400 { --gradient-start: #f59e0b; --gradient-end: #f97316; --accent-glow: rgba(245, 158, 11, 0.5); }
.error-401 { --gradient-start: #f97316; --gradient-end: #ef4444; --accent-glow: rgba(249, 115, 22, 0.5); }
.error-403 { --gradient-start: #ef4444; --gradient-end: #dc2626; --accent-glow: rgba(239, 68, 68, 0.5); }
.error-404 { --gradient-start: #3b82f6; --gradient-end: #8b5cf6; --accent-glow: rgba(59, 130, 246, 0.5); }
.error-500 { --gradient-start: #dc2626; --gradient-end: #991b1b; --accent-glow: rgba(220, 38, 38, 0.5); }

/* Responsive */
@media (max-width: 768px) {
  .error-container {
    padding: 1.5rem;
  }
  
  .error-actions {
    flex-direction: column;
    width: 100%;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
  
  .error-details {
    padding: 1rem 1.5rem;
  }
  
  .error-icon {
    width: 80px;
    height: 80px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Loading Animation */
.loading-ring {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
