/* Loading Screen - Matching iOS OnboardingFlow loading state */

#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  margin: 0;
  padding: 0;
  background: var(--brokerly-background, #f8fafc);
  opacity: 1;
  transition: opacity 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

#loading-screen.fade-out {
  opacity: 0 !important;
  pointer-events: none !important;
}

#loading-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.loading-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 0;
}

.loading-logo {
  width: 320px;
  height: 320px;
  border-radius: 64px;
  object-fit: cover;
  background: #ffffff;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  animation: logoEntrance 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards, vibrantPulse 2s ease-in-out infinite 0.8s;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, filter 0.3s ease, opacity 0.3s ease;
}

@media (max-width: 480px) {
  .logo-container {
    width: 180px;
    height: 180px;
  }

  .loading-logo {
    width: 180px;
    height: 180px;
    border-radius: 36px;
    object-fit: cover;
    background: #ffffff;
  }

  .logo-container::before {
    width: 240px;
    height: 240px;
    filter: blur(30px) saturate(2);
  }

  .logo-container::after {
    width: 260px;
    height: 260px;
    filter: blur(40px) saturate(2.5);
  }
}

@keyframes logoEntrance {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes vibrantPulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    filter: brightness(1) saturate(1);
  }

  50% {
    transform: scale(1.15);
    box-shadow: 0 0 60px var(--brokerly-primary, #3b82f6), 0 0 100px var(--brokerly-secondary, #8b5cf6);
    filter: brightness(1.2) saturate(1.4);
  }
}



/* Exit transition - Smooth 10% Z-axis drop transition */
#loading-screen.exiting .minimalist-loader {
  opacity: 0 !important;
  transition: opacity 0.2s ease-out;
}

.minimalist-loader {
  opacity: 0;
  animation: fadeIn 0.6s ease-out forwards 0.6s;
  margin-top: 16px;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

.logo-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  width: 320px;
  height: 320px;
}

/* Solar Corona Halo Effect */
.logo-container::before,
.logo-container::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: auto;
  border-radius: 50%;
  transform-origin: center center;
  z-index: -1;
  mix-blend-mode: screen;
  pointer-events: none;
}

.logo-container::before {
  width: 420px;
  height: 420px;
  background: conic-gradient(
    from 0deg,
    #ff6e5a, /* Neon Coral */
    #ffe100, /* Neon Gold */
    #00fa96, /* Neon Emerald */
    #3ca0ff, /* Neon Blue */
    #b464ff, /* Neon Purple */
    #00f0dc, /* Neon Teal */
    #ff6e5a  /* loop */
  );
  filter: blur(50px) saturate(2);
  opacity: 0.8;
  animation: coronaSpin 8s linear infinite, coronaMorph 5s ease-in-out infinite alternate;
}

.logo-container::after {
  width: 460px;
  height: 460px;
  background: conic-gradient(
    from 180deg,
    #00f0dc,
    #3ca0ff,
    #ffe100,
    #ff6e5a,
    #b464ff,
    #00fa96,
    #00f0dc
  );
  filter: blur(70px) saturate(2.5);
  opacity: 0.6;
  animation: coronaSpinReverse 12s linear infinite, coronaMorphReverse 7s ease-in-out infinite alternate;
}

@keyframes coronaSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes coronaSpinReverse {
  0% { transform: rotate(360deg); }
  100% { transform: rotate(0deg); }
}

@keyframes coronaMorph {
  0% { border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%; }
  33% { border-radius: 70% 30% 50% 50% / 30% 30% 70% 70%; }
  66% { border-radius: 100% 60% 60% 100% / 100% 100% 60% 60%; }
  100% { border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%; }
}

@keyframes coronaMorphReverse {
  0% { border-radius: 100% 60% 60% 100% / 100% 100% 60% 60%; }
  33% { border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%; }
  66% { border-radius: 70% 30% 50% 50% / 30% 30% 70% 70%; }
  100% { border-radius: 100% 60% 60% 100% / 100% 100% 60% 60%; }
}

.loading-progress-container {
  width: 200px;
  height: 3px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.loading-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg,
      var(--brokerly-primary, #3b82f6),
      var(--brokerly-secondary, #8b5cf6));
  border-radius: 3px;
  animation: loadingProgress 1.4s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

@keyframes loadingProgress {
  0% {
    left: -40%;
    width: 30%;
  }
  50% {
    width: 60%;
  }
  100% {
    left: 100%;
    width: 30%;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  #loading-screen {
    background: var(--brokerly-bg-dark, #0f172a);
  }

  .loading-logo {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  }

  @keyframes vibrantPulse {
    0%, 100% {
      transform: scale(1);
      box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5), 
                  0 0 70px rgba(59, 130, 246, 0.4);
      filter: brightness(1) saturate(1);
    }
    16% {
      box-shadow: 0 16px 52px rgba(0, 0, 0, 0.55), 
                  0 0 85px rgba(230, 97, 82, 0.7); /* Coral/Red */
      filter: brightness(1.08) saturate(1.2);
    }
    33% {
      box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 
                  0 0 95px rgba(255, 215, 0, 0.65); /* Gold */
      filter: brightness(1.12) saturate(1.25);
    }
    50% {
      transform: scale(1.1);
      box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65), 
                  0 0 105px rgba(16, 185, 129, 0.7); /* Emerald/Green */
      filter: brightness(1.15) saturate(1.3);
    }
    66% {
      box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 
                  0 0 100px rgba(59, 130, 246, 0.75); /* Blue */
      filter: brightness(1.12) saturate(1.25);
    }
    83% {
      box-shadow: 0 16px 52px rgba(0, 0, 0, 0.55), 
                  0 0 90px rgba(139, 92, 246, 0.7); /* Purple/Accent */
      filter: brightness(1.08) saturate(1.2);
    }
  }

  .loading-progress-container {
    background: rgba(255, 255, 255, 0.1);
  }
}

/* Hide app content during load, but NOT the loading screen itself! */
body.is-loading .app-container>*:not(#loading-screen),
body.is-loading .desktop-sidebar {
  display: none !important;
}

.loading-status-container {
  position: absolute;
  top: calc(100% + 24px);
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  min-height: 40px;
  width: 80vw;
  max-width: 320px;
}

/* Playful Loading Status Text - Solid, Elegant High-Contrast Font */
.loading-status-text {
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--brokerly-text-primary, #0f172a);
  display: inline-block;
  transition: opacity 0.3s ease;
}