/* ============================================================
   ELMANHAG — Professional Loading Overlay
   هوية المنصة: ذهبي (#D97706) × أسود فحمي + قبعة تخرج
   الاستخدام: window.ElmanhagLoader.show() / .complete() / .hide()
   ============================================================ */

.elm-loader-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 50% 38%, rgba(217, 119, 6, 0.10) 0%, transparent 55%),
    linear-gradient(135deg, #080810 0%, #14141B 55%, #0A0A0D 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.5s ease, visibility 0.5s ease;
  overflow: hidden;
}

.elm-loader-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* شبكة هندسية خافتة + تظليل */
.elm-loader-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(217, 119, 6, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(217, 119, 6, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(70% 65% at 50% 42%, #000 25%, transparent 100%);
  pointer-events: none;
}

.elm-loader-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(0, 0, 0, 0.55) 100%);
  pointer-events: none;
}

.elm-loader-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  z-index: 1;
  padding: 20px;
}

/* ---------- الشعار + المدارات ---------- */
.elm-loader-logo-wrapper {
  position: relative;
  width: 170px;
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.elm-loader-glow {
  position: absolute;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(217, 119, 6, 0.22) 0%, transparent 70%);
  animation: elmGlowPulse 2.2s ease-in-out infinite;
}

@keyframes elmGlowPulse {
  0%, 100% { transform: scale(1); opacity: 0.55; }
  50% { transform: scale(1.18); opacity: 1; }
}

.elm-loader-orbit {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(217, 119, 6, 0.16);
}

.elm-loader-orbit:nth-child(2) {
  width: 160px;
  height: 160px;
  border-top-color: rgba(217, 119, 6, 0.75);
  animation: elmOrbitSpin 3s linear infinite;
}

.elm-loader-orbit:nth-child(3) {
  width: 138px;
  height: 138px;
  border-bottom-color: rgba(245, 158, 11, 0.55);
  animation: elmOrbitSpin 2.1s linear infinite reverse;
}

.elm-loader-orbit:nth-child(4) {
  width: 116px;
  height: 116px;
  border-left-color: rgba(251, 191, 36, 0.45);
  animation: elmOrbitSpin 1.6s linear infinite;
}

@keyframes elmOrbitSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.elm-loader-logo {
  position: relative;
  z-index: 2;
  max-width: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: elmLogoFloat 3s ease-in-out infinite;
  filter: drop-shadow(0 0 18px rgba(217, 119, 6, 0.45));
}

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

.elm-loader-logo img {
  max-width: 150px;
  max-height: 84px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.elm-loader-logo-fallback {
  width: 74px;
  height: 74px;
  border-radius: 22px;
  background: linear-gradient(135deg, #D97706, #92400E);
  color: #0A0A0D;
  font-weight: 900;
  font-size: 2rem;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(217, 119, 6, 0.4);
}

.elm-loader-brand {
  font-weight: 900;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  color: #F5C66B;
}

/* ---------- مشهد قبعة التخرج ---------- */
.elm-loader-scene {
  position: relative;
  width: 150px;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.elm-loader-ring {
  position: absolute;
  width: 128px;
  height: 128px;
  border: 1px solid rgba(217, 119, 6, 0.18);
  border-radius: 50%;
}

.elm-loader-ring::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 14%;
  right: 14%;
  height: 1px;
  background: rgba(217, 119, 6, 0.14);
}

.elm-loader-cap {
  position: relative;
  z-index: 2;
  animation: elmCapFloat 2.6s ease-in-out infinite;
  filter: drop-shadow(0 0 14px rgba(217, 119, 6, 0.55));
}

.elm-loader-cap svg {
  width: 64px;
  height: 64px;
  display: block;
}

@keyframes elmCapFloat {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-12px) rotate(4deg); }
}

.elm-loader-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.elm-loader-particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: rgba(245, 158, 11, 0.7);
  border-radius: 50%;
  animation: elmParticleFloat 3s ease-in-out infinite;
}

