/**
 * Preloader TranspNet
 * Sistema de carregamento profissional com spinner e progress bar
 * Previne FOUC (Flash of Unstyled Content)
 */

/* ===========================================
   VARIÁVEIS GLOBAIS - CORES DO SITE
   Altere aqui para mudar em todo o site!
   =========================================== */
:root {
    /* CTA Principal (Laranja) */
    --cta-primary: #FF6600;
    --cta-hover: #e63803;
    --cta-gradient-end: #FF8833;

    /* Cores Base */
    --primary-dark: #0c1a24;
    --primary-blue: #3b82f6;
    --primary-blue-light: #60a5fa;

    /* Texto */
    --text-white: #ffffff;
    --text-muted: #9ca3af;
}

/* ===========================================
   CLASSES UTILITÁRIAS - CTA
   Use estas classes para elementos CTA
   =========================================== */

/* Texto com cor CTA */
.text-cta { color: var(--cta-primary) !important; }
.text-cta-hover:hover { color: var(--cta-hover) !important; }

/* Background CTA */
.bg-cta { background-color: var(--cta-primary) !important; }
.bg-cta-hover:hover { background-color: var(--cta-hover) !important; }

/* Background CTA com opacidade */
.bg-cta-10 { background-color: rgba(255, 67, 3, 0.1) !important; }
.bg-cta-20 { background-color: rgba(255, 67, 3, 0.2) !important; }

/* Border CTA */
.border-cta { border-color: var(--cta-primary) !important; }

/* Gradiente CTA (para botões) */
.bg-cta-gradient {
    background: linear-gradient(135deg, var(--cta-primary) 0%, var(--cta-gradient-end) 100%) !important;
}

/* Botão CTA completo */
.btn-cta {
    background-color: var(--cta-primary);
    color: white;
    transition: background-color 0.2s ease;
}
.btn-cta:hover {
    background-color: var(--cta-hover);
}

/* Overlay Principal - Cobre toda a tela durante carregamento */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 21, 30, 0.98); /* Cor base do site TranspNet com alta opacidade */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999; /* Sempre no topo */
    transition: opacity 0.6s ease-out;
}

/* Estado de fade out - aplicado quando carregamento completa */
#preloader.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* Container do Spinner */
.preloader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

/* Spinner Circular Animado */
.spinner {
    width: 70px;
    height: 70px;
    border: 5px solid rgba(59, 130, 246, 0.2); /* Azul TranspNet - borda base */
    border-top-color: #3b82f6; /* Azul TranspNet - borda animada */
    border-right-color: var(--cta-primary); /* Laranja TranspNet - detalhe */
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

/* Animação de rotação do spinner */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Container da Progress Bar */
.progress-container {
    width: 320px;
    max-width: 90vw; /* Responsivo para mobile */
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Barra de Progresso */
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-blue) 0%, var(--primary-blue-light) 50%, var(--cta-primary) 100%);
    width: 0%;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 10px;
    position: relative;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.6);
}

/* Efeito de brilho na progress bar */
.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 100%);
    animation: shimmer 2s infinite;
    border-radius: 10px;
}

/* Animação de brilho */
@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Texto de Carregamento */
.loading-text {
    color: rgba(255, 255, 255, 0.9);
    margin-top: 10px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-align: center;
}

/* Porcentagem de progresso */
.loading-percentage {
    color: #60a5fa;
    font-weight: 600;
    font-size: 13px;
    margin-top: 8px;
}

/* Logo TranspNet (opcional) */
.preloader-logo {
    width: 120px;
    height: auto;
    margin-bottom: 20px;
    opacity: 0.9;
}

/* Responsividade Mobile */
@media (max-width: 768px) {
    .spinner {
        width: 60px;
        height: 60px;
        border-width: 4px;
    }

    .progress-container {
        width: 280px;
        height: 6px;
    }

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

    .loading-percentage {
        font-size: 12px;
    }
}

/* Responsividade Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .progress-container {
        width: 300px;
    }
}

/* Modo de contraste alto (acessibilidade) */
@media (prefers-contrast: high) {
    #preloader {
        background: rgba(0, 0, 0, 0.95);
    }

    .spinner {
        border-color: rgba(255, 255, 255, 0.3);
        border-top-color: #60a5fa;
    }

    .loading-text {
        color: white;
    }
}

/* Preferência de movimento reduzido (acessibilidade) */
@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation: spin 2s linear infinite; /* Rotação mais lenta */
    }

    .progress-bar::after {
        animation: none; /* Remove efeito shimmer */
    }

    #preloader.fade-out {
        transition: opacity 0.3s ease-out; /* Transição mais rápida */
    }
}
