/**
 * ═══════════════════════════════════════════════════════════════════════════
 * SA ĐÉC MARKETING HUB — LOADING STATES CSS
 * ═══════════════════════════════════════════════════════════════════════════
 *
 * Loading States:
 * - Spinner animations (multiple variants)
 * - Skeleton loaders
 * - Button loading states
 * - Page/loader overlay
 * - Progress bars
 * - Shimmer effects
 *
 * @version 1.0.0 | 2026-03-14
 * @author Mekong Agency
 * ═══════════════════════════════════════════════════════════════════════════
 */

/* ═══════════════════════════════════════════════════════════════════════════
   1. SPINNER ANIMATIONS
   ═══════════════════════════════════════════════════════════════════════════ */

/* Base Spinner */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--md-sys-color-outline-variant, #e0e0e0);
    border-top-color: var(--md-sys-color-primary, #006A60);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Small Spinner */
.loading-spinner.sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

/* Large Spinner */
.loading-spinner.lg {
    width: 60px;
    height: 60px;
    border-width: 4px;
}

/* Primary Color */
.loading-spinner.primary {
    border-top-color: var(--md-sys-color-primary, #006A60);
}

/* Secondary Color */
.loading-spinner.secondary {
    border-top-color: var(--md-sys-color-secondary, #9C6800);
}

/* Dual Ring Spinner */
.loading-spinner.dual-ring {
    width: 40px;
    height: 40px;
}

.loading-spinner.dual-ring::after {
    content: '';
    display: block;
    width: 32px;
    height: 32px;
    margin: 4px;
    border: 3px solid var(--md-sys-color-primary, #006A60);
    border-color: var(--md-sys-color-primary, #006A60) transparent var(--md-sys-color-primary, #006A60) transparent;
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
}

/* Dots Spinner */
.loading-spinner.dots {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
}

.loading-spinner.dots::before,
.loading-spinner.dots::after {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--md-sys-color-primary, #006A60);
    border-radius: 50%;
    animation: dots 1.4s infinite ease-in-out;
}

.loading-spinner.dots::after {
    animation-delay: 0.16s;
}

@keyframes dots {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   2. SKELETON LOADERS
   ═══════════════════════════════════════════════════════════════════════════ */

.skeleton {
    background: linear-gradient(
        90deg,
        var(--md-sys-color-surface-variant, #f0f0f0) 25%,
        var(--md-sys-color-outline-variant, #e0e0e0) 50%,
        var(--md-sys-color-surface-variant, #f0f0f0) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--md-sys-shape-corner-small, 4px);
    color: transparent !important;
}

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

/* Skeleton Shapes */
.skeleton.circle {
    border-radius: 50%;
}

.skeleton.round {
    border-radius: var(--md-sys-shape-corner-full, 999px);
}

/* Skeleton Sizes */
.skeleton.text {
    height: 16px;
    width: 100%;
    margin-bottom: 8px;
}

.skeleton.title {
    height: 24px;
    width: 60%;
    margin-bottom: 12px;
}

.skeleton.subtitle {
    height: 20px;
    width: 80%;
    margin-bottom: 10px;
}

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

.skeleton.image {
    width: 100%;
    height: 200px;
}

.skeleton.card {
    padding: 16px;
    border-radius: var(--md-sys-shape-corner-medium, 12px);
}

/* Skeleton Lines */
.skeleton.lines-1 { display: block; }
.skeleton.lines-1::after {
    content: '';
    display: block;
    height: 16px;
    width: 100%;
}

.skeleton.lines-2::after {
    content: '';
    display: block;
    height: 16px;
    width: 90%;
    margin-top: 8px;
}

.skeleton.lines-3::after {
    content: '';
    display: block;
    height: 16px;
    width: 95%;
    margin-top: 8px;
}

/* Dark Mode Skeleton */
.dark-theme .skeleton {
    background: linear-gradient(
        90deg,
        #2d2d2d 25%,
        #3d3d3d 50%,
        #2d2d2d 75%
    );
    background-size: 200% 100%;
}

/* ═══════════════════════════════════════════════════════════════════════════
   3. BUTTON LOADING STATES
   ═══════════════════════════════════════════════════════════════════════════ */

.btn-loading {
    position: relative;
    pointer-events: none;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    margin-left: -8px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    color: var(--md-sys-color-on-primary, #FFFFFF);
}

.btn-loading.sm::after {
    width: 12px;
    height: 12px;
    margin-top: -6px;
    margin-left: -6px;
}

.btn-loading.lg::after {
    width: 24px;
    height: 24px;
    margin-top: -12px;
    margin-left: -12px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   4. PAGE LOADER OVERLAY
   ═══════════════════════════════════════════════════════════════════════════ */

.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--md-sys-color-surface, #FAFDFC);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    z-index: 9999;
}

.page-loader.hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.page-loader-text {
    color: var(--md-sys-color-on-surface, #191C1B);
    font-size: 14px;
    font-weight: 500;
}

/* Pulse Logo Animation */
.page-loader-logo {
    width: 80px;
    height: 80px;
    animation: pulse-logo 2s ease-in-out infinite;
}

@keyframes pulse-logo {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   5. PROGRESS BARS
   ═══════════════════════════════════════════════════════════════════════════ */

.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--md-sys-color-outline-variant, #e0e0e0);
    border-radius: var(--md-sys-shape-corner-full, 2px);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--md-sys-color-primary, #006A60);
    border-radius: var(--md-sys-shape-corner-full, 2px);
    transition: width 0.3s ease;
}

/* Indeterminate Progress */
.progress-bar.indeterminate .progress-bar-fill {
    width: 30%;
    animation: indeterminate 1.5s ease-in-out infinite;
}

@keyframes indeterminate {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(400%);
    }
}

/* Circular Progress */
.circular-progress {
    width: 60px;
    height: 60px;
    position: relative;
}

.circular-progress svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.circular-progress-circle {
    fill: none;
    stroke: var(--md-sys-color-primary, #006A60);
    stroke-linecap: round;
    stroke-dasharray: 157;
    stroke-dashoffset: 157;
    animation: circular-progress 1.5s ease-in-out infinite;
}

@keyframes circular-progress {
    0% {
        stroke-dashoffset: 157;
    }
    50% {
        stroke-dashoffset: 39;
    }
    100% {
        stroke-dashoffset: 157;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   6. SHIMMER EFFECTS
   ═══════════════════════════════════════════════════════════════════════════ */

.shimmer {
    position: relative;
    overflow: hidden;
    background: var(--md-sys-color-surface-variant, #f0f0f0);
}

.shimmer::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    transform: translateX(-100%);
    animation: shimmer-slide 2s infinite;
}

@keyframes shimmer-slide {
    100% {
        transform: translateX(100%);
    }
}

/* Shimmer Card */
.shimmer-card {
    padding: 16px;
    border-radius: var(--md-sys-shape-corner-medium, 12px);
    margin-bottom: 16px;
}

.shimmer-card::after {
    animation-delay: 0.3s;
}

/* ═══════════════════════════════════════════════════════════════════════════
   7. LOADING STATES FOR COMPONENTS
   ═══════════════════════════════════════════════════════════════════════════ */

/* Table Loading */
.table-loading {
    padding: 48px 24px;
    text-align: center;
    color: var(--md-sys-color-on-surface-variant, #666);
}

/* Card Loading */
.card-loading {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
}

/* List Loading */
.list-loading {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.list-loading .list-item-skeleton {
    height: 60px;
    border-radius: var(--md-sys-shape-corner-small, 8px);
}

/* Dashboard Widget Loading */
.widget-loading {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.widget-loading .widget-value {
    height: 40px;
    width: 80%;
}

.widget-loading .widget-label {
    height: 16px;
    width: 60%;
}

/* ═══════════════════════════════════════════════════════════════════════════
   8. FADE TRANSITIONS
   ═══════════════════════════════════════════════════════════════════════════ */

.fade-enter {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.fade-enter-active {
    opacity: 1;
    transform: translateY(0);
}

.fade-exit {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.fade-exit-active {
    opacity: 0;
    transform: translateY(-10px);
}

/* ═══════════════════════════════════════════════════════════════════════════
   9. RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .loading-spinner.lg {
        width: 48px;
        height: 48px;
    }

    .page-loader-logo {
        width: 60px;
        height: 60px;
    }

    .circular-progress {
        width: 48px;
        height: 48px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   10. UTILITY CLASSES
   ═══════════════════════════════════════════════════════════════════════════ */

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.dark-theme .loading-overlay {
    background: rgba(0, 0, 0, 0.6);
}

.loading-center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.loading-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.loading-text {
    color: var(--md-sys-color-on-surface-variant, #666);
    font-size: 14px;
}

/* Animation Delays */
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }
