/**
 * Modern Loader System
 * Sistema de loading moderno e reutilizável para toda a aplicação
 */

/* Loader Overlay - Fundo escuro com blur */
.modern-loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    margin: 0;
    padding: 0;
    animation: fadeIn 0.3s ease-in-out;
}

/* Fade in animation */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Fade out animation */
@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.modern-loader-overlay.fade-out {
    animation: fadeOut 0.3s ease-in-out forwards;
}

/* Loader Container */
.modern-loader-container {
    text-align: center;
    color: white;
    max-width: 400px;
    padding: 2rem;
}

/* Spinner moderno com animação suave */
.modern-loader-spinner {
    width: 64px;
    height: 64px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
    margin: 0 auto 1.5rem;
}

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

/* Spinner alternativo - três pontos pulsantes */
.modern-loader-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 0 auto 1.5rem;
}

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

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

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

.modern-loader-dot:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* Textos do loader */
.modern-loader-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: white;
    animation: fadeInText 0.5s ease-in-out;
}

.modern-loader-subtitle {
    font-size: 0.95rem;
    opacity: 0.8;
    color: rgba(255, 255, 255, 0.8);
    animation: fadeInText 0.5s ease-in-out 0.2s backwards;
}

@keyframes fadeInText {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Barra de progresso opcional */
.modern-loader-progress {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin-top: 1.5rem;
    overflow: hidden;
}

.modern-loader-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    border-radius: 2px;
    transition: width 0.5s ease-in-out;
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% center;
    }
    100% {
        background-position: 200% center;
    }
}

/* Variantes de cor */
.modern-loader-overlay.primary {
    background: rgba(28, 92, 148, 0.9);
}

.modern-loader-overlay.success {
    background: rgba(76, 175, 80, 0.9);
}

.modern-loader-overlay.danger {
    background: rgba(244, 67, 54, 0.9);
}

.modern-loader-overlay.warning {
    background: rgba(255, 152, 0, 0.9);
}

/* Loader inline (para usar dentro de componentes) */
.modern-loader-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

.modern-loader-inline .modern-loader-spinner {
    width: 20px;
    height: 20px;
    border-width: 2px;
    margin: 0;
}

.modern-loader-inline .modern-loader-title {
    margin: 0;
    font-size: 0.95rem;
}

/* Loader pequeno (para botões) */
.modern-loader-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

/* Loader médio */
.modern-loader-md {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

/* Loader grande */
.modern-loader-lg {
    width: 64px;
    height: 64px;
    border-width: 4px;
}

/* Prevent body scroll when loader is active */
body.loader-active {
    overflow: hidden !important;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .modern-loader-overlay {
        background: rgba(0, 0, 0, 0.95);
    }
}

/* Responsivo */
@media (max-width: 576px) {
    .modern-loader-container {
        padding: 1.5rem;
    }

    .modern-loader-title {
        font-size: 1.1rem;
    }

    .modern-loader-subtitle {
        font-size: 0.875rem;
    }

    .modern-loader-spinner {
        width: 48px;
        height: 48px;
    }
}
