/* ========================================
   PAGE STATISTIQUES : dashboard
   Fond gris très clair pour faire ressortir les cartes blanches.
======================================== */
.page-dashboard {
    --bg: var(--bg-subtle);
}

.page-dashboard .site-header {
    background: rgba(248, 250, 252, 0.85);
}

.dashboard {
    padding-top: 32px;
}

/* En-tête : titre à gauche, sélecteur à droite */
.dash-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px 32px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.dash-title {
    min-width: 0;
}

/* Sélecteur de stratégie (contrôle segmenté) */
.segmented {
    display: inline-flex;
    padding: 4px;
    gap: 2px;
    background: #EEF2F6;
    border-radius: 10px;
    overflow-x: auto;
    max-width: 100%;
}

.segment {
    min-width: 44px;
    padding: 6px 12px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-align: center;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.segment:hover {
    color: var(--text);
}

.segment.is-active {
    background: var(--surface);
    color: var(--brand);
    box-shadow: var(--shadow);
}

/* Indicateurs clés */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(9, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.kpi {
    position: relative;
    padding: 14px 12px 14px 14px;
    min-width: 0;
}

/* L'icône « i » est placée en haut à droite de la tuile : le libellé garde toute la largeur. */
.kpi-label {
    padding-right: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
}

/* Bureau : 9 cartes sur une ligne, les libellés longs passent sur deux lignes
   (hauteur réservée pour que les valeurs restent alignées). */
@media (min-width: 1200px) {
    .kpi-label {
        min-height: 2.6em;
        line-height: 1.3;
        white-space: normal;
        overflow-wrap: anywhere;
    }
}

/* Unité après un nombre (gagnés, perdus) : plus petite pour tenir dans la carte */
.kpi-unit {
    font-size: 13px;
    font-weight: 500;
}

.kpi-value {
    margin-top: 6px;
    font-size: 22px;
    line-height: 1.2;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
    white-space: nowrap;
}

/* Info-bulles */
.info-icon {
    position: absolute;
    top: 16px;
    right: 10px;
    width: 15px;
    height: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    font-size: 10px;
    font-weight: 600;
    font-style: normal;
    color: var(--subtle);
    cursor: help;
    flex-shrink: 0;
}

.tooltip-text {
    position: absolute;
    bottom: calc(100% + 8px);
    right: -8px;
    z-index: 20;
    width: 240px;
    padding: 10px 12px;
    background: var(--text);
    color: #FFFFFF;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
    white-space: normal;
    text-align: left;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
}

.info-icon:hover .tooltip-text,
.info-icon:focus .tooltip-text,
.info-icon.active .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* L'icône est à droite de la tuile : l'info-bulle s'ouvre vers la gauche,
   sauf sur la première tuile de chaque rangée, où elle sortirait de l'écran. */
.kpi:nth-child(9n+1) .tooltip-text {
    right: auto;
    left: -8px;
}

/* Rangées de cartes */
.dash-row {
    display: grid;
    gap: 16px;
    margin-bottom: 16px;
}

.dash-row--main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.dash-row--half { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dash-row--thirds { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.panel {
    padding: 20px;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.panel-head h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.panel-meta {
    font-size: 13px;
    color: var(--muted);
}

.chart {
    min-width: 0;
}

/* Carte « Résultats » : anneau + chiffre au centre */
.donut {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.donut > div:first-child {
    width: 100%;
}

.donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.donut-center strong {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.donut-center span {
    font-size: 12px;
    color: var(--muted);
}

.legend {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
    font-size: 13px;
    color: var(--muted);
}

.legend li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend strong {
    color: var(--text);
    font-weight: 600;
}

.legend--inline {
    margin: 0;
    gap: 14px;
    font-size: 12px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot--win { background: var(--brand); }
.dot--loss { background: var(--neg); }

/* Cartes tableau : le tableau va jusqu'aux bords de la carte */
.panel--table {
    padding: 0;
    overflow: hidden;
}

.panel--table .panel-head {
    padding: 16px 20px 0;
}

.panel-scroll {
    max-height: 380px;
    overflow: auto;
}

.data-table.compact th {
    padding: 8px 12px;
    font-size: 12px;
}

.data-table.compact td {
    padding: 8px 12px;
    font-size: 13px;
}

.data-table.compact th:first-child,
.data-table.compact td:first-child {
    padding-left: 20px;
}

.data-table.compact th:last-child,
.data-table.compact td:last-child {
    padding-right: 20px;
}

/* ========================================
   RESPONSIVE
======================================== */
@media (max-width: 1199px) {
    .kpi:nth-child(3n+1) .tooltip-text { right: auto; left: -8px; }
    .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .dash-row--thirds { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 800px) {
    .dashboard { padding-top: 24px; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .kpi-value { font-size: 20px; }
    .dash-row--main,
    .dash-row--half,
    .dash-row--thirds { grid-template-columns: minmax(0, 1fr); }
    .panel { padding: 16px; }
    .panel--table { padding: 0; }
    .tooltip-text { width: 200px; }
    .kpi:nth-child(odd) .tooltip-text { right: auto; left: -8px; }
    /* 9 cartes sur 2 colonnes : la dernière prend toute la largeur. */
    .kpi:last-child { grid-column: 1 / -1; }
}
