@import url('tokens.css');

/**
 * Global Loading Screen Styles
 * شاشة تحميل عامة لجميع الصفحات
 */

/* إخفاء كل شيء افتراضياً حتى يكتمل التحميل */
html:not(.settings-ready) {
    overflow: hidden !important;
}

html:not(.settings-ready) body {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* إظهار المحتوى فقط بعد اكتمال التحميل */
html.settings-ready body {
    opacity: 1 !important;
    visibility: visible !important;
    transition: opacity 0.3s ease-in;
}

/* منع التمرير أثناء التحميل */
body.settings-loading {
    overflow: hidden !important;
}

/* شاشة التحميل */
#global-settings-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--primary-color, #1a365d) 0%, var(--secondary-color, #2d3748) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    transition: opacity 0.5s ease-out;
}

#global-settings-loader .loader-content {
    text-align: center;
}

/* Spinner Animation */
#global-settings-loader .spinner {
    width: 80px;
    height: 80px;
    border: 6px solid rgba(255, 255, 255, 0.2);
    border-top: 6px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* نص التحميل */
#global-settings-loader .loader-text {
    color: white;
    font-size: 18px;
    font-weight: 500;
    margin: 0;
    font-family: var(--font-sans);
    animation: pulse 1.5s ease-in-out infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
    #global-settings-loader .spinner {
        width: 60px;
        height: 60px;
        border-width: 4px;
    }
    
    #global-settings-loader .loader-text {
        font-size: 16px;
    }
}

/* شاشة تحميل بديلة (dots) */
.loader-dots {
    display: flex;
    gap: 8px;
    margin-top: 20px;
}

.loader-dots .dot {
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loader-dots .dot:nth-child(1) {
    animation-delay: -0.32s;
}

.loader-dots .dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* تأثير الاختفاء */
#global-settings-loader.fade-out {
    opacity: 0;
    pointer-events: none;
}
