<template>
    <div class="skeleton-dashboard">
        <!-- Hero Section Skeleton -->
        <section class="skeleton-hero">
            <div class="hero-content">
                <div class="skeleton-greeting">
                    <div class="skeleton-line large pulse-slow"></div>
                    <div class="skeleton-line medium pulse-delayed"></div>
                </div>
                <div class="skeleton-status-card">
                    <div class="card-header">
                        <div class="skeleton-circle"></div>
                        <div class="skeleton-content">
                            <div class="skeleton-line"></div>
                            <div class="skeleton-line short"></div>
                        </div>
                    </div>
                    <div class="card-body">
                        <div class="skeleton-progress-bar">
                            <div class="progress-shimmer"></div>
                        </div>
                        <div class="skeleton-actions">
                            <div class="skeleton-button primary"></div>
                            <div class="skeleton-button secondary"></div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Quick Actions Skeleton -->
        <section class="skeleton-quick-actions">
            <div class="section-header">
                <div class="skeleton-line section-title"></div>
                <div class="skeleton-badge"></div>
            </div>

            <div class="quick-actions-grid">
                <div v-for="i in 3" :key="i" class="skeleton-action-card" :style="{ animationDelay: `${i * 0.1}s` }">
                    <div class="action-icon">
                        <div class="skeleton-circle medium shimmer"></div>
                    </div>
                    <div class="action-content">
                        <div class="skeleton-line"></div>
                        <div class="skeleton-line short faded"></div>
                    </div>
                    <div class="action-arrow">
                        <div class="skeleton-line tiny"></div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Activity Feed Skeleton -->
        <section class="skeleton-activity">
            <div class="section-header">
                <div class="skeleton-line section-title"></div>
                <div class="skeleton-button small"></div>
            </div>

            <div class="activity-container">
                <div v-for="i in 4" :key="i" class="skeleton-activity-item" :style="{ animationDelay: `${i * 0.15}s` }">
                    <div class="activity-avatar">
                        <div class="skeleton-circle small shimmer"></div>
                    </div>
                    <div class="activity-content">
                        <div class="skeleton-line"></div>
                        <div class="skeleton-line medium faded"></div>
                    </div>
                    <div class="activity-time">
                        <div class="skeleton-line tiny"></div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Stats Grid Skeleton -->
        <section class="skeleton-stats">
            <div class="stats-grid">
                <div v-for="i in 4" :key="i" class="skeleton-stat-card" :style="{ animationDelay: `${i * 0.2}s` }">
                    <div class="stat-icon">
                        <div class="skeleton-circle small shimmer"></div>
                    </div>
                    <div class="stat-content">
                        <div class="skeleton-line number"></div>
                        <div class="skeleton-line label"></div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Floating Elements for Enhanced Effect -->
        <div class="skeleton-decorations">
            <div class="floating-dot" v-for="i in 6" :key="i" :style="getFloatingStyle(i)"></div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { computed } from 'vue'

// Enhanced floating animation styles
const getFloatingStyle = (index: number) => {
    const delays = [0, 0.5, 1, 1.5, 2, 2.5]
    const positions = [
        { top: '10%', left: '5%' },
        { top: '20%', right: '8%' },
        { top: '40%', left: '3%' },
        { top: '60%', right: '5%' },
        { top: '80%', left: '7%' },
        { top: '90%', right: '10%' }
    ]

    return {
        ...positions[index - 1],
        animationDelay: `${delays[index - 1]}s`,
        animationDuration: `${3 + (index * 0.5)}s`
    }
}
</script>

<style scoped lang="scss">
.skeleton-dashboard {
    min-height: 100vh;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    padding: 0;
    position: relative;
    overflow: hidden;

    @media (min-width: 768px) {
        padding: 0 1rem;
    }
}

/* Hero Section Skeleton */
.skeleton-hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 2rem 1rem 3rem;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;

    &::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
        animation: hero-shimmer 3s ease-in-out infinite;
    }

    @media (min-width: 768px) {
        border-radius: 16px;
        margin: 1rem 0 2rem;
        padding: 3rem 2rem 4rem;
    }
}

.hero-content {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.skeleton-greeting {
    margin-bottom: 2rem;
    text-align: center;

    @media (min-width: 768px) {
        text-align: left;
    }
}

.skeleton-status-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);

    @media (min-width: 768px) {
        padding: 2rem;
    }
}

.card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.skeleton-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.card-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.skeleton-progress-bar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    position: relative;

    .progress-shimmer {
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, #3b82f6, transparent);
        animation: progress-slide 2s ease-in-out infinite;
    }
}

