/* Loading Effects CSS - Đơn giản và tương thích */

/* Loading Overlay cho Modal */
.modal-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(3px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    margin: 0;
    padding: 0;
}

.modal-loading-overlay.show {
    display: flex !important;
    animation: fadeIn 0.3s ease-in-out;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Loading Content - Hình tròn đẹp mắt */
.modal-loading-content {
    text-align: center;
    color: #333;
    max-width: 320px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 20px;
    padding: 40px 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15), 
                0 10px 20px rgba(0, 0, 0, 0.1),
                inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

/* Hiệu ứng ánh sáng cho loading content */
.modal-loading-content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shimmer 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes shimmer {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

/* Loading Spinner - Đẹp mắt hơn */
.modal-loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(0, 123, 255, 0.1);
    border-top: 4px solid #007bff;
    border-right: 4px solid #0056b3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 25px;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 123, 255, 0.3);
}

/* Hiệu ứng pulse cho spinner */
.modal-loading-spinner::after {
    content: '';
    position: absolute;
    top: -8px;
    left: -8px;
    right: -8px;
    bottom: -8px;
    border: 2px solid rgba(0, 123, 255, 0.2);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0% { transform: scale(0.8); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.5; }
    100% { transform: scale(0.8); opacity: 1; }
}

/* Loading Title - Đẹp mắt hơn */
.modal-loading-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #007bff;
    text-shadow: 0 1px 2px rgba(0, 123, 255, 0.1);
    letter-spacing: 0.5px;
}

/* Loading Message - Đẹp mắt hơn */
.modal-loading-message {
    font-size: 15px;
    color: #6c757d;
    margin-bottom: 20px;
    line-height: 1.5;
    font-weight: 500;
}

/* Progress Bar - Đơn giản và mượt mà */
.modal-loading-progress {
    width: 220px;
    height: 6px;
    background: linear-gradient(90deg, #e9ecef, #f8f9fa, #e9ecef);
    border-radius: 10px;
    overflow: hidden;
    margin: 0 auto;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.modal-loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #007bff, #0056b3, #007bff, #28a745);
    background-size: 300% 100%;
    animation: progressMove 2s ease-in-out infinite;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 123, 255, 0.5);
}

/* Dots Animation - Nháy thay phiên đẹp mắt */
.modal-loading-dots {
    display: inline-block;
    position: relative;
    width: 90px;
    height: 20px;
    margin-top: 15px;
}

.modal-loading-dots div {
    position: absolute;
    top: 50%;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007bff, #0056b3);
    transform: translateY(-50%);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
    opacity: 0.3;
    animation: dotPulse 1.4s infinite ease-in-out;
}

.modal-loading-dots div:nth-child(1) {
    left: 8px;
    animation-delay: 0s;
}

.modal-loading-dots div:nth-child(2) {
    left: 38px;
    animation-delay: 0.2s;
}

.modal-loading-dots div:nth-child(3) {
    left: 68px;
    animation-delay: 0.4s;
}

.modal-loading-dots div:nth-child(4) {
    left: 98px;
    animation-delay: 0.6s;
}

@keyframes dotPulse {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: translateY(-50%) scale(0.8);
    }
    40% {
        opacity: 1;
        transform: translateY(-50%) scale(1.2);
        box-shadow: 0 4px 12px rgba(0, 123, 255, 0.6);
    }
}

/* Success State - Đẹp mắt hơn */
.modal-loading-success .modal-loading-spinner {
    border: 4px solid rgba(40, 167, 69, 0.1);
    border-top: 4px solid #28a745;
    border-right: 4px solid #1e7e34;
    animation: none;
    box-shadow: 0 0 20px rgba(40, 167, 69, 0.4);
}

.modal-loading-success .modal-loading-spinner::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 36px;
    font-weight: 900;
    color: #28a745;
    text-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-loading-success .modal-loading-title {
    color: #28a745;
    text-shadow: 0 1px 2px rgba(40, 167, 69, 0.2);
}

/* Error State - Đẹp mắt hơn */
.modal-loading-error .modal-loading-spinner {
    border: 4px solid rgba(220, 53, 69, 0.1);
    border-top: 4px solid #dc3545;
    border-right: 4px solid #c82333;
    animation: none;
    box-shadow: 0 0 20px rgba(220, 53, 69, 0.4);
}

.modal-loading-error .modal-loading-spinner::after {
    content: '✕';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 36px;
    font-weight: 900;
    color: #dc3545;
    text-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-loading-error .modal-loading-title {
    color: #dc3545;
    text-shadow: 0 1px 2px rgba(220, 53, 69, 0.2);
}

/* Button Loading State */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading .btn-text {
    opacity: 0;
}

.btn-loading .btn-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Modal Body Loading State */
.modal-body-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

/* Animations */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes progressMove {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Animation cũ đã được thay thế bằng dotPulse */

/* Modal Dialog Support - Không cần thiết nữa vì sử dụng position: fixed */

/* Hiệu ứng hover cho loading content */
.modal-loading-content:hover {
    transform: translateY(-2px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2), 
                0 15px 30px rgba(0, 0, 0, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.8);
    transition: all 0.3s ease;
}

/* Hiệu ứng bounce khi hiển thị */
.modal-loading-overlay.show .modal-loading-content {
    animation: bounceIn 0.6s ease-out;
}

@keyframes bounceIn {
    0% { 
        transform: scale(0.3) translateY(-50px);
        opacity: 0;
    }
    50% { 
        transform: scale(1.05) translateY(0);
        opacity: 0.8;
    }
    70% { 
        transform: scale(0.95) translateY(0);
        opacity: 1;
    }
    100% { 
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* Hiệu ứng glow cho spinner */
.modal-loading-spinner {
    animation: spin 1s linear infinite, glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { box-shadow: 0 0 20px rgba(0, 123, 255, 0.3); }
    to { box-shadow: 0 0 30px rgba(0, 123, 255, 0.6), 0 0 40px rgba(0, 123, 255, 0.3); }
}

/* Responsive */
@media (max-width: 576px) {
    .modal-loading-content {
        max-width: 280px;
        padding: 30px 20px;
    }
    
    .modal-loading-spinner {
        width: 50px;
        height: 50px;
    }
    
    .modal-loading-title {
        font-size: 18px;
    }
    
    .modal-loading-message {
        font-size: 14px;
    }
    
    .modal-loading-progress {
        width: 180px;
    }
}

/* ===========================================
   DARK MODE SUPPORT
   =========================================== */

body.dark-mode .modal-loading-overlay {
    background: rgba(0, 0, 0, 0.7);
}

body.dark-mode .modal-loading-content {
    background: linear-gradient(135deg, #2d3748 0%, #374151 100%);
    color: #e2e8f0;
}

body.dark-mode .modal-loading-title {
    color: #667eea;
}

body.dark-mode .modal-loading-message {
    color: #cbd5e0;
}

body.dark-mode .modal-loading-progress {
    background: linear-gradient(90deg, #4a5568, #374151, #4a5568);
}

body.dark-mode .modal-loading-progress-bar {
    background: linear-gradient(90deg, #667eea, #764ba2, #667eea, #48bb78);
}