/* Site Wide Loader Styles */
.sw-loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    z-index: 999999;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    transition: opacity 0.5s ease;
}

.sw-loader-overlay.fade-out {
    opacity: 0 !important;
    pointer-events: none;
}

.sw-loader-text {
    margin-top: 20px;
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Animation speed control */
.sw-loader-animation {
    animation-duration: calc(1s / var(--sw-animation-speed, 1)) !important;
}

/* Spinner Animation */
.sw-loader-animation.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top: 3px solid currentColor;
    animation: sw-loader-spin 1s linear infinite;
}

@keyframes sw-loader-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Dots Animation */
.sw-loader-animation.dots {
    display: inline-block;
    position: relative;
    width: 64px;
    height: 64px;
}

.sw-loader-animation.dots div {
    position: absolute;
    top: 27px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: currentColor;
    animation-timing-function: cubic-bezier(0, 1, 1, 0);
}

.sw-loader-animation.dots div:nth-child(1) {
    left: 6px;
    animation: sw-loader-dots1 0.6s infinite;
}

.sw-loader-animation.dots div:nth-child(2) {
    left: 6px;
    animation: sw-loader-dots2 0.6s infinite;
}

.sw-loader-animation.dots div:nth-child(3) {
    left: 26px;
    animation: sw-loader-dots2 0.6s infinite;
}

.sw-loader-animation.dots div:nth-child(4) {
    left: 45px;
    animation: sw-loader-dots3 0.6s infinite;
}

@keyframes sw-loader-dots1 {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

@keyframes sw-loader-dots3 {
    0% { transform: scale(1); }
    100% { transform: scale(0); }
}

@keyframes sw-loader-dots2 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(19px, 0); }
}

/* Bars Animation */
.sw-loader-animation.bars {
    display: inline-block;
    position: relative;
    width: 64px;
    height: 64px;
}

.sw-loader-animation.bars div {
    display: inline-block;
    position: absolute;
    width: 13px;
    background: currentColor;
    animation: sw-loader-bars 1.2s cubic-bezier(0, 0.5, 0.5, 1) infinite;
}

.sw-loader-animation.bars div:nth-child(1) {
    left: 6px;
    animation-delay: -0.24s;
}

.sw-loader-animation.bars div:nth-child(2) {
    left: 26px;
    animation-delay: -0.12s;
}

.sw-loader-animation.bars div:nth-child(3) {
    left: 45px;
    animation-delay: 0;
}

@keyframes sw-loader-bars {
    0% { top: 6px; height: 51px; }
    50%, 100% { top: 19px; height: 26px; }
}

/* Pulse Animation */
.sw-loader-animation.pulse {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: currentColor;
    animation: sw-loader-pulse 1.2s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}

@keyframes sw-loader-pulse {
    0% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.8); opacity: 0.5; }
}

/* Circular Animation */
.sw-loader-animation.circular {
    width: 50px;
    height: 50px;
    position: relative;
}

.sw-loader-animation.circular div {
    box-sizing: border-box;
    display: block;
    position: absolute;
    width: 40px;
    height: 40px;
    margin: 5px;
    border: 5px solid currentColor;
    border-radius: 50%;
    animation: sw-loader-circular 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    border-color: currentColor transparent transparent transparent;
}

.sw-loader-animation.circular div:nth-child(1) {
    animation-delay: -0.45s;
}

.sw-loader-animation.circular div:nth-child(2) {
    animation-delay: -0.3s;
}

.sw-loader-animation.circular div:nth-child(3) {
    animation-delay: -0.15s;
}