.skeleton-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;

    @media (min-width: 768px) {
        justify-content: flex-start;
    }
}

/* Quick Actions Skeleton */
.skeleton-quick-actions {
    max-width: 1200px;
    margin: 0 auto 3rem;
    padding: 0 1rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.skeleton-badge {
    width: 80px;
    height: 24px;
    background: linear-gradient(90deg, #e0e7ff 25%, #c7d2fe 50%, #e0e7ff 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: 12px;
}

.quick-actions-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;

    @media (min-width: 640px) {
        grid-template-columns: repeat(2, 1fr);
    }

    @media (min-width: 1024px) {
        grid-template-columns: repeat(3, 1fr);
    }
}

.skeleton-action-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    animation: skeleton-fade-in 0.6s ease-out both;
}

.action-icon {
    flex-shrink: 0;
}

.action-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.action-arrow {
    flex-shrink: 0;
}

/* Activity Skeleton */
.skeleton-activity {
    max-width: 1200px;
    margin: 0 auto 3rem;
    padding: 0 1rem;
}

.activity-container {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid #e5e7eb;
}

.skeleton-activity-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid #f3f4f6;
    animation: skeleton-fade-in 0.6s ease-out both;

    &:last-child {
        border-bottom: none;
    }
}

.activity-avatar {
    flex-shrink: 0;
}

.activity-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.activity-time {
    flex-shrink: 0;
}

/* Stats Grid Skeleton */
.skeleton-stats {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.stats-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, 1fr);

    @media (min-width: 768px) {
        grid-template-columns: repeat(4, 1fr);
    }
}

.skeleton-stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    animation: skeleton-fade-in 0.6s ease-out both;
}

.stat-icon {
    flex-shrink: 0;
}

.stat-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Base Skeleton Elements */
.skeleton-line {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: 4px;

    // Size variants
    &.large {
        height: 2rem;
        width: 60%;
    }

    &.medium {
        height: 1.5rem;
        width: 45%;
    }

    &.section-title {
        height: 1.75rem;
        width: 40%;
    }

    &.number {
        height: 2.5rem;
        width: 50%;
    }

    &.label {
        height: 1rem;
        width: 80%;
    }

    &.short {
        width: 60%;
    }

    &.tiny {
        height: 0.75rem;
        width: 40px;
    }

    // Default size
    height: 1rem;
    width: 100%;

    // Animation variants
    &.pulse-slow {
        animation: skeleton-pulse 2s ease-in-out infinite;
    }

    &.pulse-delayed {
        animation: skeleton-pulse 2s ease-in-out infinite;
        animation-delay: 0.3s;
    }

    &.faded {
        opacity: 0.6;
    }
}

.skeleton-circle {
    border-radius: 50%;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;

    // Size variants
    &.small {
        width: 32px;
        height: 32px;
    }

    &.medium {
        width: 48px;
        height: 48px;
    }

    // Default size
    width: 40px;
    height: 40px;

    &.shimmer {
        animation: skeleton-shimmer 1.5s infinite, skeleton-pulse 3s ease-in-out infinite;
    }
}

.skeleton-button {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: 8px;

    &.primary {
        height: 2.5rem;
        width: 120px;
    }

    &.secondary {
        height: 2.5rem;
        width: 100px;
    }

    &.small {
        height: 2rem;
        width: 80px;
    }
}

/* Floating Decorations */
.skeleton-decorations {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
}

.floating-dot {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 50%;
    animation: float-up-down 4s ease-in-out infinite;
}

/* Animations */
@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

@keyframes skeleton-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

@keyframes skeleton-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

    100% {
        transform: translateX(100%);
    }
}

@keyframes progress-slide {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

@keyframes float-up-down {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-20px);
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .skeleton-dashboard {
        background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    }

    .skeleton-status-card,
    .skeleton-action-card,
    .activity-container,
    .skeleton-stat-card {
        background: #334155;
        border-color: #475569;
    }

    .skeleton-line,
    .skeleton-circle,
    .skeleton-button {
        background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
        background-size: 200% 100%;
    }

    .skeleton-badge {
        background: linear-gradient(90deg, #475569 25%, #64748b 50%, #475569 75%);
        background-size: 200% 100%;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* Performance optimizations */
.skeleton-line,
.skeleton-circle,
.skeleton-button,
.skeleton-badge {
    will-change: background-position;
}

.skeleton-action-card,
.skeleton-activity-item,
.skeleton-stat-card {
    will-change: opacity, transform;
}
</style>