/**
 * ZenVote - Skeleton Loading System
 * 
 * Système de chargement squelette moderne et performant
 * Compatible avec le design system ZenVote (vert & blanc)
 * 
 * @package ZenVote
 * @version 1.0.0
 */

/* ============================================
   ANIMATIONS DE BASE
   ============================================ */

@keyframes skeleton-loading {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

@keyframes skeleton-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
}

@keyframes skeleton-wave {
    0% {
        transform: translateX(-100%);
    }
    50% {
        transform: translateX(100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* ============================================
   CLASSES DE BASE SKELETON
   ============================================ */

.skeleton {
    background: linear-gradient(90deg, var(--zen-gray-200) 25%, var(--zen-gray-100) 50%, var(--zen-gray-200) 75%);
    background-size: 200px 100%;
    animation: skeleton-loading 1.5s infinite linear;
    border-radius: var(--border-radius-md);
    position: relative;
    overflow: hidden;
}

.skeleton::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    animation: skeleton-wave 2s infinite;
}

/* Variante pulse pour les éléments plus petits */
.skeleton-pulse {
    background: var(--zen-gray-200);
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: var(--border-radius-md);
}

/* Mode sombre pour les skeleton */
.skeleton-dark {
    background: linear-gradient(90deg, var(--zen-gray-700) 25%, var(--zen-gray-600) 50%, var(--zen-gray-700) 75%);
    background-size: 200px 100%;
    animation: skeleton-loading 1.5s infinite linear;
}

.skeleton-dark::after {
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
}

/* ============================================
   SKELETON POUR TEXTE
   ============================================ */

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
    border-radius: var(--border-radius-sm);
}

.skeleton-text-sm {
    height: 0.875rem;
}

.skeleton-text-lg {
    height: 1.25rem;
}

.skeleton-text-xl {
    height: 1.5rem;
}

.skeleton-title {
    height: 2rem;
    margin-bottom: var(--spacing-md);
    border-radius: var(--border-radius-md);
}

.skeleton-subtitle {
    height: 1.5rem;
    margin-bottom: var(--spacing-sm);
    border-radius: var(--border-radius-md);
}

/* Largeurs variées pour un effet plus naturel */
.skeleton-text-75 { width: 75%; }
.skeleton-text-50 { width: 50%; }
.skeleton-text-25 { width: 25%; }
.skeleton-text-90 { width: 90%; }
.skeleton-text-60 { width: 60%; }

/* ============================================
   SKELETON POUR CARTES
   ============================================ */

.skeleton-card {
    background-color: var(--zen-white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-lg);
    border: 1px solid var(--zen-gray-200);
}

.skeleton-card-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--zen-gray-200);
}

.skeleton-card-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-card-content {
    flex: 1;
}

.skeleton-card-body {
    margin-bottom: var(--spacing-lg);
}

.skeleton-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--zen-gray-200);
}

/* ============================================
   SKELETON POUR BOUTONS
   ============================================ */

.skeleton-btn {
    height: 2.5rem;
    width: 120px;
    border-radius: var(--border-radius-md);
}

.skeleton-btn-sm {
    height: 2rem;
    width: 80px;
}

.skeleton-btn-lg {
    height: 3rem;
    width: 160px;
}

.skeleton-btn-full {
    width: 100%;
}

/* ============================================
   SKELETON POUR IMAGES
   ============================================ */

.skeleton-image {
    background-color: var(--zen-gray-200);
    border-radius: var(--border-radius-md);
    position: relative;
    overflow: hidden;
}

.skeleton-image::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23D1D5DB' viewBox='0 0 24 24'%3E%3Cpath d='M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.5;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-avatar-sm {
    width: 32px;
    height: 32px;
}

.skeleton-avatar-lg {
    width: 56px;
    height: 56px;
}

/* ============================================
   SKELETON POUR TABLEAUX
   ============================================ */

.skeleton-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--zen-white);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.skeleton-table-header {
    background: var(--zen-gray-50);
    height: 48px;
}

.skeleton-table-row {
    height: 56px;
    border-bottom: 1px solid var(--zen-gray-200);
}

.skeleton-table-cell {
    padding: var(--spacing-md);
    vertical-align: middle;
}

.skeleton-table-cell .skeleton {
    height: 1rem;
    margin: 0;
}

/* ============================================
   SKELETON POUR STATISTIQUES
   ============================================ */

.skeleton-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.skeleton-stats-card {
    background: var(--zen-white);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--zen-gray-200);
}

.skeleton-stats-number {
    height: 3rem;
    width: 80%;
    margin-bottom: var(--spacing-md);
    border-radius: var(--border-radius-md);
}

.skeleton-stats-label {
    height: 1rem;
    width: 60%;
    border-radius: var(--border-radius-sm);
}

/* ============================================
   SKELETON POUR GRAPHIQUES
   ============================================ */

.skeleton-chart {
    height: 300px;
    background: var(--zen-white);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--zen-gray-200);
    position: relative;
    overflow: hidden;
}

.skeleton-chart::before {
    content: '';
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    height: 200px;
    background: linear-gradient(180deg, var(--zen-gray-200) 0%, var(--zen-gray-100) 100%);
    border-radius: var(--border-radius-sm);
}

.skeleton-chart::after {
    content: '';
    position: absolute;
    top: 20px;
    left: 20px;
    width: 150px;
    height: 1.5rem;
    background: var(--zen-gray-200);
    border-radius: var(--border-radius-sm);
}