@keyframes sw-loader-circular {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Percentage Animation */
.sw-loader-animation.percentage {
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: currentColor;
    font-size: 14px;
}

.sw-loader-animation.percentage::after {
    content: '0%';
    animation: sw-loader-percentage 3s linear infinite;
}

@keyframes sw-loader-percentage {
    0% { content: '0%'; }
    10% { content: '10%'; }
    20% { content: '20%'; }
    30% { content: '30%'; }
    40% { content: '40%'; }
    50% { content: '50%'; }
    60% { content: '60%'; }
    70% { content: '70%'; }
    80% { content: '80%'; }
    90% { content: '90%'; }
    100% { content: '100%'; }
}

/* Ripple Animation */
.sw-loader-animation.ripple {
    width: 60px;
    height: 60px;
    position: relative;
}

.sw-loader-animation.ripple div {
    position: absolute;
    border: 3px solid currentColor;
    opacity: 1;
    border-radius: 50%;
    animation: sw-loader-ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}

.sw-loader-animation.ripple div:nth-child(2) {
    animation-delay: -0.5s;
}

@keyframes sw-loader-ripple {
    0% {
        top: 27px;
        left: 27px;
        width: 0;
        height: 0;
        opacity: 0;
    }
    4.9% {
        top: 27px;
        left: 27px;
        width: 0;
        height: 0;
        opacity: 0;
    }
    5% {
        top: 27px;
        left: 27px;
        width: 0;
        height: 0;
        opacity: 1;
    }
    100% {
        top: 0px;
        left: 0px;
        width: 54px;
        height: 54px;
        opacity: 0;
    }
}

/* Flip Animation */
.sw-loader-animation.flip {
    width: 50px;
    height: 50px;
    perspective: 90px;
}

.sw-loader-animation.flip::before {
    content: '';
    width: 100%;
    height: 100%;
    background: currentColor;
    animation: sw-loader-flip 2.4s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}

@keyframes sw-loader-flip {
    0%, 100% { transform: rotateY(0deg); }
    50% { transform: rotateY(180deg); }
}

/* Cube Animation - Simplified version */
.sw-loader-animation.cube {
    width: 30px;
    height: 30px;
    position: relative;
    transform-style: preserve-3d;
    animation: sw-loader-cube-rotate 2s infinite linear;
}

.sw-loader-animation.cube > div {
    position: absolute;
    width: 100%;
    height: 100%;
    background: currentColor;
    opacity: 0.8;
}

.sw-loader-animation.cube .front {
    transform: translateZ(15px);
}

.sw-loader-animation.cube .back {
    transform: translateZ(-15px);
}

.sw-loader-animation.cube .right {
    transform: rotateY(90deg) translateZ(15px);
}

.sw-loader-animation.cube .left {
    transform: rotateY(-90deg) translateZ(15px);
}

.sw-loader-animation.cube .top {
    transform: rotateX(90deg) translateZ(15px);
}

.sw-loader-animation.cube .bottom {
    transform: rotateX(-90deg) translateZ(15px);
}

@keyframes sw-loader-cube-rotate {
    0% { transform: rotateX(0) rotateY(0) rotateZ(0); }
    100% { transform: rotateX(360deg) rotateY(360deg) rotateZ(360deg); }
}

/* Orbit Animation */
.sw-loader-animation.orbit {
    width: 60px;
    height: 60px;
    position: relative;
}

.sw-loader-animation.orbit div {
    position: absolute;
    width: 48px;
    height: 48px;
    top: 6px;
    left: 6px;
    border-radius: 50%;
    border: 3px solid currentColor;
    border-color: currentColor transparent transparent transparent;
    animation: sw-loader-orbit 1.5s linear infinite;
}

.sw-loader-animation.orbit div:nth-child(1) { animation-delay: -0.45s; }
.sw-loader-animation.orbit div:nth-child(2) { animation-delay: -0.3s; }
.sw-loader-animation.orbit div:nth-child(3) { animation-delay: -0.15s; }

@keyframes sw-loader-orbit {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Heartbeat Animation */
.sw-loader-animation.heartbeat {
    width: 50px;
    height: 50px;
    position: relative;
    transform: rotate(45deg);
    animation: sw-loader-heartbeat 1.2s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
}

.sw-loader-animation.heartbeat:before,
.sw-loader-animation.heartbeat:after {
    content: "";
    position: absolute;
    display: block;
    width: 25px;
    height: 25px;
    background: currentColor;
}

.sw-loader-animation.heartbeat:before {
    top: -12px;
    left: 0;
    border-radius: 50% 0 0 50%;
}

.sw-loader-animation.heartbeat:after {
    top: 0;
    left: -12px;
    border-radius: 50% 50% 0 0;
}

@keyframes sw-loader-heartbeat {
    0% { transform: scale(0.95) rotate(45deg); }
    5% { transform: scale(1.1) rotate(45deg); }
    39% { transform: scale(0.85) rotate(45deg); }
    45% { transform: scale(1) rotate(45deg); }
    60% { transform: scale(0.95) rotate(45deg); }
    100% { transform: scale(0.9) rotate(45deg); }
}

/* Clock Animation */
.sw-loader-animation.clock {
    width: 50px;
    height: 50px;
    border: 3px solid currentColor;
    border-radius: 50%;
    position: relative;
    animation: sw-loader-clock 1.2s infinite linear;
}

.sw-loader-animation.clock:after {
    content: "";
    position: absolute;
    background: currentColor;
    width: 3px;
    height: 24px;
    left: 50%;
    top: 50%;
    transform: translateX(-50%);
    transform-origin: top center;
    animation: sw-loader-clock-hand 12s infinite linear;
}

@keyframes sw-loader-clock {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes sw-loader-clock-hand {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Animated ellipsis for loading text */
.animated-ellipsis::after {
    content: '...';
    animation: sw-loader-ellipsis 1.5s infinite;
    display: inline-block;
    width: 1em;
    text-align: left;
}

@keyframes sw-loader-ellipsis {
    0% { content: '.'; }
    33% { content: '..'; }
    66% { content: '...'; }
    100% { content: '...'; }
}

/* Specific styles for WS Form pages */
.sw-loader-wsf-page .sw-loader-overlay {
    z-index: 1000000; /* Higher z-index to overlay WS Form iframes */
}

.sw-loader-wsf-page .sw-loader-animation {
    transform: scale(1.5); /* Larger animation for WS Form pages */
}

.sw-loader-wsf-page .sw-loader-text {
    font-size: 18px !important; /* Larger text for WS Form pages */
    font-weight: 500;
}

/* Ensure loader is visible over WS Form iframes */
body.ws-form-page {
    position: relative;
}

body.ws-form-page .sw-loader-overlay {
    z-index: 1000001 !important;
}

/* Force larger size for WS Form pages specifically */
body.ws-form-page .sw-loader-animation {
    transform: scale(1.8) !important;
}

body.ws-form-page .sw-loader-text {
    font-size: 20px !important;
    font-weight: 600;
}