/* Book Page Turning Animation - Realistic Scroll Effect */
@keyframes pageFlip {
  0% {
    transform: perspective(600px) rotateY(0deg);
    opacity: 1;
    z-index: 3;
  }

  25% {
    transform: perspective(600px) rotateY(-90deg);
    opacity: 0.8;
  }

  50% {
    transform: perspective(600px) rotateY(-180deg);
    opacity: 0;
    z-index: 1;
  }

  51% {
    transform: perspective(600px) rotateY(180deg);
    opacity: 0;
    z-index: 1;
  }

  75% {
    transform: perspective(600px) rotateY(90deg);
    opacity: 0.8;
  }

  100% {
    transform: perspective(600px) rotateY(0deg);
    opacity: 1;
    z-index: 3;
  }
}

@keyframes pageFlipDelay {
  0% {
    transform: perspective(600px) rotateY(0deg);
    opacity: 0.7;
    z-index: 2;
  }

  25% {
    transform: perspective(600px) rotateY(-90deg);
    opacity: 0.6;
  }

  50% {
    transform: perspective(600px) rotateY(-180deg);
    opacity: 0;
    z-index: 1;
  }

  51% {
    transform: perspective(600px) rotateY(180deg);
    opacity: 0;
    z-index: 1;
  }

  75% {
    transform: perspective(600px) rotateY(90deg);
    opacity: 0.6;
  }

  100% {
    transform: perspective(600px) rotateY(0deg);
    opacity: 0.7;
    z-index: 2;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }

  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

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

  50% {
    opacity: 0.7;
  }
}

/* Main Container */
.app-loading {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  top: 10em;
}

.app-loading:first-of-type {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  z-index: 9999;
  overflow: hidden;
}

/* Logo Image - Large and Centered */
.app-loading:first-of-type::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 250px;
  height: 250px;
  /* background-image: url('/content/images/logo-eduportal.png'); */
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  animation:
    fadeIn 0.6s ease-out,
    pulse 2s ease-in-out infinite 0.6s;
  z-index: 10;
  filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.3));
}

/* Book Icon Container */
.app-loading .lds-pacman {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: 200px !important;
  height: 200px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 5 !important;
  perspective: 1000px !important;
}

/* Book Base Container */
.app-loading .lds-pacman > div:nth-child(2) {
  display: flex !important;
  position: relative !important;
  width: 160px !important;
  height: 120px !important;
  justify-content: center !important;
  align-items: center !important;
  transform-style: preserve-3d !important;
}

/* Page 1 - Front turning page */
.app-loading .lds-pacman > div:nth-child(2) div:nth-child(1) {
  position: absolute !important;
  width: 70px !important;
  height: 100px !important;
  background: white !important;
  border: 3px solid #e0e0e0 !important;
  border-radius: 4px !important;
  box-shadow:
    0 5px 20px rgba(0, 0, 0, 0.2),
    inset 0 1px 3px rgba(0, 0, 0, 0.1) !important;
  top: 10px !important;
  right: 5px !important;
  transform-origin: left center !important;
  transform-style: preserve-3d !important;
  animation: pageFlip 3s ease-in-out infinite !important;
  backface-visibility: hidden !important;
}

/* Add subtle page lines */
.app-loading .lds-pacman > div:nth-child(2) div:nth-child(1)::before {
  content: '';
  position: absolute;
  top: 15px;
  left: 8px;
  right: 8px;
  height: 70%;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    transparent 12%,
    #e8e8e8 12%,
    #e8e8e8 14%,
    transparent 14%,
    transparent 26%,
    #e8e8e8 26%,
    #e8e8e8 28%,
    transparent 28%,
    transparent 40%,
    #e8e8e8 40%,
    #e8e8e8 42%,
    transparent 42%,
    transparent 54%,
    #e8e8e8 54%,
    #e8e8e8 56%,
    transparent 56%,
    transparent 68%,
    #e8e8e8 68%,
    #e8e8e8 70%,
    transparent 70%,
    transparent 82%,
    #e8e8e8 82%,
    #e8e8e8 84%,
    transparent 84%
  );
  border-radius: 2px;
}

/* Page 2 - Second layer */
.app-loading .lds-pacman > div:nth-child(2) div:nth-child(2) {
  position: absolute !important;
  width: 70px !important;
  height: 100px !important;
  background: #f8f8f8 !important;
  border: 3px solid #d0d0d0 !important;
  border-radius: 4px !important;
  box-shadow: 0 3px 15px rgba(0, 0, 0, 0.15) !important;
  top: 10px !important;
  right: 5px !important;
  transform-origin: left center !important;
  transform-style: preserve-3d !important;
  animation: pageFlipDelay 3s ease-in-out infinite 0.3s !important;
  backface-visibility: hidden !important;
}

