/* ========== AMÉLIORATIONS UI ========== */

/* 1. CORRECTIONS DE BUGS D'AFFICHAGE */
.stat-card {
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    transform: rotate(45deg);
    animation: shimmer 3s infinite;
    z-index: -1;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%) rotate(45deg);
    }
    100% {
        transform: translateX(100%) rotate(45deg);
    }
}

/* 2. AMÉLIORATION DE L'AFFICHAGE MOBILE */
@media screen and (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr !important;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        transition: left 0.3s ease;
        z-index: 1000;
        width: 250px !important;
    }

    .sidebar.active {
        left: 0;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 1rem !important;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    .activity-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* 3. CORRECTION DES DÉBORDEMENTS */
.activity-item {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.stat-number {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
}

/* 4. AMÉLIORATION DES INTERACTIONS */
.stat-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.nav-item {
    position: relative;
    overflow: hidden;
}

.nav-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.nav-item:hover::after {
    transform: scaleX(1);
}

/* 5. CORRECTION DES PROBLÈMES DE CONTRASTE */
.stat-card h3 {
    color: #4a5568;
    font-weight: 600;
}

.activity-time {
    background: #667eea;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
}

/* 6. AMÉLIORATION DE L'ACCESSIBILITÉ */
:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

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

/* 7. MODE SOMBRE */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a202c;
        color: #e2e8f0;
    }

    .sidebar {
        background-color: #2d3748;
    }

    .stat-card {
        background-color: #2d3748;
        border-color: #4a5568;
    }

    .stat-card h3 {
        color: #e2e8f0;
    }

    .activity-item {
        background-color: #2d3748;
        border-color: #4a5568;
    }
}

/* 8. ANIMATIONS D'ENTRÉE */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stat-card,
.activity-item {
    animation: fadeInUp 0.6s ease forwards;
}

.stat-card:nth-child(2) {
    animation-delay: 0.1s;
}

.stat-card:nth-child(3) {
    animation-delay: 0.2s;
}

.stat-card:nth-child(4) {
    animation-delay: 0.3s;
}

/* 9. CORRECTION DES ESPACEMENTS */
.main-content {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.stat-card {
    padding: 1.5rem;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

/* 10. AMÉLIORATION DE LA TYPOGRAPHIE */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 {
    font-weight: 600;
    line-height: 1.3;
}

h1 {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
}

h2 {
    font-size: clamp(1.5rem, 3vw, 2rem);
    margin-bottom: 1.5rem;
}

/* 11. GESTION DES ÉTATS DE CHARGEMENT */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    animation: loading 1.5s infinite;
}

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

/* 12. CORRECTION POUR IMPRESSION */
@media print {
    .sidebar,
    .main-header {
        display: none;
    }

    .main-content {
        margin: 0;
        padding: 0;
    }

    .stat-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}