/* WebSkel Spinner Styles - Modern Loading Animation */

/* Reset for all dialogs to ensure proper display */
dialog {
    margin: 0;
    padding: 0;
    border: none;
}

/* Initial loading spinner - appears immediately */
.initial-spinner {
    opacity: 1;
}

/* Fallback full-screen overlay */
.spinner-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.2) !important;
    z-index: 99999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Dialog backdrop */
dialog.spinner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border: none;
    padding: 0;
    margin: 0;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

dialog.spinner::backdrop {
    background: transparent;
}

/* Fix for iOS/Safari */
dialog.spinner[open] {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
    max-width: none !important;
    max-height: none !important;
}

/* Ensure full coverage on mobile devices */
@supports (padding: max(0px)) {
    dialog.spinner {
        width: 100vw;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile */
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* Loading animation container */
dialog.spinner-default-style {
    min-width: 120px;
    min-height: 120px;
}

dialog.spinner-default-style::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70px;
    height: 70px;
    background: var(--surface, rgba(255, 255, 255, 0.95));
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Modern circular loader with dots */
dialog.spinner-default-style::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin-left: -20px;
    margin-top: -20px;
    border: 3px solid var(--background-secondary, rgba(0, 0, 0, 0.08));
    border-top-color: var(--primary, #4CAF50);
    border-radius: 50%;
    animation: spinRotate 0.8s linear infinite;
}

/* Additional animated dots */
.spinner-dots {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    gap: 8px;
}

.spinner-dot {
    width: 10px;
    height: 10px;
    background: var(--primary, #4CAF50);
    border-radius: 50%;
    animation: dotPulse 1.5s ease-in-out infinite;
}

.spinner-dot:nth-child(1) { animation-delay: 0s; }
.spinner-dot:nth-child(2) { animation-delay: 0.15s; }
.spinner-dot:nth-child(3) { animation-delay: 0.3s; }

/* Alternative pulse animation */
.spinner-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
}

.spinner-pulse::before,
.spinner-pulse::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--primary, #4CAF50);
    opacity: 0.6;
    animation: pulseBig 2s ease-in-out infinite;
}

.spinner-pulse::after {
    animation-delay: 1s;
}

/* Loading text */
.spinner-text {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text, #fff);
    font-size: 14px;
    font-weight: 500;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    animation: fadeInOut 2s ease-in-out infinite;
}

/* Animations */
@keyframes spinRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes dotPulse {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    30% {
        transform: scale(1.5);
        opacity: 0.6;
    }
}

@keyframes pulseBig {
    0% {
        transform: scale(0.8);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.4;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

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

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    dialog.spinner {
        background: rgba(0, 0, 0, 0.3);
    }
    
    dialog.spinner-default-style::before {
        background: var(--surface, rgba(42, 42, 42, 0.95));
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }
    
    dialog.spinner-default-style::after {
        border-color: var(--background-secondary, rgba(255, 255, 255, 0.1));
        border-top-color: var(--primary, #4CAF50);
    }
    
    .spinner-text {
        color: var(--text, #fff);
    }
}

/* Responsive design */
@media (max-width: 768px) {
    dialog.spinner-default-style::before {
        width: 60px;
        height: 60px;
        border-radius: 15px;
    }
    
    dialog.spinner-default-style::after {
        width: 40px;
        height: 40px;
        margin-left: -20px;
        margin-top: -20px;
    }
    
    .spinner-text {
        font-size: 12px;
        bottom: 20px;
    }
}

/* Alternative modern spinner styles */
.spinner-modern {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.spinner-modern .ring {
    width: 64px;
    height: 64px;
    border: 8px solid transparent;
    border-radius: 50%;
    position: absolute;
    animation: ringRotate 1.5s linear infinite;
}

.spinner-modern .ring:nth-child(1) {
    border-top-color: var(--primary, #4CAF50);
    animation-delay: 0s;
}

.spinner-modern .ring:nth-child(2) {
    border-right-color: var(--primary-hover, #45a049);
    animation-delay: 0.15s;
    width: 54px;
    height: 54px;
    margin: 5px;
}

.spinner-modern .ring:nth-child(3) {
    border-bottom-color: var(--primary-light, #66BB6A);
    animation-delay: 0.3s;
    width: 44px;
    height: 44px;
    margin: 10px;
}

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

/* Loading bar style */
.spinner-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--background-secondary, rgba(0, 0, 0, 0.1));
    overflow: hidden;
}

.spinner-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent,
        var(--primary, #4CAF50),
        transparent
    );
    animation: slideBar 1.5s ease-in-out infinite;
}

@keyframes slideBar {
    0% { left: -100%; }
    100% { left: 100%; }
}