/**
 * Styles pour les statistiques Vocabulaire Arabe
 */
/* ========================================
   Reset & Base
   ======================================== */
.va-stats-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--va-gray-800);
    background: var(--va-gray-50);
    scroll-behavior: smooth;
}

.va-stats-wrapper *,
.va-stats-wrapper *::before,
.va-stats-wrapper *::after {
    box-sizing: border-box;
}

/* Polices arabes */
[lang="ar"] {
    font-family: 'Amiri', serif;
}

/* ========================================
   Layout
   ======================================== */
.va-stats-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
}


/* ========================================
KPIs
======================================== */
.va-stats-kpis {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.va-stats-kpis:not(#exoStats) {
    margin-bottom: 2.5rem;
}

.va-stats-kpis-3col {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* Grille principale */
#kpis {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-auto-rows: auto;
    /*grid-template-rows: repeat(3, 1fr);*/
    grid-column-gap: 1rem;
    grid-row-gap: 1rem;
    margin-bottom: 2.5rem;
}

/* Ligne 1 */
#kpis .va-stats-kpi-card:nth-child(1) { grid-area: 1 / 1 / 2 / 3; }
#kpis .va-stats-kpi-card:nth-child(2) { grid-area: 1 / 3 / 2 / 5; }
#kpis .va-stats-kpi-card:nth-child(3) { grid-area: 1 / 5 / 2 / 7; }

/* Ligne 2 */
#kpis .va-stats-kpi-card:nth-child(4) { grid-area: 2 / 1 / 3 / 4; }
#kpis .va-stats-kpi-card:nth-child(5) { grid-area: 2 / 4 / 3 / 7; }

/* Ligne 3 */
#kpis .va-stats-kpi-card:nth-child(6) { grid-area: 3 / 1 / 4 / 4; }
#kpis .va-stats-kpi-card:nth-child(7) { grid-area: 3 / 4 / 4 / 7; }

.va-stats-kpi-card {
    background: white;
    border-radius: 1rem;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.va-stats-kpi-label {
    color: var(--va-gray-500);
    font-size: 0.875rem;
    margin: 0 0 0.5rem;
}

.va-stats-kpi-value {
    font-size: 1.875rem;
    font-weight: 800;
    color: var(--va-blue-night);
    margin: 0;
}

/* ========================================
   Card / Section
   ======================================== */
.va-stats-card,
.va-stats-section {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 2.5rem;
    overflow-x: hidden;
}

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

.va-stats-section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--va-blue-night);
    margin: 0;
}

.va-stats-subsection-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--va-blue-night);
    margin: 0 0 0.75rem;
}

.va-stats-section-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ========================================
   Buttons
   ======================================== */
.va-stats-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.va-stats-btn-primary {
    background: var(--va-gold);
    color: white;
}

.va-stats-btn-primary:hover {
    filter: brightness(0.95);
}

.va-stats-btn-danger {
    background: var(--va-danger);
    color: white;
}

.va-stats-btn-danger:hover {
    background: #dc2626;
}

.va-stats-btn-group {
    display: inline-flex;
    background: var(--va-gray-100);
    border-radius: 0.5rem;
    padding: 0.25rem;
}

.va-stats-range-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 0.375rem;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.va-stats-range-btn-active {
    background: var(--va-blue-night);
    color: white;
}

/* ========================================
   Tables
   ======================================== */
.va-stats-table-wrapper {
    margin-bottom: 1.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

.va-stats-table {
    width: 100%;
    font-size: 0.875rem;
    border-collapse: collapse;
}

.va-stats-table thead tr {
    border-bottom: 1px solid var(--va-gray-200);
    text-align: left;
    color: var(--va-gray-600);
}

.va-stats-table th,
.va-stats-table td {
    padding: 0.5rem 1rem 0.5rem 0;
    white-space: normal;   /* autorise le retour à la ligne */
    word-break: break-word; /* coupe les mots trop longs */
    overflow-wrap: anywhere; /* casse les mots très longs s’il le faut */
    vertical-align: middle;
    min-width: 90px;
}

.va-stats-table tbody tr {
    border-bottom: 1px solid var(--va-gray-100);
}

.va-stats-table tbody tr:last-child {
    border-bottom: none;
}

.va-stats-table td:first-child {
    font-weight: 500;
}

.va-stats-text-success {
    color: var(--va-success);
}

.va-stats-text-warning {
    color: var(--va-warning);
}

/* ========================================
   Charts
   ======================================== */
.va-stats-chart-box {
    margin-bottom: 1.5rem;
}

.va-stats-chart-label {
    font-size: 0.875rem;
    color: var(--va-gray-500);
    margin: 0 0 0.5rem;
}
 
#section-presence .va-stats-chart-box, #section-studytime .va-stats-chart-box {
    width: 100%;
    height: 300px; 
}
 
