/**
 * Estilos do Preload Global
 * Overlay elegante com animação suave para todas as ações do sistema
 */

/* Container principal do preload */
#preload-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Overlay ativo */
#preload-overlay.active {
    display: flex;
    opacity: 1;
    visibility: visible;
}

#preload-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
}

/* Container do spinner */
.preload-spinner {
    position: relative;
    width: 50px;
    height: 50px;
    margin-bottom: 16px;
}

/* Spinner principal - anel rotativo */
.spinner-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 4px solid transparent;
    border-top-color: #6C9BD5;
    border-right-color: #6C9BD5;
    animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

/* Anel secundário - delay na animação */
.spinner-ring:nth-child(2) {
    top: 5px;
    left: 5px;
    width: calc(100% - 10px);
    height: calc(100% - 10px);
    border-top-color: #8BC4E8;
    border-right-color: #8BC4E8;
    animation-delay: -0.4s;
}

/* Anel terciário - mais delay */
.spinner-ring:nth-child(3) {
    top: 10px;
    left: 10px;
    width: calc(100% - 20px);
    height: calc(100% - 20px);
    border-top-color: #5B9BD5;
    border-right-color: #5B9BD5;
    animation-delay: -0.8s;
}

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

/* Centro do spinner com ícone */
.spinner-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    color: #6C9BD5;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.6;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
}

/* Texto de carregamento */
.preload-text {
    font-family: 'Roboto', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.9375rem;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
    text-align: center;
    animation: fadeInUp 0.5s ease;
}

.preload-subtext {
    font-family: 'Roboto', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.8125rem;
    color: #666;
    text-align: center;
    animation: fadeInUp 0.5s ease 0.1s both;
}

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

/* Barra de progresso */
.preload-progress {
    width: 150px;
    height: 3px;
    background: rgba(224, 224, 224, 0.7);
    border-radius: 2px;
    margin-top: 12px;
    overflow: hidden;
    animation: fadeInUp 0.5s ease 0.2s both;
}

.preload-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #6C9BD5 0%, #8BC4E8 50%, #6C9BD5 100%);
    background-size: 200% 100%;
    border-radius: 2px;
    animation: progress 1.5s ease-in-out infinite;
    width: 0%;
}

@keyframes progress {
    0% {
        width: 0%;
        background-position: 0% 50%;
    }
    50% {
        width: 70%;
    }
    100% {
        width: 100%;
        background-position: 100% 50%;
    }
}

/* Preload compacto para ações rápidas */
#preload-overlay.compact {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(1px);
}

#preload-overlay.compact .preload-spinner {
    width: 40px;
    height: 40px;
}

#preload-overlay.compact .spinner-ring:nth-child(2) {
    top: 4px;
    left: 4px;
    width: calc(100% - 8px);
    height: calc(100% - 8px);
}

#preload-overlay.compact .spinner-ring:nth-child(3) {
    top: 8px;
    left: 8px;
    width: calc(100% - 16px);
    height: calc(100% - 16px);
}

#preload-overlay.compact .spinner-center {
    font-size: 14px;
}

#preload-overlay.compact .preload-text {
    font-size: 0.875rem;
}

#preload-overlay.compact .preload-subtext,
#preload-overlay.compact .preload-progress {
    display: none;
}

/* Preload minimalista para micro-interações */
#preload-overlay.minimal {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(1px);
}

#preload-overlay.minimal .preload-content {
    background: rgba(255, 255, 255, 0.7);
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(4px);
}

#preload-overlay.minimal .preload-spinner {
    width: 32px;
    height: 32px;
    margin-bottom: 12px;
}

#preload-overlay.minimal .spinner-ring {
    border-width: 2.5px;
}

#preload-overlay.minimal .spinner-ring:nth-child(2) {
    top: 3px;
    left: 3px;
    width: calc(100% - 6px);
    height: calc(100% - 6px);
}

#preload-overlay.minimal .spinner-ring:nth-child(3) {
    top: 6px;
    left: 6px;
    width: calc(100% - 12px);
    height: calc(100% - 12px);
}

#preload-overlay.minimal .spinner-center {
    font-size: 12px;
}

#preload-overlay.minimal .preload-text {
    font-size: 0.8125rem;
    margin-bottom: 0;
}

#preload-overlay.minimal .preload-subtext,
#preload-overlay.minimal .preload-progress {
    display: none;
}

/* Ícones específicos para diferentes ações */
.preload-icon {
    display: none;
}

.preload-icon.active {
    display: block;
}

/* Responsividade */
@media (max-width: 768px) {
    #preload-overlay .preload-spinner {
        width: 40px;
        height: 40px;
    }

    #preload-overlay .spinner-ring:nth-child(2) {
        top: 4px;
        left: 4px;
        width: calc(100% - 8px);
        height: calc(100% - 8px);
    }

    #preload-overlay .spinner-ring:nth-child(3) {
        top: 8px;
        left: 8px;
        width: calc(100% - 16px);
        height: calc(100% - 16px);
    }

    #preload-overlay .spinner-center {
        font-size: 14px;
    }

    #preload-overlay .preload-text {
        font-size: 0.875rem;
    }

    #preload-overlay .preload-subtext {
        font-size: 0.75rem;
    }

    #preload-overlay .preload-progress {
        width: 120px;
    }
}

/* Animação de dots para loading text */
.dots {
    display: inline-block;
}

.dots::after {
    content: '.';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% {
        content: '';
    }
    40% {
        content: '.';
    }
    60% {
        content: '..';
    }
    80%, 100% {
        content: '...';
    }
}

/* Suporte para modo escuro (se necessário no futuro) */
@media (prefers-color-scheme: dark) {
    #preload-overlay {
        background: rgba(30, 30, 30, 0.3);
    }

    #preload-overlay .preload-text {
        color: #fff;
    }

    #preload-overlay .preload-subtext {
        color: #ccc;
    }

    #preload-overlay .preload-progress {
        background: rgba(255, 255, 255, 0.1);
    }
}

