/* ========================================
   DASHBOARD-STYLES.CSS - Dashboard amélioré
   Version: 2.1 (Université Chouaib Doukkali)
   ======================================== */

/* ========================================
   1. DASHBOARD CONTAINER
   ======================================== */
.dashboard-container {
    padding: 20px 0;
}

/* ========================================
   2. STATS CARDS - Version améliorée avec 4 par ligne
   ======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 15px;
    }
}

@media (max-width: 992px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
}

@media (max-width: 576px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    border-left: 4px solid var(--primary-color);
    cursor: default;
    min-height: 110px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-card .stat-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    position: relative;
    z-index: 1;
}

.stat-card .stat-info {
    flex: 1;
    min-width: 0;
}

.stat-card .stat-number {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-color);
    line-height: 1.2;
    margin-bottom: 2px;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stat-card .stat-trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-top: 4px;
    padding: 2px 10px;
    border-radius: 20px;
    background: var(--bg-light);
}

.stat-trend.up {
    color: var(--accent-color);
    background: var(--accent-bg);
}

.stat-trend.down {
    color: var(--danger-color);
    background: var(--danger-bg);
}

.stat-trend.neutral {
    color: var(--info-color);
    background: var(--info-bg);
}

.stat-card .stat-icon-wrapper {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: white;
    flex-shrink: 0;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    margin-left: 12px;
}

.stat-card:hover .stat-icon-wrapper {
    transform: scale(1.08) rotate(-3deg);
}

/* Stat card colors */
.stat-card.primary {
    border-left-color: var(--primary-color);
}
.stat-card.primary .stat-icon-wrapper {
    background: var(--primary-gradient);
}

.stat-card.green {
    border-left-color: var(--accent-color);
}
.stat-card.green .stat-icon-wrapper {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
}

