/* ===== ANIME-STYLE LOADING PAGE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-purple: #8B5CF6;
    --secondary-pink: #EC4899;
    --accent-cyan: #06B6D4;
    --accent-yellow: #F59E0B;
    --dark-bg: #0F0F23;
    --darker-bg: #050510;
    --text-white: #FFFFFF;
    --text-glow: #E0E7FF;
    --magic-glow: #A855F7;
    --success-green: #10B981;
}

body {
    font-family: 'Poppins', sans-serif;
    background: var(--dark-bg);
    min-height: 100vh;
    overflow: hidden;
    position: relative;
}

/* ===== ANIMATED BACKGROUND ===== */
.animated-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('png/wall.gif');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -3;
}

/* Add overlay to make text more readable */
.animated-bg::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        135deg,
        rgba(15, 15, 35, 0.7) 0%,
        rgba(26, 26, 46, 0.6) 50%,
        rgba(22, 33, 62, 0.8) 100%
    );
    z-index: 1;
}

/* Thêm overlay tối hơn cho toàn bộ nền để text dễ đọc */
.animated-bg::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, rgba(15, 15, 35, 0.9) 0%, rgba(15, 15, 35, 0.7) 50%, rgba(15, 15, 35, 0.5) 100%);
    z-index: 2;
    pointer-events: none;
}

.nebula {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 30%, rgba(139, 92, 246, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(236, 72, 153, 0.2) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(6, 182, 212, 0.1) 0%, transparent 50%);
    animation: nebulaFloat 20s ease-in-out infinite;
}

.cosmic-dust {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(139, 92, 246, 0.4), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(236, 72, 153, 0.3), transparent);
    background-repeat: repeat;
    background-size: 200px 200px;
    animation: cosmicDrift 30s linear infinite;
}

.stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    animation: starTwinkle 2s ease-in-out infinite alternate;
}

/* ===== MAGIC PARTICLES ===== */
.magic-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.magic-particle {
    position: absolute;
    background: linear-gradient(45deg, var(--primary-purple), var(--secondary-pink));
    border-radius: 50%;
    animation: magicFloat 8s ease-in-out infinite;
    box-shadow: 0 0 10px currentColor;
}

/* ===== MAIN LOADING CONTAINER ===== */
.loading-container {
    position: relative;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: flex-start;  /* Căn trái */
    justify-content: center;
    min-height: 100vh;
    text-align: left;  /* Căn trái text */
    padding: 20px 20px 20px 10%;  /* Thêm padding trái 10% */
    width: 100%;
    max-width: 800px;  /* Giới hạn chiều rộng */
}

/* ===== MAGICAL CIRCLE ===== */
.magic-circle {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 0 40px 0;  /* margin trái = 0, margin phải auto để căn trái */
}

.outer-ring, .middle-ring, .inner-ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid;
    animation: ringRotate 10s linear infinite;
}

.outer-ring {
    width: 200px;
    height: 200px;
    border-color: var(--primary-purple);
    box-shadow: 0 0 20px var(--primary-purple);
    animation-direction: normal;
}

.middle-ring {
    width: 150px;
    height: 150px;
    top: 25px;
    left: 25px;
    border-color: var(--secondary-pink);
    box-shadow: 0 0 15px var(--secondary-pink);
    animation-direction: reverse;
    animation-duration: 8s;
}

.inner-ring {
    width: 100px;
    height: 100px;
    top: 50px;
    left: 50px;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px var(--accent-cyan);
    animation-duration: 6s;
}

/* ===== AVATAR STYLING ===== */
.avatar-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 130px;
    height: 130px;
    z-index: 5;
}

.magical-aura {
    position: absolute;
    inset: -25px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.35) 0%, transparent 70%);
    animation: auraGlow 3s ease-in-out infinite;
    z-index: 1;
}

.avatar-glow {
    position: absolute;
    inset: -15px;
    border-radius: 50%;
    background: linear-gradient(45deg, var(--primary-purple), var(--secondary-pink));
    filter: blur(12px);
    animation: avatarGlow 2s ease-in-out infinite;
    z-index: 1;
}

.avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--text-white);
    position: relative;
    z-index: 3;
    box-shadow: 0 0 25px rgba(139, 92, 246, 0.6);
    backface-visibility: hidden;
    transform: translateZ(0);
}

.avatar-frame {
    position: absolute;
    inset: -18px;
    border: 2px solid var(--accent-yellow);
    border-radius: 50%;
    animation: frameRotate 15s linear infinite;
    z-index: 2;
}

.frame-glow {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 1px solid var(--accent-yellow);
    box-shadow: 0 0 20px var(--accent-yellow);
    animation: frameGlow 2s ease-in-out infinite alternate;
}

/* ===== TITLE STYLING ===== */
.loading-text-container {
    margin: 0 0 40px 0;  /* margin trái = 0 */
    text-align: left;
    width: 100%;
}

.main-title {
    font-family: 'Orbitron', monospace;
    font-size: 3rem;
    font-weight: 900;
    margin-bottom: 20px;
    letter-spacing: 3px;
    text-align: left;  /* Căn trái */
    width: 100%;
}

.title-glow {
    display: inline-block;
    color: var(--text-white);
    text-shadow: 
        0 0 20px rgba(0, 0, 0, 0.8),
        0 0 10px var(--primary-purple),
        0 0 20px var(--primary-purple),
        0 0 30px var(--primary-purple);
    animation: letterGlow 2s ease-in-out infinite alternate;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.5s ease;
}

.title-glow.animate {
    transform: translateY(0);
    opacity: 1;
}

.title-accent {
    display: inline-block;
    color: var(--secondary-pink);
    text-shadow: 
        0 0 20px rgba(0, 0, 0, 0.8),
        0 0 10px var(--secondary-pink),
        0 0 20px var(--secondary-pink);
    margin-left: 10px;
    animation: accentGlow 2s ease-in-out infinite alternate;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.5s ease;
}

.title-accent.animate {
    transform: translateY(0);
    opacity: 1;
}

.loading-subtitle {
    display: flex;
    align-items: center;
    justify-content: flex-start;  /* Căn trái */
    gap: 10px;
    font-size: 1.2rem;
    color: var(--text-white);
    font-weight: 300;
    text-align: left;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.loading-subtitle i {
    color: var(--accent-yellow);
    animation: iconSpin 3s linear infinite;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dots {
    display: flex;
    gap: 5px;
    justify-content: flex-start;  /* Căn trái */
}

.dots span {
    width: 8px;
    height: 8px;
    background: var(--accent-cyan);
    border-radius: 50%;
    animation: dotBounce 1.5s ease-in-out infinite;
}

.dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* ===== PROGRESS BAR ===== */
.progress-container {
    width: 400px;
    margin: 0 0 30px 0;  /* margin trái = 0 */
}

.progress-bg {
    position: relative;
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    overflow: hidden;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-purple), var(--secondary-pink), var(--accent-cyan));
    border-radius: 20px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-glow {
    position: absolute;
    top: -2px;
    left: 0;
    width: 100%;
    height: 16px;
    background: linear-gradient(90deg, var(--primary-purple), var(--secondary-pink), var(--accent-cyan));
    border-radius: 20px;
    filter: blur(8px);
    opacity: 0.7;
    animation: progressGlow 2s ease-in-out infinite;
}

.progress-spark {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 20px;
    height: 20px;
    background: radial-gradient(circle, var(--text-white) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: sparkGlow 1s ease-in-out infinite;
}

.progress-percentage {
    margin-top: 15px;
    font-family: 'Orbitron', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-white);
    text-shadow: 
        0 0 10px var(--accent-cyan),
        0 0 20px rgba(0, 0, 0, 0.5);
    text-align: left;  /* Căn trái */
}

/* ===== STATUS MESSAGES ===== */
.status-messages {
    min-height: 30px;
    width: 100%;
    text-align: left;  /* Căn trái */
}

.status-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;  /* Căn trái */
    gap: 10px;
    font-size: 1rem;
    color: var(--text-white);
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    animation: statusFade 0.5s ease-in-out;
    width: 100%;
}