#section-presence .va-stats-chart-box canvas, #section-studytime .va-stats-chart-box canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* ========================================
   Grid Layouts
   ======================================== */
.va-stats-grid-layout {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 1fr;
}

.va-stats-grid-layout-2col {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 1fr;
}

@media (min-width: 1024px) {
    .va-stats-grid-layout {
        grid-template-columns: 2fr 1fr;
    }
    .va-stats-grid-layout-2col {
        grid-template-columns: 1fr 1fr;
    }
    #section-phrases .va-stats-grid-layout > .col-2 {
        border-left: 1px solid #e0e0e0;
        padding-left: 2rem;
    }
}

.va-stats-charts-group {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Chaque colonne prend bien l’espace défini */
.va-stats-grid-layout-2col > div {
  min-width: 0;
}

/* S’assure que les canvas ne débordent pas */
.va-stats-chart-box canvas {
  width: 100% !important;
  height: auto !important;
  max-width: 100%;
  display: block;
}

/* ========================================
   Progress Bar (Objectif quotidien)
   ======================================== */
.va-stats-progress-wrapper {
    margin-top: 0.75rem;
}

.va-stats-progress-track {
    height: 0.75rem;
    background: var(--va-gray-200);
    border-radius: 9999px;
    overflow: hidden;
    width: 100%;
}

.va-stats-progress-bar {
    height: 100%;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.va-stats-progress-bar.low {
    background: var(--va-danger);
}

.va-stats-progress-bar.medium {
    background: var(--va-warning);
}

.va-stats-progress-bar.high {
    background: var(--va-success);
}

/* ========================================
   Footer
   ======================================== */
.va-stats-footer {
    background: var(--va-blue-night);
    color: var(--va-gray-200);
    margin-top: 4rem;
}

.va-stats-footer-text {
    text-align: center;
    padding: 2rem 0;
    font-size: 0.875rem;
    color: var(--va-gray-500);
    margin: 0;
}

/* ========================================
   Responsive
======================================== */
@media (max-width: 768px) {
    .va-stats-page-title {
        font-size: 1.5rem;
    }
    
    .va-stats-section-header {
        flex-direction: column;
        align-items: flex-start;
        cursor: pointer;
    }

    .va-stats-section .va-stats-section-content {
        /*overflow: hidden;*/
        transition: max-height 0.3s ease;
    }

    .va-stats-section.open .va-stats-section-content {
        display: block;
    }
    
    .va-stats-kpis {
        grid-template-columns: 1fr;
    }

    #kpis {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    #kpis > div {
        grid-area: auto !important; /* On annule les placements 6-colonnes */
    }

    .va-stats-section .va-stats-section-header {
        cursor: pointer;
        position: relative;
        padding-right: 25px; /* espace pour l'icône */
    }

    .va-stats-section .va-stats-section-header::after {
        content: '▸';
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%) rotate(0deg);
        transition: transform 0.3s ease;
        font-size: 1rem;
        color: #555;
    }

    .va-stats-section.open .va-stats-section-header::after {
        transform: translateY(-50%) rotate(90deg);
    }
}

/* ========================================
   Animations confetti (gardées telles quelles)
   ======================================== */
