/* ==========================================================
   LOADERS
   SOSMedical Design System
========================================================== */

/*
|--------------------------------------------------------------------------
| Spinner base
|--------------------------------------------------------------------------
*/

.loader {
    display: inline-block;
    width: 40px;
    height: 40px;

    border: 3px solid rgba(0, 153, 216, 0.18);
    border-top-color: var(--secondary);
    border-radius: 50%;

    animation: loader-spin 0.75s linear infinite;
}

.loader--sm {
    width: 24px;
    height: 24px;
    border-width: 2px;
}

.loader--lg {
    width: 56px;
    height: 56px;
    border-width: 4px;
}

.loader--light {
    border-color: rgba(255, 255, 255, 0.28);
    border-top-color: var(--white);
}

.loader--success {
    border-color: rgba(0, 182, 122, 0.18);
    border-top-color: var(--success);
}

.loader--dark {
    border-color: rgba(11, 35, 65, 0.16);
    border-top-color: var(--primary);
}

@keyframes loader-spin {
    to {
        transform: rotate(360deg);
    }
}

/*
|--------------------------------------------------------------------------
| Loader wrapper
|--------------------------------------------------------------------------
*/

.loader-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 14px;

    width: 100%;
    min-height: 180px;
    padding: var(--space-4);

    text-align: center;
}

.loader-wrapper__text {
    color: var(--text-light);
    font-size: 14px;
}

/*
|--------------------------------------------------------------------------
| Inline loader
|--------------------------------------------------------------------------
*/

.loader-inline {
    display: inline-flex;
    align-items: center;
    gap: 10px;

    color: var(--text-light);
    font-size: 14px;
}

.loader-inline .loader {
    flex-shrink: 0;
}

/*
|--------------------------------------------------------------------------
| Page loader
|--------------------------------------------------------------------------
*/

.page-loader {
    position: fixed;
    z-index: 9999;
    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 18px;

    visibility: visible;
    background:
        radial-gradient(
            circle at center,
            rgba(0, 153, 216, 0.08),
            transparent 40%
        ),
        var(--white);

    opacity: 1;

    transition:
        opacity 0.45s ease,
        visibility 0.45s ease;
}