/* ============================================
   SKELETON POUR LISTES
   ============================================ */

.skeleton-list {
    background: var(--zen-white);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--zen-gray-200);
    overflow: hidden;
}

.skeleton-list-item {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--zen-gray-200);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.skeleton-list-item:last-child {
    border-bottom: none;
}

.skeleton-list-content {
    flex: 1;
}

/* ============================================
   SKELETON POUR FORMULAIRES
   ============================================ */

.skeleton-form-group {
    margin-bottom: var(--spacing-lg);
}

.skeleton-form-label {
    height: 1rem;
    width: 120px;
    margin-bottom: var(--spacing-sm);
    border-radius: var(--border-radius-sm);
}

.skeleton-form-input {
    height: 2.75rem;
    width: 100%;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--zen-gray-200);
}

.skeleton-form-textarea {
    height: 120px;
    width: 100%;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--zen-gray-200);
}

/* ============================================
   SKELETON POUR NAVIGATION
   ============================================ */

.skeleton-nav {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
    padding: var(--spacing-md) 0;
}

.skeleton-nav-item {
    height: 1.25rem;
    width: 80px;
    border-radius: var(--border-radius-sm);
}

.skeleton-nav-logo {
    height: 2rem;
    width: 120px;
    border-radius: var(--border-radius-md);
}

/* ============================================
   CONTENEURS DE SKELETON
   ============================================ */

.skeleton-container {
    padding: var(--spacing-lg);
}

.skeleton-section {
    margin-bottom: var(--spacing-2xl);
}

.skeleton-grid {
    display: grid;
    gap: var(--spacing-lg);
}

.skeleton-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.skeleton-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.skeleton-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* ============================================
   ÉTATS ET VARIATIONS
   ============================================ */

.skeleton-loading {
    pointer-events: none;
    user-select: none;
}

.skeleton-fade-in {
    animation: fadeIn 0.3s ease;
}

.skeleton-fade-out {
    animation: fadeOut 0.3s ease;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .skeleton-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .skeleton-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .skeleton-grid-2 {
        grid-template-columns: 1fr;
    }
    
    .skeleton-stats-grid {
        grid-template-columns: 1fr;
    }
    
    .skeleton-card {
        padding: var(--spacing-md);
    }
    
    .skeleton-nav {
        flex-wrap: wrap;
        gap: var(--spacing-sm);
    }
}

@media (max-width: 480px) {
    .skeleton-container {
        padding: var(--spacing-md);
    }
    
    .skeleton-chart {
        height: 250px;
    }
    
    .skeleton-btn {
        width: 100px;
    }
    
    .skeleton-btn-lg {
        width: 140px;
    }
}

/* ============================================
   UTILITAIRES SKELETON
   ============================================ */

.skeleton-hidden {
    display: none;
}

.skeleton-visible {
    display: block;
}

.skeleton-flex {
    display: flex;
}

.skeleton-grid-display {
    display: grid;
}

/* Classes pour masquer/afficher le contenu réel */
.content-loading .real-content {
    display: none;
}

.content-loading .skeleton-content {
    display: block;
}

.content-loaded .real-content {
    display: block;
}

.content-loaded .skeleton-content {
    display: none;
}

/* ============================================
   SKELETON SPÉCIFIQUES ZENVOTE
   ============================================ */

/* Skeleton pour les cartes de sondage */
.skeleton-poll-card {
    background: var(--zen-white);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--zen-gray-200);
    margin-bottom: var(--spacing-lg);
}

.skeleton-poll-title {
    height: 1.5rem;
    width: 80%;
    margin-bottom: var(--spacing-md);
    border-radius: var(--border-radius-md);
}

.skeleton-poll-description {
    height: 1rem;
    width: 100%;
    margin-bottom: var(--spacing-sm);
    border-radius: var(--border-radius-sm);
}

.skeleton-poll-options {
    margin: var(--spacing-lg) 0;
}

.skeleton-poll-option {
    height: 2.5rem;
    width: 100%;
    margin-bottom: var(--spacing-sm);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--zen-gray-200);
}

.skeleton-poll-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--zen-gray-200);
}

.skeleton-poll-stat {
    height: 1rem;
    width: 60px;
    border-radius: var(--border-radius-sm);
}

/* Skeleton pour les événements */
.skeleton-event-card {
    background: var(--zen-white);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--zen-gray-200);
}

.skeleton-event-image {
    height: 200px;
    width: 100%;
    background: var(--zen-gray-200);
}

.skeleton-event-content {
    padding: var(--spacing-xl);
}

.skeleton-event-title {
    height: 1.5rem;
    width: 90%;
    margin-bottom: var(--spacing-md);
    border-radius: var(--border-radius-md);
}

.skeleton-event-date {
    height: 1rem;
    width: 40%;
    margin-bottom: var(--spacing-sm);
    border-radius: var(--border-radius-sm);
}

.skeleton-event-description {
    height: 1rem;
    width: 100%;
    margin-bottom: var(--spacing-sm);
    border-radius: var(--border-radius-sm);
}

/* Skeleton pour le dashboard */
.skeleton-dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xl);
}

.skeleton-dashboard-title {
    height: 2.5rem;
    width: 300px;
    border-radius: var(--border-radius-lg);
}

.skeleton-dashboard-actions {
    display: flex;
    gap: var(--spacing-md);
}