@keyframes confetti-fall {
    0% {
        transform: translateY(-10px) rotate(0deg);
        opacity: 0.9;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.confetti-piece {
    position: fixed;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    pointer-events: none;
    animation: confetti-fall linear forwards;
}

/* ========================================
   My Progress
   ======================================== */
.va-my-progress { 
    padding: 1.5rem; 
    margin: 2rem 0; 
}
.va-my-progress h3 {
    margin: 0 0 1rem;
    font-size: 1.25rem;
}
.va-progress-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); 
    gap: 1rem; 
}
.va-progress-item { 
    text-align: center; 
    padding: 1rem;
    font-weight: 600;
}
.va-login-required {
    padding: 1rem;
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    border-radius: 0.375rem;
}

/* ========================================
   Leaderboard
   ======================================== */
/*.va-leaderboard { 
    margin: 2rem 0; 
    background: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.va-leaderboard h3 {
    margin: 0 0 1rem;
    font-size: 1.5rem;
}
.va-leaderboard-table { 
    width: 100%; 
    border-collapse: collapse; 
}
.va-leaderboard-table th,
.va-leaderboard-table td { 
    padding: 0.75rem; 
    text-align: left; 
    border-bottom: 1px solid #e5e7eb; 
}
.va-leaderboard-table th { 
    background: #f3f4f6; 
    font-weight: 600; 
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.va-leaderboard-table tbody tr:hover {
    background: #f9fafb;
}
.va-leaderboard-table .va-rank {
    font-size: 1.25rem;
    font-weight: bold;
}
.va-top-1 { background: rgba(255, 215, 0, 0.1) !important; }
.va-top-2 { background: rgba(192, 192, 192, 0.1) !important; }
.va-top-3 { background: rgba(205, 127, 50, 0.1) !important; }*/
.va-leaderboard-wrapper {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.va-profile {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background: #fff;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

.va-profile-card {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.va-profile-avatar {
    border: 4px solid var(--color-gold);
    border-radius: 9999px;
    width: 6rem;
    height: 6rem;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem;
    box-shadow: var(--shadow-md);
}

.va-profile-info>* {
    margin: 0;
}

.va-profile-stats {
    font-size: 0.975rem;
    color: var(--color-gray-500);
}

.va-profile-rank {
    margin-left: auto;
    text-align: center;
}

.va-profile-rank-number, .va-profile-metric > strong {
    font-size: 2.25rem;
    font-weight: 700
}

.va-profile-rank-label, .va-profile-metric > span {
    font-size: 0.875rem;
    color: var(--va-gray-500);
}

.va-profile-metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    margin-top: 1rem;
    gap: 1rem;
}

.va-profile-metrics div {
    text-align: center;
    background: #f1f5f9;
    border-radius: 10px;
    padding: 0.75rem;
}

.va-ranking {
    margin-top: 3rem;
}

.va-ranking-header {
    margin-bottom: 2rem;
}

/* CONTENEUR FILTRES */
.va-period-filters {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 16px;
    max-width: 640px;
    margin: 0 auto 24px;
}

/* BOUTONS */
.va-period-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.va-btn {
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    border: 1px solid var(--color-gray-200);
    background: transparent;
    color: var(--color-gray-700);
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.va-btn-active {
    border: 1px solid var(--color-gold);
    background: var(--color-gold);
    color: var(--color-white);
}

.va-btn:hover {
    border: 1px solid var(--color-gold);
    color: var(--color-gold);
}

.va-btn-active:hover {
    color: var(--color-white);
}

/* BOUTON ACTIF */
.va-btn-active {
    background: var(--color-gold);
    color: var(--color-white);
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(var(--color-gold), 0.4);
}

/* LOADER */
.va-loader {
    text-align: center;
    padding: 32px 0;
}

.va-loader-text {
    margin-top: 8px;
    color: var(--color-gray-600);
    font-size: 14px;
}

/* SPINNER */
.va-spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid rgba(var(--color-gold), 0.3);
    border-bottom-color: var(--color-gold);
    animation: va-spin 0.8s linear infinite;
}

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

.va-ranking-wrapper {
    border-radius: var(--radius-md);
    background: #fff;
    box-shadow: var(--shadow-md);
}

/* POIDUM */
.va-podium-wrapper {
    padding: 2rem;
}

.va-podium {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2.5rem;
    margin-bottom: 2rem;
}

.va-podium-item.va-podium-2 {
    background-image: linear-gradient(to right bottom, rgb(209, 213, 219), rgb(156, 163, 175));
}

.va-podium-item.va-podium-3 {
    background-image: linear-gradient(to right bottom, rgb(217, 119, 6), rgb(180, 83, 9));
}

.va-podium-item {
    background: #fff;
    border-radius: 16px;
    padding: 1rem;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.va-podium-item.va-podium-1 {
    transform: translateY(-1rem);
}

.va-podium-rank, .va-podium-avatar {
    margin-bottom: 0.75rem;
}

.va-podium-avatar img {
    padding: 10px;
}

.va-podium-item.va-podium-1 .va-podium-avatar img {
    border: 4px solid var(--color-gold);
}

.va-podium-name {
    font-size: 1.125rem;
    line-height: 1.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.va-podium-item:not(:nth-child(2)) .va-podium-name,
.va-podium-item:not(:nth-child(2)) .va-podium-xp {
    color: #fff;
}

.va-podium-rank img {
    font-size: 3rem;
    line-height: 1;
}

.va-podium-1 .va-podium-rank img {
    font-size: 3.75rem;
}

.va-podium-xp {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    background-color: rgb(255 255 255 / 0.3);
    border-radius: .5rem;
    font-weight: 700;
    font-size: 1.5rem;
    line-height: 2rem;
}

/* TABLEAU CLASSEMENT */
.va-ranking-table {
    width: 100%;
    margin-bottom: 2rem;
    border-spacing: 0;
    border-collapse: separate;
    text-align: center;
}

.va-ranking-table thead, .va-ranking-table tfoot {
    background-color: rgb(249 250 251);
}

.va-ranking-table tbody td, .va-ranking-table tfoot {
    border-top: 1px solid #e5e7eb;
}

.va-ranking-table td, .va-ranking-table th {
    padding: 1rem 1.5rem;
}

.va-ranking-table .va-ranking-row.is-current {
    transform: scale(1.05);
    background: #fff;
    font-size: 1.2em;
}

.va-ranking-table .va-ranking-row.is-current td {
    border-bottom: 1px solid #e5e7eb;
}

.va-ranking-rank {
    color: #9ca3af;
    font-size: 1.125rem;
    line-height: 1.75rem;
    font-weight: 700;
}

.va-ranking-row.is-current .va-ranking-rank {
    color: var(--color-gray-900);
    font-size: var(--space-xl);
}

.va-ranking-user-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1em;
}

.va-ranking-username .va-badge {
    background: #f59e0b;
    color: #fff;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    margin-left: 0.5rem;
}

.va-avatar-img-small {
    border-radius: 50%;
}

.va-ranking-xp {
    font-size: 1.125rem;
    line-height: 1.75rem;
    font-weight: 700;
}

.va-ranking-table tfoot a {
    font-size: var(--space-md);
}

/* ========================================
   Study Time
   ======================================== */
.va-empty-state {
    text-align: center;
    color: #6b7280;
    padding: 40px 20px;
    font-size: 16px;
}
/* Notifications */
.va-notif {
    padding: 12px 16px;
    border-radius: 8px;
    margin: 16px 0;
    font-size: 14px;
}

.va-notif-success {
    background-color: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
}

.va-notif-warning {
    background-color: #fef3c7;
    color: #92400e;
    border-left: 4px solid #f59e0b;
}

.va-notif-info {
    background-color: #dbeafe;
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}

.va-tracker-status {
    background: #f3f4f6;
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    transition: all 0.3s ease;
}

.va-tracker-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: #374151;
}

.va-tracker-dot {
    width: 10px;
    height: 10px;
    background: #10b981;
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

.va-tracker-status.paused {
    background: #fee2e2;
}

.va-tracker-status.paused .va-tracker-dot {
    background: #ef4444;
    animation: none;
}

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

.va-btn-secondary {
    background: white;
    border: 1px solid #d1d5db;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.va-btn-secondary:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.va-btn-secondary.va-study-paused {
    background: #10b981;
    color: white;
    border-color: #10b981;
}

.va-btn-secondary.va-study-paused:hover {
    background: #059669;
    border-color: #059669;
}