.stat-card.orange {
    border-left-color: var(--warning-color);
}
.stat-card.orange .stat-icon-wrapper {
    background: linear-gradient(135deg, #f39c12, #f1c40f);
}

.stat-card.purple {
    border-left-color: #8e44ad;
}
.stat-card.purple .stat-icon-wrapper {
    background: linear-gradient(135deg, #8e44ad, #9b59b6);
}

.stat-card.teal {
    border-left-color: #1abc9c;
}
.stat-card.teal .stat-icon-wrapper {
    background: linear-gradient(135deg, #1abc9c, #16a085);
}

.stat-card.red {
    border-left-color: var(--danger-color);
}
.stat-card.red .stat-icon-wrapper {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.stat-card.blue {
    border-left-color: var(--secondary-color);
}
.stat-card.blue .stat-icon-wrapper {
    background: linear-gradient(135deg, #2e86c1, #3498db);
}

.stat-card.indigo {
    border-left-color: #3f51b5;
}
.stat-card.indigo .stat-icon-wrapper {
    background: linear-gradient(135deg, #3f51b5, #5c6bc0);
}

.stat-card.pink {
    border-left-color: #e91e63;
}
.stat-card.pink .stat-icon-wrapper {
    background: linear-gradient(135deg, #e91e63, #f06292);
}

/* ========================================
   3. CHART CONTAINERS
   ======================================== */
.chart-container {
    background: var(--bg-white);
    border-radius: var(--radius-md);
    padding: 20px 24px 24px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    height: 100%;
    border-top: 3px solid var(--primary-color);
}

.chart-container:hover {
    box-shadow: var(--shadow-hover);
}

.chart-container h6 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-container h6 i {
    color: var(--primary-color);
}

.chart-container .chart-wrapper {
    position: relative;
    height: 260px;
    width: 100%;
}

.chart-container .chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

.chart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
}

.chart-empty i {
    font-size: 3rem;
    color: var(--border-color);
    margin-bottom: 12px;
}

/* ========================================
   4. DASHBOARD HEADER
   ======================================== */
.dashboard-header {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.dashboard-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
}

.dashboard-header p {
    color: var(--text-muted);
    font-size: 1rem;
    margin: 4px 0 0 0;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.quick-stat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--bg-light);
    color: var(--text-color);
}

.quick-stat .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.quick-stat .dot.green { background: var(--accent-color); }
.quick-stat .dot.orange { background: var(--warning-color); }
.quick-stat .dot.red { background: var(--danger-color); }

/* ========================================
   5. RECENT ACTIVITY
   ======================================== */
.recent-activity {
    background: var(--bg-white);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    box-shadow: var(--shadow);
    border-top: 3px solid var(--secondary-color);
    height: 100%;
}

.recent-activity h6 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.recent-activity h6 i {
    color: var(--secondary-color);
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    transition: all 0.2s ease;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-item:hover {
    padding-left: 6px;
    background: var(--bg-light);
    border-radius: 6px;
}

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: white;
    flex-shrink: 0;
}

.activity-icon.green { background: var(--accent-color); }
.activity-icon.blue { background: var(--secondary-color); }
.activity-icon.orange { background: var(--warning-color); }
.activity-icon.red { background: var(--danger-color); }
.activity-icon.purple { background: #8e44ad; }
.activity-icon.pink { background: #e91e63; }

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-content .activity-text {
    font-size: 0.85rem;
    color: var(--text-color);
    margin: 0;
}

.activity-content .activity-text strong {
    color: var(--primary-color);
}

.activity-content .activity-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin: 0;
}

/* ========================================
   6. ANIMATIONS
   ======================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stat-card {
    animation: fadeInUp 0.5s ease forwards;
    opacity: 0;
}

.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.10s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.20s; }
.stat-card:nth-child(5) { animation-delay: 0.25s; }
.stat-card:nth-child(6) { animation-delay: 0.30s; }
.stat-card:nth-child(7) { animation-delay: 0.35s; }
.stat-card:nth-child(8) { animation-delay: 0.40s; }

.chart-container {
    animation: fadeInUp 0.5s ease forwards;
    animation-delay: 0.15s;
    opacity: 0;
}

/* ========================================
   7. LOADING STATES
   ======================================== */
.dashboard-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: var(--text-muted);
}

.dashboard-loading .spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-light);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   8. RESPONSIVE
   ======================================== */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 15px;
    }

    .stat-card .stat-number {
        font-size: 1.5rem;
    }

    .stat-card .stat-icon-wrapper {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
}

@media (max-width: 992px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .stat-card {
        padding: 16px 18px;
        min-height: 100px;
    }

    .stat-card .stat-number {
        font-size: 1.4rem;
    }

    .chart-container .chart-wrapper {
        height: 220px;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-card {
        padding: 14px 16px;
        min-height: 90px;
    }

    .stat-card .stat-number {
        font-size: 1.3rem;
    }

    .stat-card .stat-label {
        font-size: 0.7rem;
    }

    .stat-card .stat-icon-wrapper {
        width: 36px;
        height: 36px;
        font-size: 1rem;
        border-radius: 10px;
    }

    .stat-card .stat-trend {
        font-size: 0.65rem;
        padding: 1px 8px;
    }

    .chart-container {
        padding: 16px 16px 20px;
    }

    .chart-container .chart-wrapper {
        height: 200px;
    }

    .dashboard-header h1 {
        font-size: 1.4rem;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-card {
        padding: 12px 14px;
        min-height: 80px;
        border-left-width: 3px;
    }

    .stat-card .stat-number {
        font-size: 1.1rem;
    }

    .stat-card .stat-label {
        font-size: 0.65rem;
    }

    .stat-card .stat-icon-wrapper {
        width: 32px;
        height: 32px;
        font-size: 0.85rem;
        border-radius: 8px;
        margin-left: 8px;
    }

    .stat-card .stat-trend {
        font-size: 0.6rem;
        padding: 1px 6px;
        margin-top: 2px;
    }

    .chart-container .chart-wrapper {
        height: 170px;
    }

    .dashboard-header h1 {
        font-size: 1.2rem;
    }
}

/* ========================================
   9. DARK MODE SUPPORT
   ======================================== */
@media (prefers-color-scheme: dark) {
    .stat-card,
    .chart-container,
    .recent-activity {
        background: #1a2a3a;
        border-color: #2a3a4a;
    }

    .stat-card .stat-number {
        color: #e8edf3;
    }

    .stat-card .stat-label {
        color: #8a9aaa;
    }

    .chart-container h6 {
        color: #e8edf3;
    }

    .activity-content .activity-text {
        color: #d4dce8;
    }

    .activity-item {
        border-color: #2a3a4a;
    }

    .activity-item:hover {
        background: #1a2a3a;
    }

    .quick-stat {
        background: #1a2a3a;
        color: #d4dce8;
    }
}
