/*
 * Loading States & Animations
 * Spinners, Skeletons, และ Animations สวยงาม
 */

/* ===== Loading Spinners ===== */

/* Spinner - Default */
.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 158, 247, 0.1);
    border-top-color: #009ef7;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.loading-spinner-lg {
    width: 60px;
    height: 60px;
    border-width: 6px;
}

/* Spinner - Dots */
.loading-dots {
    display: inline-flex;
    gap: 8px;
}

.loading-dots span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #009ef7;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

/* Spinner - Pulse */
.loading-pulse {
    width: 40px;
    height: 40px;
    background: #009ef7;
    border-radius: 50%;
    animation: pulse 1.2s ease-in-out infinite;
}

/* Full Page Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.loading-overlay-content {
    text-align: center;
    color: white;
}

.loading-overlay-text {
    margin-top: 1rem;
    font-size: 1.1rem;
    font-weight: 500;
}

/* ===== Skeleton Loaders ===== */

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

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

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

.skeleton-title {
    height: 1.5rem;
    width: 60%;
    margin-bottom: 1rem;
}

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

.skeleton-button {
    height: 38px;
    width: 120px;
}

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

/* Dark mode skeletons */
[data-theme="dark"] .skeleton {
    background: linear-gradient(
        90deg,
        #2e3244 25%,
        #3f4254 50%,
        #2e3244 75%
    );
    background-size: 200% 100%;
}

/* ===== Progress Indicators ===== */

.progress-bar-animated {
    animation: progress-bar-stripes 1s linear infinite;
}

.progress-circular {
    width: 100px;
    height: 100px;
    position: relative;
}

.progress-circular svg {
    transform: rotate(-90deg);
}

.progress-circular-path {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    stroke: #009ef7;
    transition: stroke-dashoffset 0.3s ease;
}

/* ===== Button Loading States ===== */

.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-loading .btn-text {
    visibility: hidden;
}

/* ===== Fade In/Out Animations ===== */

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

.fade-out {
    animation: fadeOut 0.3s ease-out;
}

.slide-in-up {
    animation: slideInUp 0.3s ease-out;
}

.slide-in-down {
    animation: slideInDown 0.3s ease-out;
}

.slide-in-left {
    animation: slideInLeft 0.3s ease-out;
}

.slide-in-right {
    animation: slideInRight 0.3s ease-out;
}

.scale-in {
    animation: scaleIn 0.3s ease-out;
}

.bounce-in {
    animation: bounceIn 0.5s ease-out;
}

/* ===== Page Transition ===== */

.page-transition {
    animation: pageTransition 0.3s ease-out;
}

/* ===== Shimmer Effect ===== */

.shimmer {
    position: relative;
    overflow: hidden;
}

.shimmer::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: shimmer 2s infinite;
}

/* Dark mode shimmer */
[data-theme="dark"] .shimmer::after {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0) 100%
    );
}

/* ===== Keyframe Animations ===== */

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

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

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

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

@keyframes progress-bar-stripes {
    0% {
        background-position: 1rem 0;
    }
    100% {
        background-position: 0 0;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes slideInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(20px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pageTransition {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* ===== Hover Effects ===== */

.hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.hover-scale {
    transition: transform 0.2s ease;
}

.hover-scale:hover {
    transform: scale(1.05);
}

.hover-glow {
    transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(0, 158, 247, 0.4);
}

/* ===== Mobile Optimizations ===== */

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

    .loading-overlay-text {
        font-size: 1rem;
    }
}

/* ===== Accessibility ===== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .skeleton,
    .shimmer::after {
        animation: none !important;
    }
}

/* ===== Utility Classes ===== */

.loading-state {
    position: relative;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.no-animation {
    animation: none !important;
}

.delay-100 {
    animation-delay: 100ms !important;
}

.delay-200 {
    animation-delay: 200ms !important;
}

.delay-300 {
    animation-delay: 300ms !important;
}

.delay-500 {
    animation-delay: 500ms !important;
}

.duration-fast {
    animation-duration: 0.2s !important;
}

.duration-normal {
    animation-duration: 0.3s !important;
}

.duration-slow {
    animation-duration: 0.5s !important;
}
