/* ==========================================================================
   Loading Screen — Server 3D SVG Loader
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Visually hidden (screen readers only)
   ------------------------------------------------------------------------ */
.loader-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   Full-screen overlay
   ------------------------------------------------------------------------ */
.app-loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #f1f5f9;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  transition: opacity 400ms ease, visibility 400ms ease;
}

/* Hide loader once Angular has bootstrapped */
body.app-initialized .app-loading {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Wrapper
   ------------------------------------------------------------------------ */
.loader-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  animation: wrapper-enter 800ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes wrapper-enter {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* --------------------------------------------------------------------------
   Logo
   ------------------------------------------------------------------------ */
.loader-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: -160px;
  z-index: 10;
  animation: logo-rise-and-follow 3s ease-in-out 400ms both;
}

.loader-logo img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(13, 59, 102, 0.3))
          drop-shadow(0 0 20px rgba(18, 181, 229, 0.2));
}

@keyframes logo-rise-and-follow {
  0% {
    opacity: 0;
    transform: translateY(80px) scale(0.3);
    filter: blur(8px);
  }
  20% {
    opacity: 0.8;
    transform: translateY(50px) scale(0.7);
    filter: blur(4px);
  }
  40% {
    opacity: 1;
    transform: translateY(20px) scale(1);
    filter: blur(0px);
  }
  60% {
    opacity: 0.9;
    transform: translateY(-10px) scale(0.95);
    filter: blur(0px);
  }
  80% {
    opacity: 0.5;
    transform: translateY(-40px) scale(0.8);
    filter: blur(3px);
  }
  100% {
    opacity: 0;
    transform: translateY(-70px) scale(0.5);
    filter: blur(6px);
  }
}

/* --------------------------------------------------------------------------
   SVG Container
   ------------------------------------------------------------------------ */
.loader-svg-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 280px;
  height: 280px;
  animation: svg-float 4s ease-in-out infinite;
}

@keyframes svg-float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-12px);
  }
}

.loader-svg-container svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 40px rgba(13, 59, 102, 0.3))
          drop-shadow(0 0 80px rgba(18, 181, 229, 0.15));
}

/* --------------------------------------------------------------------------
   SVG Global
   ------------------------------------------------------------------------ */
#svg-global {
  zoom: 1.2;
  overflow: visible;
}

/* --------------------------------------------------------------------------
   Particle animations
   ------------------------------------------------------------------------ */
@keyframes fade-particles {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes floatUp {
  0% {
    transform: translateY(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  100% {
    transform: translateY(-40px);
    opacity: 0;
  }
}

#particles {
  animation: fade-particles 5s infinite alternate;
}

.particle {
  animation: floatUp linear infinite;
}

.p1 {
  animation-duration: 2.2s;
  animation-delay: 0s;
}
.p2 {
  animation-duration: 2.5s;
  animation-delay: 0.3s;
}
.p3 {
  animation-duration: 2s;
  animation-delay: 0.6s;
}
.p4 {
  animation-duration: 2.8s;
  animation-delay: 0.2s;
}
.p5 {
  animation-duration: 2.3s;
  animation-delay: 0.4s;
}
.p6 {
  animation-duration: 3s;
  animation-delay: 0.1s;
}
.p7 {
  animation-duration: 2.1s;
  animation-delay: 0.5s;
}
.p8 {
  animation-duration: 2.6s;
  animation-delay: 0.2s;
}
.p9 {
  animation-duration: 2.4s;
  animation-delay: 0.3s;
}

/* --------------------------------------------------------------------------
   Bounce lines animation
   ------------------------------------------------------------------------ */
@keyframes bounce-lines {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

#line-v1,
#line-v2,
#node-server,
#panel-rigth,
#reflectores,
#particles {
  animation: bounce-lines 3s ease-in-out infinite alternate;
}
#line-v2 {
  animation-delay: 0.2s;
}

#node-server,
#panel-rigth,
#reflectores,
#particles {
  animation-delay: 0.4s;
}

