﻿/**
 * ProgressiveDocs Loader System CSS
 * Styles for page loader and operational loaders
 */

/* Page Loader Styles */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.page-loader.hide {
    opacity: 0;
    visibility: hidden;
}

.page-loader-content {
    text-align: center;
    color: white;
}

.page-loader-logo {
    position: relative;
    margin-bottom: 20px;
}

.progressivedocs-logo {
    width: 320px;
    height: auto;
    margin-bottom: 10px;
}

.heartbeat-animation {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
}

.pulse-wave {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.pulse-wave.wave-1 {
    animation-delay: 0s;
}

.pulse-wave.wave-2 {
    animation-delay: 0.6s;
}

.pulse-wave.wave-3 {
    animation-delay: 1.2s;
}

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

.page-loader-text {
    font-size: 18px;
    font-weight: 300;
    letter-spacing: 1px;
    animation: fade 2s infinite;
}

@keyframes fade {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Operational Loader Styles */
.operational-loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: inherit;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Fullscreen variant for body-level loaders: center in current viewport */
.operational-loader-overlay.fullscreen {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.operational-loader-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.operational-loader-overlay.light {
    background: rgba(255, 255, 255, 0.9);
}

.operational-loader-overlay.dark {
    background: rgba(0, 0, 0, 0.7);
}

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

/* Operational Pulse Loader Animation */
.operational-pulse-loader {
    position: relative;
    display: inline-block;
}

.operational-pulse-loader::before {
    content: '';
    display: block;
    border-radius: 50%;
    border: 2px solid #3b82f6;
    border-top-color: transparent;
    animation: operational-spin 0.8s linear infinite;
}

/* Size variants for operational loader */
.operational-pulse-loader.small::before {
    width: 1em;   /* scale with font to match button line height */
    height: 1em;
    min-width: 12px; /* guard small buttons */
    min-height: 12px;
    border-width: 2px;
}

.operational-pulse-loader.normal::before {
    width: 24px;
    height: 24px;
    border-width: 3px;
}

.operational-pulse-loader.large::before {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

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

/* Operational Loading Text */
.operational-loading-text {
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    text-align: center;
    white-space: nowrap;
}

.operational-loader-overlay.dark .operational-loading-text {
    color: #d1d5db;
}

/* Button Loading States */
.btn-loading {
    position: relative;
    pointer-events: none;
    cursor: not-allowed !important;
    opacity: 0.8;
}

.btn-loading .operational-pulse-loader {
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}

.btn-loading .operational-pulse-loader::before {
    border-color: currentColor;
    border-top-color: transparent;
    opacity: 0.7;
}

.btn-loading .operational-loading-text {
    color: inherit;
    opacity: 0.9;
}

/* New unique class for programmatic button loader to avoid conflicts */
.btn-processing {
    position: relative;
    pointer-events: none;
    cursor: not-allowed !important;
    opacity: 0.9;
}

.btn-processing .operational-pulse-loader {
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}

.btn-processing .operational-pulse-loader::before {
    border-color: currentColor;
    border-top-color: transparent;
    opacity: 0.85;
}

/* Ensure tight inline line-heights inside processing button to avoid height growth */
.btn-processing .operational-pulse-loader,
.btn-processing .operational-loading-text {
    line-height: 1;
    margin: 0; /* avoid vertical expansion */
}

.btn-processing .operational-loading-text {
    color: inherit;
    opacity: 1;
}

/* Form Loading States */
form.loading {
    position: relative;
}

form.loading input,
form.loading textarea,
form.loading select,
form.loading button {
    pointer-events: none;
    opacity: 0.6;
}

/* Responsive Design */
@media (max-width: 768px) {
    .page-loader-text {
        font-size: 16px;
    }
    
    .progressivedocs-logo {
        width: 240px;
    }
    
    .operational-loading-text {
        font-size: 11px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .operational-loader-overlay.light {
        background: rgba(255, 255, 255, 0.95);
    }
    
    .operational-loader-overlay.dark {
        background: rgba(0, 0, 0, 0.85);
    }
    
    .operational-pulse-loader::before {
        border-width: 3px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .pulse-wave {
        animation: none;
    }
    
    .page-loader-text {
        animation: none;
        opacity: 1;
    }
    
    .operational-pulse-loader::before {
        animation: operational-spin 2s linear infinite;
    }
}

/* Focus indicators for accessibility */
.operational-loader-overlay:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Dropdown Loader Styles */
.dropdown-loader {
    position: absolute;
    top: 50%;
    right: 28px;
    transform: translateY(-50%);
    z-index: 10;
    pointer-events: none;
}

.dropdown-loader::before {
    content: '';
    display: block;
    width: 16px;
    height: 16px;
    border: 2px solid #d1d5db;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: dropdown-spin 0.8s linear infinite;
}

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

.dropdown-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

.dropdown-wrapper.loading {
    pointer-events: none;
}

.dropdown-wrapper.loading select {
    opacity: 0.7;
    cursor: not-allowed;
}

.dropdown-wrapper.loading .dropdown-loader {
    display: block;
}

/* Hide dropdown arrow when loading */
.dropdown-wrapper.loading::after {
    display: none !important;
}

.appointment-popup-select-wrapper.loading::after {
    display: none !important;
}

/* Mini loader for inline use */
.mini-loader {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 1px solid #d1d5db;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: dropdown-spin 0.8s linear infinite;
    vertical-align: middle;
    margin: 0 4px;
}

/* Print styles */
@media print {
    .page-loader,
    .operational-loader-overlay,
    .dropdown-loader,
    .mini-loader {
        display: none !important;
    }
}
