/**
 * ============================================================================
 * KAPITALE PAGE LOADER STYLES
 * ============================================================================
 * 
 * Beautiful loading animations for smooth page transitions.
 * Matches Kapitale branding with green color (#2CCE80).
 * 
 * LOADER OPTIONS INCLUDED:
 * 1. Spinning logo (default)
 * 2. Progress bar
 * 3. Pulsing logo
 * 4. Dots animation
 * 
 * Choose your preferred animation by uncommenting the relevant sections.
 * 
 * ============================================================================
 */

/* ========================================================================== */
/* BASE LOADER OVERLAY */
/* ========================================================================== */

#page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #FFFFFF;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.6s ease;
}

/* Fade out animation */
#page-loader.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* ========================================================================== */
/* PAGE CONTENT TRANSITIONS */
/* ========================================================================== */

#page-content {
    opacity: 1;
    transition: opacity 0.8s ease;
}

/* Hidden state (during loading) */
#page-content.page-hidden {
    opacity: 0;
}

/* Visible state (after loading) */
#page-content.page-visible {
    opacity: 1;
}

/* Fade out when navigating away */
#page-content.page-fade-out {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* ========================================================================== */
/* LOADER CONTAINER */
/* ========================================================================== */

.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

/* ========================================================================== */
/* OPTION 1: SPINNING LOGO (DEFAULT) */
/* ========================================================================== */

.loader-logo {
    width: 120px;
    height: auto;
    animation: logoSpin 2s ease-in-out infinite;
}

@keyframes logoSpin {
    0% {
        transform: rotate(0deg);
        opacity: 0.6;
    }
    50% {
        transform: rotate(180deg);
        opacity: 1;
    }
    100% {
        transform: rotate(360deg);
        opacity: 0.6;
    }
}

/* ========================================================================== */
/* OPTION 2: SPINNING CIRCLE (If no logo) */
/* ========================================================================== */

.loader-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(44, 206, 128, 0.2);
    border-top-color: #2CCE80;
    border-radius: 50%;
    animation: spinnerRotate 1s linear infinite;
}

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

/* ========================================================================== */
/* OPTION 3: PULSING LOGO */
/* ========================================================================== */

.loader-logo-pulse {
    width: 120px;
    height: auto;
    animation: logoPulse 1.5s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.7;
    }
}

/* ========================================================================== */
/* OPTION 4: ANIMATED DOTS */
/* ========================================================================== */

.loader-dots {
    display: flex;
    gap: 12px;
}

.loader-dot {
    width: 12px;
    height: 12px;
    background: #2CCE80;
    border-radius: 50%;
    animation: dotBounce 1.4s ease-in-out infinite;
}

.loader-dot:nth-child(1) {
    animation-delay: 0s;
}

.loader-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loader-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotBounce {
    0%, 80%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.5;
    }
    40% {
        transform: translateY(-20px) scale(1.2);
        opacity: 1;
    }
}

/* ========================================================================== */
/* OPTION 5: PROGRESS BAR */
/* ========================================================================== */

.loader-progress-bar {
    width: 200px;
    height: 4px;
    background: rgba(44, 206, 128, 0.2);
    border-radius: 2px;
    overflow: hidden;
}

.loader-progress-fill {
    height: 100%;
    width: 0%;
    background: #2CCE80;
    transition: width 0.3s ease;
    border-radius: 2px;
}

/* Animated progress bar (if not using JS progress) */
.loader-progress-fill-animated {
    height: 100%;
    width: 100%;
    background: #2CCE80;
    border-radius: 2px;
    animation: progressFill 2s ease-in-out infinite;
    transform-origin: left;
}

@keyframes progressFill {
    0% {
        transform: scaleX(0);
    }
    50% {
        transform: scaleX(1);
    }
    100% {
        transform: scaleX(0);
    }
}

/* ========================================================================== */
/* LOADING TEXT */
/* ========================================================================== */

.loader-text {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 14px;
    color: #828282;
    letter-spacing: 0.5px;
    animation: textFade 2s ease-in-out infinite;
}

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

/* ========================================================================== */
/* CIRCULAR PROGRESS (Advanced) */
/* ========================================================================== */

.loader-circular {
    width: 80px;
    height: 80px;
    position: relative;
}

.loader-circular-svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.loader-circular-bg {
    fill: none;
    stroke: rgba(44, 206, 128, 0.1);
    stroke-width: 4;
}

.loader-circular-progress {
    fill: none;
    stroke: #2CCE80;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 251.2;
    stroke-dashoffset: 251.2;
    animation: circularProgress 2s ease-in-out infinite;
}

@keyframes circularProgress {
    0% {
        stroke-dashoffset: 251.2;
    }
    50% {
        stroke-dashoffset: 0;
    }
    100% {
        stroke-dashoffset: -251.2;
    }
}

/* ========================================================================== */
/* SMOOTH FADE VARIANTS */
/* ========================================================================== */

/* Slide up animation */
@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.slide-up {
    animation: slideUp 0.6s ease forwards;
}

/* Scale in animation */
@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.scale-in {
    animation: scaleIn 0.5s ease forwards;
}

/* ========================================================================== */
/* RESPONSIVE ADJUSTMENTS */
/* ========================================================================== */

@media (max-width: 768px) {
    .loader-logo,
    .loader-logo-pulse {
        width: 100px;
    }
    
    .loader-spinner {
        width: 50px;
        height: 50px;
    }
    
    .loader-progress-bar {
        width: 160px;
    }
    
    .loader-text {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .loader-logo,
    .loader-logo-pulse {
        width: 80px;
    }
    
    .loader-spinner {
        width: 40px;
        height: 40px;
    }
    
    .loader-progress-bar {
        width: 120px;
    }
    
    .loader-text {
        font-size: 12px;
    }
    
    .loader-container {
        gap: 24px;
    }
}

/* ========================================================================== */
/* ACCESSIBILITY */
/* ========================================================================== */

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    #page-loader,
    #page-content,
    .loader-logo,
    .loader-spinner,
    .loader-logo-pulse,
    .loader-dot,
    .loader-progress-fill,
    .loader-text,
    .loader-circular-progress {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

