/* ===== PRELOADER STYLES ===== */

/* Preloader principal para páginas */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease-out;
    backdrop-filter: blur(10px);
    opacity: 1;
}

/* Estado oculto del preloader */
#preloader.hidden {
    opacity: 0 !important;
    pointer-events: none;
}

#preloader[style*="opacity: 0"] {
    opacity: 0 !important;
    pointer-events: none;
}

body.dark-mode #preloader {
    background: linear-gradient(135deg, #232946 0%, #1a1f3a 100%);
}

/* Icono del preloader */
.preloader-icon {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    box-shadow: 
        0 0 0 0 rgba(238, 188, 29, 0.7),
        0 0 0 10px rgba(255, 255, 255, 0.1),
        0 0 0 20px rgba(238, 188, 29, 0.2),
        0 8px 32px rgba(35, 41, 70, 0.15);
    border: 3px solid #eebc1d;
    animation: preloaderPulse 2s infinite ease-in-out;
}

body.dark-mode .preloader-icon {
    background: #232946;
    border-color: #eebc1d;
    box-shadow: 
        0 0 0 0 rgba(238, 188, 29, 0.7),
        0 0 0 10px rgba(35, 41, 70, 0.3),
        0 0 0 20px rgba(238, 188, 29, 0.2),
        0 8px 32px rgba(0, 0, 0, 0.3);
    animation: preloaderPulseDarkMode 2s infinite ease-in-out;
}

/* Imagen dentro del preloader */
.preloader-icon img {
    width: 45px !important;
    height: 45px !important;
    border-radius: 50%;
    object-fit: cover;
    filter: drop-shadow(0 2px 8px rgba(238, 188, 29, 0.3));
    display: block !important;
    animation: preloaderRotate 3s linear infinite;
}

/* Animación de pulso del icono */
@keyframes preloaderPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 
            0 0 0 0 rgba(238, 188, 29, 0.7),
            0 0 0 10px rgba(255, 255, 255, 0.1),
            0 0 0 20px rgba(238, 188, 29, 0.2),
            0 8px 32px rgba(35, 41, 70, 0.15);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 
            0 0 0 20px rgba(238, 188, 29, 0),
            0 0 0 30px rgba(255, 255, 255, 0.05),
            0 0 0 40px rgba(238, 188, 29, 0),
            0 12px 40px rgba(35, 41, 70, 0.2);
    }
}

@keyframes preloaderPulseDarkMode {
    0%, 100% {
        transform: scale(1);
        box-shadow: 
            0 0 0 0 rgba(238, 188, 29, 0.7),
            0 0 0 10px rgba(35, 41, 70, 0.3),
            0 0 0 20px rgba(238, 188, 29, 0.2),
            0 8px 32px rgba(0, 0, 0, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 
            0 0 0 20px rgba(238, 188, 29, 0),
            0 0 0 30px rgba(35, 41, 70, 0.1),
            0 0 0 40px rgba(238, 188, 29, 0),
            0 12px 40px rgba(0, 0, 0, 0.4);
    }
}

@keyframes preloaderRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== LOADING SPINNERS ===== */

/* Spinner para elementos pequeños */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(238, 188, 29, 0.2);
    border-radius: 50%;
    border-top-color: #eebc1d;
    animation: spin 1s linear infinite;
    vertical-align: middle;
}

/* Spinner para botones */
.btn .loading-spinner {
    width: 16px;
    height: 16px;
    border-width: 2px;
    margin-right: 8px;
}

/* Spinner grande para contenido */
.loading-spinner-lg {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(238, 188, 29, 0.2);
    border-radius: 50%;
    border-top-color: #eebc1d;
    animation: spin 1.2s linear infinite;
}

/* Spinner de Bootstrap personalizado */
.spinner-border {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    vertical-align: -0.125em;
    border: 0.25em solid rgba(238, 188, 29, 0.25);
    border-right-color: #eebc1d;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.125em;
}

/* Animación de rotación */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== ESTADOS DE CARGA ===== */

/* Contenedor con estado de carga */
.loading-container {
    position: relative;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    backdrop-filter: blur(2px);
    z-index: 10;
}

body.dark-mode .loading-overlay {
    background: rgba(35, 41, 70, 0.9);
}

/* Texto de carga */
.loading-text {
    margin-left: 12px;
    color: #666;
    font-size: 0.9rem;
    font-weight: 500;
}

body.dark-mode .loading-text {
    color: #ccc;
}

/* ===== UTILIDADES ===== */

/* Ocultar elementos durante la carga */
.loading .content {
    opacity: 0.5;
    pointer-events: none;
}

/* Transiciones suaves */
.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 768px) {
    .preloader-icon {
        width: 70px;
        height: 70px;
    }
    
    .preloader-icon img {
        width: 35px;
        height: 35px;
    }
    
    .loading-spinner-lg {
        width: 32px;
        height: 32px;
        border-width: 3px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .preloader-icon,
    .loading-spinner,
    .loading-spinner-lg,
    .spinner-border {
        animation-duration: 2s;
    }
    
    .preloader-icon img {
        animation: none;
    }
}
