.loading-screen {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: #e5e5ea;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    opacity: 1;
    visibility: visible;
    transition:
        opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
        visibility 0.6s ease;
    direction: rtl;
    font-family: 'Estedad', 'Vazirmatn', sans-serif;
    overflow: hidden;
}

.loading-screen::before {
    content: '';
    position: absolute;
    top: -20%;
    right: -10%;
    width: 60vw;
    height: 60vw;
    max-width: 600px;
    max-height: 600px;
    background: radial-gradient(circle, rgba(0, 122, 255, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
    animation: loadingFloat 8s ease-in-out infinite;
}

.loading-screen::after {
    content: '';
    position: absolute;
    bottom: -20%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    max-width: 500px;
    max-height: 500px;
    background: radial-gradient(circle, rgba(78, 205, 196, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
    animation: loadingFloat 8s ease-in-out infinite reverse;
}

@keyframes loadingFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(3%, -3%) scale(1.05); }
}

body.dark-theme .loading-screen {
    background: #000000;
}

body.dark-theme .loading-screen::before {
    background: radial-gradient(circle, rgba(255, 215, 0, 0.12) 0%, transparent 70%);
}

body.dark-theme .loading-screen::after {
    background: radial-gradient(circle, rgba(255, 149, 0, 0.12) 0%, transparent 70%);
}

.loading-screen.hide {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loading-screen-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 30px;
    text-align: center;
}

.loading-screen-profile {
    position: relative;
    width: 130px;
    height: 130px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-screen-profile-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    padding: 3px;
    background: conic-gradient(
        from 0deg,
        #007aff 0%,
        #4ecdc4 25%,
        #007aff 50%,
        #4ecdc4 75%,
        #007aff 100%
    );
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    animation: loadingRingRotate 2s linear infinite;
}

body.dark-theme .loading-screen-profile-ring {
    background: conic-gradient(
        from 0deg,
        #ffd700 0%,
        #ff9500 25%,
        #ffd700 50%,
        #ff9500 75%,
        #ffd700 100%
    );
}

@keyframes loadingRingRotate {
    to { transform: rotate(360deg); }
}

.loading-screen-profile-inner {
    position: relative;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--tab-glass-bg, rgba(255, 255, 255, 0.12));
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.15),
        inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    z-index: 2;
}

body.dark-theme .loading-screen-profile-inner {
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.5),
        inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.loading-screen-profile-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    animation: loadingProfilePulse 3s ease-in-out infinite;
}

@keyframes loadingProfilePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

.loading-screen-profile-pulse {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid #007aff;
    opacity: 0;
    pointer-events: none;
    animation: loadingPulseRing 2s ease-out infinite;
}

body.dark-theme .loading-screen-profile-pulse {
    border-color: #ffd700;
}

@keyframes loadingPulseRing {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    100% {
        transform: scale(1.35);
        opacity: 0;
    }
}

.loading-screen-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: #1a1a1a;
    margin: 0;
    font-family: 'Estedad', 'Vazirmatn', sans-serif;
    transition: color 0.3s ease;
}

body.dark-theme .loading-screen-title {
    color: #e8e8e8;
}

.loading-screen-subtitle {
    font-size: 0.9rem;
    color: #666;
    margin: 0;
    font-family: 'Estedad', 'Vazirmatn', sans-serif;
    transition: color 0.3s ease;
}

body.dark-theme .loading-screen-subtitle {
    color: #b0b8c8;
}

.loading-screen-progress {
    position: relative;
    width: 280px;
    max-width: 80vw;
    height: 6px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 99px;
    overflow: hidden;
    margin-top: 4px;
}

body.dark-theme .loading-screen-progress {
    background: rgba(255, 255, 255, 0.08);
}

.loading-screen-progress-fill {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #007aff, #4ecdc4);
    border-radius: 99px;
    transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 0 10px rgba(0, 122, 255, 0.4);
}

body.dark-theme .loading-screen-progress-fill {
    background: linear-gradient(90deg, #ffd700, #ff9500);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

.loading-screen-percent {
    font-size: 1.8rem;
    font-weight: 800;
    color: #007aff;
    font-family: 'Estedad', 'Vazirmatn', sans-serif;
    letter-spacing: -0.5px;
    font-variant-numeric: tabular-nums;
    transition: color 0.3s ease;
    display: flex;
    align-items: baseline;
    gap: 2px;
}

body.dark-theme .loading-screen-percent {
    color: #ffd700;
}

.loading-screen-percent-sign {
    font-size: 1rem;
    font-weight: 600;
    opacity: 0.7;
}

.loading-screen-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-right: 4px;
}

.loading-screen-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #007aff;
    animation: loadingDotBlink 1.4s infinite ease-in-out both;
}

body.dark-theme .loading-screen-dots span {
    background: #ffd700;
}

.loading-screen-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-screen-dots span:nth-child(2) { animation-delay: -0.16s; }
.loading-screen-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes loadingDotBlink {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.loading-screen-brand {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Great Vibes', cursive;
    font-size: 1.2rem;
    color: #888;
    opacity: 0.6;
    z-index: 2;
    transition: color 0.3s ease;
}

body.dark-theme .loading-screen-brand {
    color: #6a7a8a;
}

@media (max-width: 480px) {
    .loading-screen-profile {
        width: 110px;
        height: 110px;
    }

    .loading-screen-profile-inner {
        width: 92px;
        height: 92px;
    }

    .loading-screen-title {
        font-size: 1.2rem;
    }

    .loading-screen-subtitle {
        font-size: 0.8rem;
    }

    .loading-screen-percent {
        font-size: 1.5rem;
    }

    .loading-screen-progress {
        width: 220px;
    }

    .loading-screen-brand {
        font-size: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .loading-screen,
    .loading-screen::before,
    .loading-screen::after,
    .loading-screen-profile-ring,
    .loading-screen-profile-inner img,
    .loading-screen-profile-pulse,
    .loading-screen-dots span {
        animation: none !important;
        transition: none !important;
    }
}