/* Page 2 lines */
.app-loading .lds-pacman > div:nth-child(2) div:nth-child(2)::before {
  content: '';
  position: absolute;
  top: 15px;
  left: 8px;
  right: 8px;
  height: 70%;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    transparent 12%,
    #e0e0e0 12%,
    #e0e0e0 14%,
    transparent 14%,
    transparent 26%,
    #e0e0e0 26%,
    #e0e0e0 28%,
    transparent 28%,
    transparent 40%,
    #e0e0e0 40%,
    #e0e0e0 42%,
    transparent 42%,
    transparent 54%,
    #e0e0e0 54%,
    #e0e0e0 56%,
    transparent 56%,
    transparent 68%,
    #e0e0e0 68%,
    #e0e0e0 70%,
    transparent 70%,
    transparent 82%,
    #e0e0e0 82%,
    #e0e0e0 84%,
    transparent 84%
  );
  border-radius: 2px;
}

/* Book Spine/Left Page (Static) */
.app-loading .lds-pacman > div:nth-child(1) {
  display: block !important;
  position: absolute !important;
  width: 70px !important;
  height: 100px !important;
  background: #fafafa !important;
  border: 3px solid #c0c0c0 !important;
  border-radius: 4px !important;
  top: 50% !important;
  left: calc(50% - 75px) !important;
  transform: translateY(-50%) !important;
  z-index: 1 !important;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15) !important;
}

/* Left page lines */
.app-loading .lds-pacman > div:nth-child(1)::before {
  content: '';
  position: absolute;
  top: 15px;
  left: 8px;
  right: 8px;
  height: 70%;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    transparent 12%,
    #d8d8d8 12%,
    #d8d8d8 14%,
    transparent 14%,
    transparent 26%,
    #d8d8d8 26%,
    #d8d8d8 28%,
    transparent 28%,
    transparent 40%,
    #d8d8d8 40%,
    #d8d8d8 42%,
    transparent 42%,
    transparent 54%,
    #d8d8d8 54%,
    #d8d8d8 56%,
    transparent 56%,
    transparent 68%,
    #d8d8d8 68%,
    #d8d8d8 70%,
    transparent 70%,
    transparent 82%,
    #d8d8d8 82%,
    #d8d8d8 84%,
    transparent 84%
  );
  border-radius: 2px;
}

/* Hide unused div */
.app-loading .lds-pacman > div:nth-child(2) div:nth-child(3) {
  display: none !important;
}

/* Book Binding/Spine */
.app-loading .lds-pacman::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 100px;
  background: linear-gradient(to right, #b0b0b0, #d0d0d0, #b0b0b0);
  border-radius: 2px;
  box-shadow:
    0 3px 10px rgba(0, 0, 0, 0.2),
    inset 0 1px 2px rgba(255, 255, 255, 0.5);
  z-index: 4;
}

/* Book Cover Bottom */
.app-loading .lds-pacman::after {
  content: '';
  position: absolute;
  top: calc(50% + 50px);
  left: 50%;
  transform: translateX(-50%);
  width: 160px;
  height: 8px;
  background: linear-gradient(to bottom, #a0a0a0, #c0c0c0);
  border-radius: 0 0 4px 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  z-index: 0;
}

/* Loading Text */
.app-loading p {
  display: block !important;
  position: absolute !important;
  top: calc(50% + 180px) !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  font-size: 1.5em !important;
  color: white !important;
  font-weight: 600 !important;
  letter-spacing: 2px !important;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
  z-index: 10 !important;
  margin: 0 !important;
  text-align: center !important;
}

/* Responsive Design */
@media (max-width: 768px) {
  .app-loading:first-of-type::before {
    width: 200px;
    height: 200px;
  }

  .app-loading .lds-pacman {
    width: 160px !important;
    height: 160px !important;
  }

  .app-loading .lds-pacman > div:nth-child(2) {
    width: 130px !important;
    height: 100px !important;
  }

  .app-loading .lds-pacman > div:nth-child(2) div {
    width: 55px !important;
    height: 80px !important;
  }

  .app-loading .lds-pacman > div:nth-child(1) {
    width: 55px !important;
    height: 80px !important;
    left: calc(50% - 60px) !important;
  }

  .app-loading .lds-pacman::before {
    height: 80px !important;
  }

  .app-loading .lds-pacman::after {
    top: calc(50% + 40px) !important;
    width: 130px !important;
  }

  .app-loading p {
    font-size: 1.2em !important;
    top: calc(50% + 150px) !important;
  }
}

@media (max-width: 480px) {
  .app-loading:first-of-type::before {
    width: 160px;
    height: 160px;
  }

  .app-loading .lds-pacman {
    width: 140px !important;
    height: 140px !important;
  }

  .app-loading .lds-pacman > div:nth-child(2) {
    width: 110px !important;
    height: 85px !important;
  }

  .app-loading .lds-pacman > div:nth-child(2) div {
    width: 45px !important;
    height: 65px !important;
  }

  .app-loading .lds-pacman > div:nth-child(1) {
    width: 45px !important;
    height: 65px !important;
    left: calc(50% - 50px) !important;
  }

  .app-loading .lds-pacman::before {
    height: 65px !important;
  }

  .app-loading .lds-pacman::after {
    top: calc(50% + 32px) !important;
    width: 110px !important;
  }

  .app-loading p {
    font-size: 1em !important;
    top: calc(50% + 130px) !important;
  }
}