.status-item i {
    color: var(--accent-yellow);
    animation: iconPulse 2s ease-in-out infinite;
    background: rgba(0, 0, 0, 0.3);
    padding: 5px;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== FLOATING ELEMENTS ===== */
.floating-elements {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 15;
}

.floating-icon {
    position: absolute;
    font-size: 1.5rem;
    color: var(--accent-yellow);
    animation: floatUpDown var(--duration) ease-in-out infinite;
    animation-delay: var(--delay);
    opacity: 0.7;
}

.floating-icon:nth-child(1) { top: 20%; left: 10%; }
.floating-icon:nth-child(2) { top: 30%; right: 15%; }
.floating-icon:nth-child(3) { bottom: 30%; left: 20%; }
.floating-icon:nth-child(4) { bottom: 20%; right: 10%; }

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .loading-container {
        padding: 20px 20px 20px 5%;  /* Giảm padding trái trên mobile */
    }
    
    .main-title {
        font-size: 2rem;
        letter-spacing: 2px;
    }
    
    .progress-container {
        width: 300px;
    }
    
    .magic-circle {
        width: 150px;
        height: 150px;
        margin: 0 0 30px 0;
    }
    
    .outer-ring {
        width: 150px;
        height: 150px;
    }
    
    .middle-ring {
        width: 110px;
        height: 110px;
        top: 20px;
        left: 20px;
    }
    
    .inner-ring {
        width: 70px;
        height: 70px;
        top: 40px;
        left: 40px;
    }
    
    .avatar-container {
        width: 60px;
        height: 60px;
    }
    
    .avatar-img {
        width: 60px;
        height: 60px;
    }
    
    /* Điều chỉnh overlay cho mobile */
    .animated-bg::after {
        background: linear-gradient(90deg, rgba(15, 15, 35, 0.9) 0%, rgba(15, 15, 35, 0.8) 100%);
    }
    
    .loading-subtitle {
        font-size: 1rem;
    }
    
    .status-item i {
        width: 25px;
        height: 25px;
        font-size: 0.9rem;
    }
    
    .loading-subtitle i {
        width: 30px;
        height: 30px;
        font-size: 1rem;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes ringRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes auraGlow {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.1); }
}

@keyframes avatarGlow {
    0%, 100% { opacity: 0.6; filter: blur(12px); }
    50% { opacity: 1; filter: blur(15px); }
}

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

@keyframes frameGlow {
    0% { opacity: 0.5; box-shadow: 0 0 10px var(--accent-yellow); }
    100% { opacity: 1; box-shadow: 0 0 30px var(--accent-yellow); }
}

@keyframes letterGlow {
    0% { text-shadow: 0 0 10px var(--primary-purple), 0 0 20px var(--primary-purple); }
    100% { text-shadow: 0 0 20px var(--primary-purple), 0 0 40px var(--primary-purple), 0 0 60px var(--primary-purple); }
}

@keyframes accentGlow {
    0% { text-shadow: 0 0 10px var(--secondary-pink), 0 0 20px var(--secondary-pink); }
    100% { text-shadow: 0 0 20px var(--secondary-pink), 0 0 40px var(--secondary-pink), 0 0 60px var(--secondary-pink); }
}

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

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

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

@keyframes sparkGlow {
    0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.5); }
}

@keyframes iconPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

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

@keyframes nebulaFloat {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

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

@keyframes starTwinkle {
    0% { opacity: 0.2; transform: scale(1); }
    100% { opacity: 1; transform: scale(1.2); }
}

@keyframes magicFloat {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(100px, -50px) rotate(90deg); }
    50% { transform: translate(50px, -100px) rotate(180deg); }
    75% { transform: translate(-50px, -50px) rotate(270deg); }
}

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

/* ===== LOADING COMPLETE ANIMATION ===== */
.loading-complete {
    animation: fadeOut 1s ease-in-out forwards;
}

.loading-complete .magic-circle {
    animation: scaleUp 1s ease-in-out forwards;
}

.loading-complete .main-title {
    animation: titleFadeOut 1s ease-in-out forwards;
}

@keyframes fadeOut {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes scaleUp {
    0% { transform: scale(1); }
    100% { transform: scale(1.5); opacity: 0; }
}

@keyframes titleFadeOut {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* Thêm z-index cho các element quan trọng */
.magic-circle, .loading-text-container, .progress-container, .status-messages {
    position: relative;
    z-index: 25;
}