/**
 * Estilos para Animações de Carregamento
 * Sistema STTP - Portal do Motorista
 */

/* Overlay de carregamento */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(3px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

#loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Conteúdo do loading */
.loading-content {
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 300px;
    width: 90%;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Spinner principal */
.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #28a745;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* Textos do loading */
.loading-text {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.loading-subtext {
    font-size: 14px;
    color: #666;
    margin-bottom: 0;
}

/* Spinner para botões */
.btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

/* Estados de loading para botões */
.btn.loading {
    pointer-events: none;
    opacity: 0.8;
    position: relative;
}

.btn.loading:disabled {
    opacity: 0.8;
}

/* Animação de pulse para elementos importantes */
.loading-pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Loading para cards */
.card.loading {
    position: relative;
    pointer-events: none;
}

.card.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 1;
    border-radius: inherit;
}

.card.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #28a745;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translate(-50%, -50%);
    z-index: 2;
}

/* Loading para navegação */
.nav-btn.loading {
    position: relative;
    pointer-events: none;
}

.nav-btn.loading::before {
    content: '';
    position: absolute;
    top: 5px;
    right: 5px;
    width: 12px;
    height: 12px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #28a745;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1;
}

/* Estados de loading para formulários */
.form-section.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

/* Overlay simples para seções */
.section-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
}

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

.loading-dots::after {
    content: '';
    animation: dots 1.5s infinite;
}

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

/* Loading específico para upload */
.upload-loading {
    display: none;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #28a745;
}

.upload-loading.active {
    display: flex;
}

.upload-progress {
    flex: 1;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
}

.upload-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #28a745, #20c997);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 3px;
}

/* Responsividade */
@media (max-width: 768px) {
    .loading-content {
        padding: 30px 20px;
        margin: 20px;
    }

    .loading-spinner {
        width: 40px;
        height: 40px;
        border-width: 3px;
    }

    .loading-text {
        font-size: 16px;
    }

    .loading-subtext {
        font-size: 13px;
    }
}

/* Prevenção de cliques duplos */
.no-double-click {
    pointer-events: none;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

/* Indicador de processo em andamento */
.processing-indicator {
    position: relative;
}

.processing-indicator::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid #28a745;
    border-radius: inherit;
    animation: pulse-border 2s ease-in-out infinite;
}

@keyframes pulse-border {
    0% {
        border-color: #28a745;
        transform: scale(1);
    }
    50% {
        border-color: #20c997;
        transform: scale(1.02);
    }
    100% {
        border-color: #28a745;
        transform: scale(1);
    }
}