/* Loading System - Rainify */

:root {
    --loading-primary: #3b82f6;
    --loading-bg: rgba(15, 23, 42, 0.95);
}

/* ==================== LOADING ROOT ==================== */
#loading-root {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    pointer-events: none;
}

/* ==================== SPINNER BÁSICO ==================== */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(59, 130, 246, 0.2);
    border-top-color: var(--loading-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-large {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(59, 130, 246, 0.2);
    border-top-color: var(--loading-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-small {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(59, 130, 246, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== DOTS ANIMADOS ==================== */
.loading-dots {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.loading-dots span {
    width: 10px;
    height: 10px;
    background: var(--loading-primary);
    border-radius: 50%;
    animation: dotPulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) {
    animation-delay: 0s;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==================== LOADING INLINE ==================== */
.loading-inline {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 15px;
}

.loading-message {
    color: #94a3b8;
    font-size: 0.9rem;
    font-weight: 500;
    margin: 0;
}

/* ==================== LOADING OVERLAY ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: all;
    z-index: 10000;
}

.loading-overlay.loading-overlay-show {
    opacity: 1;
}

.loading-overlay.loading-overlay-exit {
    opacity: 0;
}

.loading-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 40px;
    background: var(--loading-bg);
    backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.loading-overlay.loading-overlay-show .loading-overlay-content {
    transform: scale(1);
}

.loading-overlay-message {
    color: #f8fafc;
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    text-align: center;
}

/* ==================== BUTTON LOADING ==================== */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
    cursor: wait !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 20px;
    height: 20px;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Spinner dentro de botón (con texto) */
.btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

/* ==================== SKELETON SCREENS ==================== */
.skeleton {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 25%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 75%
    );
    background-size: 200% 100%;
    animation: skeletonLoading 1.5s ease-in-out infinite;
    border-radius: 8px;
}

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

/* Skeleton Variants */
.skeleton-text {
    height: 16px;
    width: 100%;
    margin-bottom: 10px;
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: 15px;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-image {
    width: 100%;
    height: 200px;
    border-radius: 12px;
    margin-bottom: 15px;
}

.skeleton-card {
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    margin-bottom: 15px;
}

.skeleton-list-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    margin-bottom: 10px;
}

/* ==================== PROGRESS BAR ==================== */
.progress-bar-container {
    margin: 20px 0;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--loading-primary), #2563eb);
    border-radius: 4px;
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: progressShine 2s ease-in-out infinite;
}

@keyframes progressShine {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.progress-message {
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 500;
    margin: 0;
    text-align: center;
}

/* ==================== PULSE EFFECT ==================== */
.loading-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ==================== SHIMMER EFFECT (Alternativa) ==================== */
.loading-shimmer {
    background: linear-gradient(
        -45deg,
        rgba(255, 255, 255, 0.05),
        rgba(255, 255, 255, 0.1),
        rgba(255, 255, 255, 0.05),
        rgba(255, 255, 255, 0.1)
    );
    background-size: 400% 400%;
    animation: shimmer 3s ease infinite;
}

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

/* ==================== RESPONSIVE ==================== */
@media (max-width: 640px) {
    .loading-overlay-content {
        padding: 30px;
        margin: 0 20px;
    }
    
    .spinner-large {
        width: 50px;
        height: 50px;
    }
    
    .loading-overlay-message {
        font-size: 0.9rem;
    }
}

/* ==================== UTILIDADES ==================== */
.loading-center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.loading-fullscreen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Disable durante loading */
.is-loading {
    pointer-events: none;
    opacity: 0.6;
}

.is-loading * {
    cursor: wait !important;
}


/* ==========================================
   LIGHT MODE ADJUSTMENTS - LOADING
   Copiar AL FINAL de loading.css
   ========================================== */

/* Loading overlay más claro */
body.light-mode .loading-overlay {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
}

/* Contenido del overlay */
body.light-mode .loading-overlay-content {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.15),
        0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Mensaje del loading */
body.light-mode .loading-overlay-message {
    color: var(--text-primary);
}

/* Spinner grande */
body.light-mode .spinner-large {
    border-color: rgba(59, 130, 246, 0.15);
    border-top-color: var(--loading-primary);
}

/* Spinner normal */
body.light-mode .spinner {
    border-color: rgba(59, 130, 246, 0.15);
    border-top-color: var(--loading-primary);
}

/* Spinner pequeño (dentro de botones) */
body.light-mode .spinner-small {
    border-color: rgba(255, 255, 255, 0.4);
    border-top-color: white;
}

/* Loading inline */
body.light-mode .loading-inline {
    /* Ya funciona con variables */
}

body.light-mode .loading-message {
    color: var(--text-secondary);
}

/* Dots animados */
body.light-mode .loading-dots span {
    background: var(--loading-primary);
}

/* Skeleton screens */
body.light-mode .skeleton {
    background: linear-gradient(
        90deg,
        rgba(0, 0, 0, 0.04) 25%,
        rgba(0, 0, 0, 0.08) 50%,
        rgba(0, 0, 0, 0.04) 75%
    );
}

body.light-mode .skeleton-card {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

body.light-mode .skeleton-list-item {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

/* Progress bar */
body.light-mode .progress-bar {
    background: rgba(0, 0, 0, 0.08);
}

body.light-mode .progress-bar-fill {
    background: linear-gradient(90deg, var(--loading-primary), #2563eb);
}

body.light-mode .progress-message {
    color: var(--text-secondary);
}

/* Button loading state */
body.light-mode .btn-loading::after {
    border-color: rgba(255, 255, 255, 0.4);
    border-top-color: white;
}

/* Shimmer effect */
body.light-mode .loading-shimmer {
    background: linear-gradient(
        -45deg,
        rgba(0, 0, 0, 0.03),
        rgba(0, 0, 0, 0.06),
        rgba(0, 0, 0, 0.03),
        rgba(0, 0, 0, 0.06)
    );
}