/*
 * Modern Loader System for dokhub Healthcare Application
 * Inspired by modern SaaS applications with healthcare theme
 */

:root {
    --loader-primary: #0066cc;
    --loader-secondary: #14b8a6;
    --loader-white: #ffffff;
    --loader-overlay-bg: rgba(255, 255, 255, 0.95);
    --loader-backdrop: rgba(0, 0, 0, 0.1);
    --loader-shadow: 0 10px 25px -5px rgba(0, 102, 204, 0.2);
    --loader-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== GLOBAL LOADER OVERLAY - Login Style ===== */
.global-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.global-loader.show {
    display: flex;
    opacity: 1;
}

.global-loader.hide {
    opacity: 0;
}

/* Progressive enhancement fallback */
.no-backdrop-support .global-loader {
    background: rgba(255, 255, 255, 0.95);
}

/* ===== PULSE LOADER (Login Style) ===== */
.pulse-loader {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--loader-primary);
    animation: pulse 1.5s ease-in-out infinite;
    box-shadow: var(--loader-shadow);
}

@keyframes pulse {
    0% { 
        transform: scale(0.8); 
        opacity: 1; 
    }
    100% { 
        transform: scale(1.2); 
        opacity: 0; 
    }
}

/* ===== MEDICAL CROSS LOADER ===== */
.medical-loader {
    width: 50px;
    height: 50px;
    position: relative;
    display: inline-block;
}

.medical-loader::before,
.medical-loader::after {
    content: '';
    position: absolute;
    background: var(--loader-primary);
    border-radius: 4px;
    animation: medical-cross 1.2s ease-in-out infinite;
}

.medical-loader::before {
    width: 6px;
    height: 50px;
    left: 22px;
    top: 0;
}

.medical-loader::after {
    width: 50px;
    height: 6px;
    left: 0;
    top: 22px;
    animation-delay: 0.4s;
}

@keyframes medical-cross {
    0%, 80%, 100% {
        opacity: 0;
        transform: scale(0.6);
    }
    40% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== DNA HELIX LOADER ===== */
.dna-loader {
    width: 60px;
    height: 60px;
    position: relative;
    display: inline-block;
}

.dna-loader::before,
.dna-loader::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--loader-primary);
    animation: dna-helix 1.5s ease-in-out infinite;
}

.dna-loader::before {
    left: 0;
    animation-delay: 0s;
}

.dna-loader::after {
    right: 0;
    background: var(--loader-secondary);
    animation-delay: 0.75s;
}

@keyframes dna-helix {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(15px) rotate(90deg);
    }
    50% {
        transform: translateY(30px) rotate(180deg);
    }
    75% {
        transform: translateY(45px) rotate(270deg);
    }
}

/* ===== HEARTBEAT LOADER ===== */
.heartbeat-loader {
    width: 50px;
    height: 50px;
    position: relative;
    display: inline-block;
}

.heartbeat-loader::before {
    content: '♥';
    position: absolute;
    font-size: 30px;
    color: var(--loader-primary);
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    animation: heartbeat 1.2s ease-in-out infinite;
}

@keyframes heartbeat {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    14% {
        transform: translate(-50%, -50%) scale(1.3);
    }
    28% {
        transform: translate(-50%, -50%) scale(1);
    }
    42% {
        transform: translate(-50%, -50%) scale(1.3);
    }
    70% {
        transform: translate(-50%, -50%) scale(1);
    }
}

/* ===== SPINNING DOTS LOADER ===== */
.dots-loader {
    display: inline-block;
    position: relative;
    width: 80px;
    height: 80px;
}

.dots-loader div {
    position: absolute;
    top: 33px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--loader-primary);
    animation-timing-function: cubic-bezier(0, 1, 1, 0);
}

.dots-loader div:nth-child(1) {
    left: 8px;
    animation: dots1 0.6s infinite;
}

.dots-loader div:nth-child(2) {
    left: 8px;
    animation: dots2 0.6s infinite;
}

.dots-loader div:nth-child(3) {
    left: 32px;
    animation: dots2 0.6s infinite;
}

.dots-loader div:nth-child(4) {
    left: 56px;
    animation: dots3 0.6s infinite;
}

@keyframes dots1 {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

@keyframes dots3 {
    0% { transform: scale(1); }
    100% { transform: scale(0); }
}

@keyframes dots2 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(24px, 0); }
}

/* ===== BUTTON LOADERS ===== */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

.btn-loading .btn-text {
    opacity: 0.5;
}

.btn-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: btn-spin 1s linear infinite;
}

@keyframes btn-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== INLINE LOADERS ===== */
.inline-loader {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--loader-backdrop);
    border-top: 2px solid var(--loader-primary);
    border-radius: 50%;
    animation: inline-spin 1s linear infinite;
    vertical-align: middle;
    margin: 0 8px;
}

@keyframes inline-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== CARD/SECTION LOADERS ===== */
.section-loading {
    position: relative;
    pointer-events: none;
}

.section-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--loader-overlay-bg);
    backdrop-filter: blur(2px);
    z-index: 10;
    border-radius: inherit;
}

.section-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid var(--loader-backdrop);
    border-top: 3px solid var(--loader-primary);
    border-radius: 50%;
    animation: section-spin 1s linear infinite;
    z-index: 11;
}

@keyframes section-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== SKELETON LOADERS ===== */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-text:last-child {
    width: 80%;
}

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

.skeleton-card {
    height: 200px;
    border-radius: 8px;
}

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

/* ===== LOADING MESSAGES - Login Style ===== */
.loader-message {
    margin-top: 20px;
    font-weight: 500;
    color: var(--loader-primary);
    font-size: 16px;
    text-align: center;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Remove the blinking animation for better readability */

/* ===== PAGE TRANSITION LOADER ===== */
.page-transition {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--loader-primary), var(--loader-secondary));
    transform: translateX(-100%);
    animation: page-load 2s ease-in-out;
    z-index: 9999;
}

@keyframes page-load {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(0%); }
    100% { transform: translateX(100%); }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .pulse-loader {
        width: 50px;
        height: 50px;
    }
    
    .loader-message {
        font-size: 14px;
    }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    .pulse-loader,
    .medical-loader::before,
    .medical-loader::after,
    .dna-loader::before,
    .dna-loader::after,
    .heartbeat-loader::before,
    .dots-loader div,
    .inline-loader,
    .section-loading::after,
    .skeleton {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* ===== HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
    :root {
        --loader-primary: #0000ff;
        --loader-secondary: #008000;
        --loader-overlay-bg: rgba(255, 255, 255, 0.98);
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .global-loader,
    .pulse-loader,
    .medical-loader,
    .dna-loader,
    .heartbeat-loader,
    .dots-loader,
    .inline-loader {
        display: none !important;
    }
}