.page-loader.is-hidden {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.page-loader__logo {
    width: min(220px, 60vw);
    max-height: 80px;
    object-fit: contain;
}

.page-loader__text {
    color: var(--primary);
    font-family: var(--font-title);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/*
|--------------------------------------------------------------------------
| Medical pulse loader
|--------------------------------------------------------------------------
*/

.pulse-loader {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 64px;
    height: 64px;
}

.pulse-loader::before,
.pulse-loader::after {
    position: absolute;
    inset: 0;

    content: "";

    border: 2px solid var(--secondary);
    border-radius: 50%;

    animation: pulse-loader-ring 1.8s ease-out infinite;
}

.pulse-loader::after {
    animation-delay: 0.6s;
}

.pulse-loader__dot {
    width: 16px;
    height: 16px;

    background: var(--secondary);
    border-radius: 50%;

    box-shadow: 0 0 0 8px rgba(0, 153, 216, 0.1);

    animation: pulse-loader-dot 1.2s ease-in-out infinite;
}

@keyframes pulse-loader-ring {
    0% {
        opacity: 0.8;
        transform: scale(0.35);
    }

    100% {
        opacity: 0;
        transform: scale(1);
    }
}

@keyframes pulse-loader-dot {
    0%,
    100% {
        transform: scale(0.85);
    }

    50% {
        transform: scale(1);
    }
}

/*
|--------------------------------------------------------------------------
| Dots loader
|--------------------------------------------------------------------------
*/

.dots-loader {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.dots-loader__dot {
    width: 9px;
    height: 9px;

    background: var(--secondary);
    border-radius: 50%;

    animation: dots-loader-bounce 1.2s ease-in-out infinite;
}

.dots-loader__dot:nth-child(2) {
    animation-delay: 0.15s;
}

.dots-loader__dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes dots-loader-bounce {
    0%,
    80%,
    100% {
        opacity: 0.45;
        transform: translateY(0);
    }

    40% {
        opacity: 1;
        transform: translateY(-7px);
    }
}

/*
|--------------------------------------------------------------------------
| Progress bar
|--------------------------------------------------------------------------
*/

.progress {
    position: relative;
    width: 100%;
    height: 9px;
    overflow: hidden;

    background: #e8eef3;
    border-radius: 999px;
}

.progress__bar {
    width: 0;
    height: 100%;

    background:
        linear-gradient(
            90deg,
            var(--secondary),
            var(--success)
        );
    border-radius: inherit;

    transition: width 0.45s ease;
}

.progress--sm {
    height: 5px;
}

.progress--lg {
    height: 13px;
}

.progress--indeterminate .progress__bar {
    position: absolute;
    width: 40%;

    animation: progress-indeterminate 1.25s ease-in-out infinite;
}

@keyframes progress-indeterminate {
    0% {
        left: -40%;
    }

    100% {
        left: 100%;
    }
}

/*
|--------------------------------------------------------------------------
| Skeleton base
|--------------------------------------------------------------------------
*/

.skeleton {
    position: relative;
    overflow: hidden;

    background: #e9eff4;
    border-radius: var(--radius-sm);
}

.skeleton::after {
    position: absolute;
    inset: 0;

    content: "";

    background:
        linear-gradient(
            90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.72) 50%,
            transparent 100%
        );

    transform: translateX(-100%);

    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
    100% {
        transform: translateX(100%);
    }
}

/*
|--------------------------------------------------------------------------
| Skeleton shapes
|--------------------------------------------------------------------------
*/

.skeleton--text {
    width: 100%;
    height: 14px;
}

.skeleton--title {
    width: 70%;
    height: 24px;
}

.skeleton--image {
    width: 100%;
    min-height: 240px;
    border-radius: var(--radius-md);
}

.skeleton--circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.skeleton--button {
    width: 130px;
    height: 44px;
    border-radius: var(--radius-md);
}

/*
|--------------------------------------------------------------------------
| Skeleton card
|--------------------------------------------------------------------------
*/

.skeleton-card {
    overflow: hidden;

    background: var(--white);
    border: 1px solid rgba(11, 35, 65, 0.08);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.skeleton-card__media {
    min-height: 260px;
    border-radius: 0;
}

.skeleton-card__body {
    display: flex;
    flex-direction: column;
    gap: 14px;

    padding: 24px;
}

.skeleton-card__line {
    height: 13px;
}

.skeleton-card__line--short {
    width: 42%;
}

.skeleton-card__line--medium {
    width: 68%;
}

.skeleton-card__line--long {
    width: 100%;
}

/*
|--------------------------------------------------------------------------
| Loading overlay
|--------------------------------------------------------------------------
*/

.loading-overlay {
    position: absolute;
    z-index: 20;
    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;

    visibility: hidden;

    background: rgba(255, 255, 255, 0.84);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);

    opacity: 0;

    transition:
        opacity var(--transition),
        visibility var(--transition);
}

.loading-overlay.is-visible {
    visibility: visible;
    opacity: 1;
}

.loading-overlay__text {
    color: var(--primary);
    font-family: var(--font-title);
    font-size: 13px;
    font-weight: 600;
}

/*
|--------------------------------------------------------------------------
| Loading container
|--------------------------------------------------------------------------
*/

.is-loading-container {
    position: relative;
    min-height: 140px;
}

/*
|--------------------------------------------------------------------------
| Reduced motion
|--------------------------------------------------------------------------
*/

@media (prefers-reduced-motion: reduce) {
    .loader,
    .pulse-loader::before,
    .pulse-loader::after,
    .pulse-loader__dot,
    .dots-loader__dot,
    .progress--indeterminate .progress__bar,
    .skeleton::after {
        animation-duration: 2.5s;
    }

    .page-loader,
    .progress__bar,
    .loading-overlay {
        transition: none;
    }
}