/* --------------------------------------------------------------------------
   Content below SVG
   ------------------------------------------------------------------------ */
.loader-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: content-enter 600ms cubic-bezier(0.22, 1, 0.36, 1) 300ms both;
}

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

/* --------------------------------------------------------------------------
   Typography
   ------------------------------------------------------------------------ */
.loader-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  color: #0D3B66;
  letter-spacing: -0.02em;
  text-shadow: 0 0 40px rgba(18, 181, 229, 0.3);
}

.loader-subtitle {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 400;
  color: #1A759F;
  letter-spacing: 0.05em;
}

/* --------------------------------------------------------------------------
   Background glow effects
   ------------------------------------------------------------------------ */
.app-loading::before,
.app-loading::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
  pointer-events: none;
}

.app-loading::before {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #0D3B66 0%, transparent 70%);
  top: 20%;
  left: 30%;
  animation: glow-float-1 8s ease-in-out infinite alternate;
}

.app-loading::after {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, #12B5E5 0%, transparent 70%);
  bottom: 20%;
  right: 25%;
  animation: glow-float-2 10s ease-in-out infinite alternate;
}

@keyframes glow-float-1 {
  0% { transform: translate(0, 0); }
  100% { transform: translate(40px, 30px); }
}

@keyframes glow-float-2 {
  0% { transform: translate(0, 0); }
  100% { transform: translate(-30px, -40px); }
}

/* --------------------------------------------------------------------------
   Error overlay
   ------------------------------------------------------------------------ */
.app-loading-error {
  position: fixed;
  z-index: 10000;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
  background: #f8fafc;
  color: #334155;
  pointer-events: none;
}

#jhipster-error {
  width: min(100%, 720px);
  max-height: 90vh;
  overflow: auto;
  padding: 32px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
  color: #475569;
  pointer-events: auto;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

#jhipster-error h1 {
  color: #0f172a;
  font-size: 1.25rem;
  margin-bottom: 16px;
}

#jhipster-error h2,
#jhipster-error h3 {
  color: #1e293b;
  font-size: 1rem;
  margin-top: 16px;
  margin-bottom: 8px;
}

#jhipster-error code {
  color: #0891b2;
  background: #f0fdfa;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.875rem;
}

#jhipster-error a {
  color: #0891b2;
  text-decoration: underline;
}

#jhipster-error ol {
  padding-left: 20px;
}

#jhipster-error li {
  margin-bottom: 4px;
}

/* --------------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------------ */
@media (max-width: 480px) {
  .loader-svg-container {
    width: 200px;
    height: 200px;
  }

  .loader-wrapper {
    gap: 24px;
  }

  .loader-title {
    font-size: 1.35rem;
  }

  .loader-subtitle {
    font-size: 0.8rem;
  }

  .app-loading::before {
    width: 250px;
    height: 250px;
  }

  .app-loading::after {
    width: 200px;
    height: 200px;
  }

  #jhipster-error {
    padding: 24px;
  }
}

/* --------------------------------------------------------------------------
   Reduced motion
   ------------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .loader-svg-container,
  .particle,
  #particles,
  #node-server,
  #line-v1,
  #line-v2,
  #reflectores,
  #panel-rigth,
  .app-loading::before,
  .app-loading::after,
  .loader-wrapper,
  .loader-content,
  .loader-logo {
    animation: none !important;
  }

  .loader-svg-container {
    transform: none;
  }

  .particle {
    opacity: 1;
    transform: none;
  }

  #particles,
  #node-server,
  #reflectores,
  #panel-rigth,
  #line-v1,
  #line-v2 {
    opacity: 1;
  }

  .loader-wrapper {
    opacity: 1;
    transform: none;
  }

  .loader-content {
    opacity: 1;
    transform: none;
  }

  .loader-logo {
    opacity: 1;
    transform: none;
    margin-bottom: 16px;
  }

  .loader-logo img {
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.1));
  }
}
