/* ===================================
   AI 4 GREEN - GLOBAL LOADING SYSTEM
   Mascot-based loading animations
   =================================== */

/* Loading Overlay */
.ai4g-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 15, 30, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        visibility 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai4g-loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Loading Container */
.ai4g-loading-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    transform: scale(0.8);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai4g-loading-overlay.active .ai4g-loading-container {
    transform: scale(1);
}

/* Mascot Container */
.ai4g-loading-mascot {
    position: relative;
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Mascot Image */
.ai4g-loading-mascot img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 10px 30px rgba(0, 255, 136, 0.3));
    animation: mascotFloat 3s ease-in-out infinite;
}

/* Glow Ring around Mascot */
.ai4g-loading-ring {
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: #00ff88;
    border-right-color: #00ff88;
    animation: ringRotate 2s linear infinite;
    opacity: 0.6;
}

.ai4g-loading-ring::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-bottom-color: #00d4ff;
    border-left-color: #00d4ff;
    animation: ringRotate 3s linear infinite reverse;
    opacity: 0.4;
}

/* Particles around Mascot */
.ai4g-loading-particles {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

.ai4g-loading-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: linear-gradient(135deg, #00ff88, #00d4ff);
    border-radius: 50%;
    opacity: 0;
    animation: particleFloat 3s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

.ai4g-loading-particle:nth-child(1) {
    top: 10%;
    left: 50%;
    animation-delay: 0s;
}

.ai4g-loading-particle:nth-child(2) {
    top: 30%;
    left: 80%;
    animation-delay: 0.5s;
}

.ai4g-loading-particle:nth-child(3) {
    top: 60%;
    left: 85%;
    animation-delay: 1s;
}

.ai4g-loading-particle:nth-child(4) {
    top: 80%;
    left: 50%;
    animation-delay: 1.5s;
}

.ai4g-loading-particle:nth-child(5) {
    top: 60%;
    left: 15%;
    animation-delay: 2s;
}

.ai4g-loading-particle:nth-child(6) {
    top: 30%;
    left: 20%;
    animation-delay: 2.5s;
}

/* Loading Text */
.ai4g-loading-text {
    font-family: 'Baloo 2', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: #fff;
    text-align: center;
    margin-top: 1rem;
    position: relative;
}

.ai4g-loading-text::after {
    content: '';
    animation: loadingDots 1.5s steps(4, end) infinite;
}

/* Loading Message */
.ai4g-loading-message {
    font-family: 'Baloo 2', sans-serif;
    font-size: 1rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    max-width: 400px;
    line-height: 1.6;
}

/* Progress Bar (optional) */
.ai4g-loading-progress {
    width: 300px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 1rem;
    display: none;
}

.ai4g-loading-overlay.with-progress .ai4g-loading-progress {
    display: block;
}

.ai4g-loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #00ff88, #00d4ff, #00ff88);
    background-size: 200% 100%;
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
    animation: progressShimmer 2s linear infinite;
}

/* Small Loading Spinner (for buttons/inline) */
.ai4g-loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #00ff88;
    border-radius: 50%;
    animation: spinnerRotate 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

/* ===================================
   ANIMATIONS
   =================================== */

/* Mascot Float Animation */
@keyframes mascotFloat {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    25% {
        transform: translateY(-15px) scale(1.02);
    }

    50% {
        transform: translateY(0) scale(1);
    }

    75% {
        transform: translateY(-8px) scale(0.98);
    }
}

/* Ring Rotation */
@keyframes ringRotate {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Particle Float */
@keyframes particleFloat {
    0% {
        opacity: 0;
        transform: translateY(0) scale(0);
    }

    20% {
        opacity: 1;
        transform: translateY(-20px) scale(1);
    }

    80% {
        opacity: 1;
        transform: translateY(-60px) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateY(-80px) scale(0);
    }
}

/* Loading Dots */
@keyframes loadingDots {

    0%,
    20% {
        content: '';
    }

    40% {
        content: '.';
    }

    60% {
        content: '..';
    }

    80%,
    100% {
        content: '...';
    }
}

/* Progress Shimmer */
@keyframes progressShimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Spinner Rotation */
@keyframes spinnerRotate {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

@media (max-width: 768px) {
    .ai4g-loading-mascot {
        width: 150px;
        height: 150px;
    }

    .ai4g-loading-ring {
        width: 170px;
        height: 170px;
    }

    .ai4g-loading-text {
        font-size: 1.25rem;
    }

    .ai4g-loading-message {
        font-size: 0.9rem;
        max-width: 300px;
        padding: 0 1rem;
    }

    .ai4g-loading-progress {
        width: 250px;
    }
}

@media (max-width: 480px) {
    .ai4g-loading-mascot {
        width: 120px;
        height: 120px;
    }

    .ai4g-loading-ring {
        width: 140px;
        height: 140px;
    }

    .ai4g-loading-text {
        font-size: 1.1rem;
    }

    .ai4g-loading-message {
        font-size: 0.85rem;
    }

    .ai4g-loading-progress {
        width: 200px;
    }
}

/* ===================================
   UTILITY CLASSES
   =================================== */

/* Prevent body scroll when loading */
body.ai4g-loading-active {
    overflow: hidden;
}

/* Button loading state */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spinnerRotate 0.8s linear infinite;
}

/* Section loading overlay */
.section-loading {
    position: relative;
    pointer-events: none;
}

.section-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 15, 30, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}