.elm-loader-particle:nth-child(1) { top: 12%; left: 22%; animation-delay: 0s; }
.elm-loader-particle:nth-child(2) { top: 30%; right: 16%; animation-delay: 0.5s; }
.elm-loader-particle:nth-child(3) { bottom: 20%; left: 12%; animation-delay: 1s; }
.elm-loader-particle:nth-child(4) { top: 52%; right: 8%; animation-delay: 1.5s; }
.elm-loader-particle:nth-child(5) { top: 16%; right: 38%; animation-delay: 2s; }
.elm-loader-particle:nth-child(6) { bottom: 12%; right: 28%; animation-delay: 2.5s; }
.elm-loader-particle:nth-child(7) { top: 42%; left: 8%; animation-delay: 0.3s; }
.elm-loader-particle:nth-child(8) { top: 26%; left: 44%; animation-delay: 1.8s; }

@keyframes elmParticleFloat {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.25; }
  50% { transform: translateY(-18px) scale(1.5); opacity: 1; }
}

/* ---------- النص + التقدم ---------- */
.elm-loader-info {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.elm-loader-text {
  color: #ffffff;
  font-size: 19px;
  font-weight: 800;
  font-family: 'Cairo', 'Tajawal', sans-serif;
  text-shadow: 0 0 18px rgba(217, 119, 6, 0.45);
}

.elm-loader-text .dots span {
  animation: elmDotPulse 1.5s ease-in-out infinite;
  opacity: 0;
  color: #F59E0B;
}

.elm-loader-text .dots span:nth-child(1) { animation-delay: 0s; }
.elm-loader-text .dots span:nth-child(2) { animation-delay: 0.25s; }
.elm-loader-text .dots span:nth-child(3) { animation-delay: 0.5s; }

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

.elm-loader-progress-wrapper {
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.elm-loader-progress-track {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.09);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.elm-loader-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #92400E, #D97706, #F59E0B, #D97706);
  background-size: 200% 100%;
  border-radius: 3px;
  animation: elmProgressShimmer 2s ease-in-out infinite;
  position: relative;
  transition: width 0.3s ease;
}

.elm-loader-progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 34px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  animation: elmProgressGlow 1.6s ease-in-out infinite;
}

@keyframes elmProgressShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes elmProgressGlow {
  0% { inset-inline-start: -34px; opacity: 0; }
  50% { opacity: 1; }
  100% { inset-inline-start: 100%; opacity: 0; }
}

.elm-loader-progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.elm-loader-percent {
  color: #F59E0B;
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 10px rgba(217, 119, 6, 0.5);
}

.elm-loader-status {
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  font-family: 'Cairo', 'Tajawal', sans-serif;
}

/* خطوط سرعة خافتة */
.elm-loader-speed-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.elm-loader-speed-line {
  position: absolute;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(217, 119, 6, 0.28), transparent);
  animation: elmSpeedLine 2.4s ease-in-out infinite;
}

.elm-loader-speed-line:nth-child(1) { top: 22%; width: 70px; left: -90px; animation-delay: 0s; }
.elm-loader-speed-line:nth-child(2) { top: 45%; width: 90px; left: -110px; animation-delay: 0.5s; }
.elm-loader-speed-line:nth-child(3) { top: 65%; width: 60px; left: -80px; animation-delay: 1s; }
.elm-loader-speed-line:nth-child(4) { top: 82%; width: 80px; left: -100px; animation-delay: 1.5s; }

@keyframes elmSpeedLine {
  0% { transform: translateX(0); opacity: 0; }
  50% { opacity: 1; }
  100% { transform: translateX(420px); opacity: 0; }
}

/* ---------- موبايل ---------- */
@media (max-width: 768px) {
  .elm-loader-container { gap: 20px; }
  .elm-loader-logo-wrapper { width: 130px; height: 130px; }
  .elm-loader-glow { width: 112px; height: 112px; }
  .elm-loader-orbit:nth-child(2) { width: 124px; height: 124px; }
  .elm-loader-orbit:nth-child(3) { width: 106px; height: 106px; }
  .elm-loader-orbit:nth-child(4) { width: 88px; height: 88px; }
  .elm-loader-logo img { max-width: 118px; max-height: 66px; }
  .elm-loader-scene { width: 120px; height: 92px; }
  .elm-loader-ring { width: 104px; height: 104px; }
  .elm-loader-cap svg { width: 50px; height: 50px; }
  .elm-loader-text { font-size: 16px; }
  .elm-loader-progress-wrapper { width: 210px; }
}

/* ---------- تقليل الحركة ---------- */
@media (prefers-reduced-motion: reduce) {
  .elm-loader-overlay *, .elm-loader-overlay *::before, .elm-loader-overlay *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
