/* ===== VARIABLES — DARK MODE (défaut) ===== */
:root {
    --fond-body: #0f1117;
    --fond-carte: #1c2333;
    --fond-carte-hover: #232d42;
    --fond-sidebar: #161b26;
    --fond-entete: #161b26;
    --fond-graphique: rgba(0, 0, 0, 0.15);
    --texte-principal: #e8edf5;
    --texte-secondaire: #8b95a8;
    --texte-menu: #a0a8bc;
    --accent: #039ff4;
    --accent-fonce: #028df1;
    --accent-clair: rgba(3, 159, 244, 0.15);
    --accent-hover: rgba(3, 159, 244, 0.25);
    --lien-accent: #4fbcf7;
    --succes: #22c55e;
    --succes-fond: rgba(34, 197, 94, 0.15);
    --danger: #ef4444;
    --danger-fond: rgba(239, 68, 68, 0.15);
    --attention-fond: rgba(245, 158, 11, 0.15);
    --attention: #f59e0b;
    --bordure: #2a3347;
    --barre-grise: #3a4258;
    --ombre-carte: 0 8px 30px rgba(0, 0, 0, 0.35);
    --ombre-legere: 0 4px 16px rgba(0, 0, 0, 0.25);
    --sidebar-largeur: 250px;
    --espacement: 20px;
    --rayon: 20px;
    --rayon-petit: 12px;
}

/* ===== THÈME CLAIR — activé quand la checkbox est cochée ===== */
html:has(#bascule-theme:checked) {
    --fond-body: #eceef6;
    --fond-carte: #ffffff;
    --fond-carte-hover: #f5f6fb;
    --fond-sidebar: #ffffff;
    --fond-entete: #ffffff;
    --fond-graphique: #f0f2f8;
    --texte-principal: #1a1d2e;
    --texte-secondaire: #8b93a8;
    --texte-menu: #6b7289;
    --accent-clair: rgba(3, 159, 244, 0.12);
    --accent-hover: rgba(3, 159, 244, 0.1);
    --lien-accent: #028df1;
    --succes-fond: #dcfce7;
    --danger-fond: #fee2e2;
    --attention-fond: #fef3c7;
    --bordure: #e8ebf3;
    --barre-grise: #e2e5ef;
    --ombre-carte: 0 8px 30px rgba(26, 29, 46, 0.06);
    --ombre-legere: 0 4px 16px rgba(26, 29, 46, 0.04);
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Manrope", sans-serif;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--texte-principal);
    background-color: var(--fond-body);
    display: grid;
    grid-template-columns: var(--sidebar-largeur) 1fr;
    min-height: 100vh;
}

h1, h2 {
    margin: 0;
    font-weight: 600;
}

ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Accessibilité */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.lien-evitement {
    position: absolute;
    top: -100%;
    left: var(--espacement);
    z-index: 300;
    padding: 0.6rem 1rem;
    background: var(--accent);
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
    border-radius: var(--rayon-petit);
    transition: top 0.2s ease;
}

.lien-evitement:focus {
    top: var(--espacement);
}

/* .bascule-sidebar et .bascule-theme : masquées via .sr-only dans le HTML */

/* Bouton thème — icône lune (sombre) / soleil (clair) */
.bouton-theme {
    cursor: pointer;
}

.icone-theme-clair {
    display: none;
}

html:has(#bascule-theme:checked) .icone-theme-sombre {
    display: none;
}

html:has(#bascule-theme:checked) .icone-theme-clair {
    display: inline;
}

/* ===== SIDEBAR ===== */
.barre-laterale {
    background-color: var(--fond-sidebar);
    border-right: 1px solid var(--bordure);
    padding: 1.5rem 1.25rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 120;
    display: flex;
    flex-direction: column;
}

.barre-laterale-entete {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 0.5rem 1.5rem;
}

.logo-icone img {
    display: block;
    width: 28px;
    height: 28px;
}

.logo-texte {
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--texte-principal);
}

.logo-texte span {
    color: var(--accent);
}

.menu-section {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--texte-secondaire);
    margin: 1.25rem 0 0.5rem;
    padding: 0 0.75rem;
}

.menu-section:first-of-type {
    margin-top: 0;
}

.menu-lateral ul {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.menu-lateral a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.7rem 0.85rem;
    border-radius: var(--rayon-petit);
    color: var(--texte-menu);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.88rem;
    transition: background-color 0.25s ease, color 0.25s ease;
}

.menu-lateral a:hover {
    background-color: var(--accent-clair);
    color: var(--accent);
}

.menu-lateral a.actif,
.menu-lateral a[aria-current="page"] {
    background-color: var(--accent);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(3, 159, 244, 0.35);
}

.icone-menu {
    font-size: 1.05rem;
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

.icone-liste {
    margin-right: 6px;
    color: var(--accent);
    font-size: 0.9rem;
}

.carte-upgrade {
    margin-top: auto;
    background: linear-gradient(145deg, #0d0f18, #1a1f35);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    padding: 1.25rem;
    color: #ffffff;
}

.carte-upgrade p {
    margin: 0 0 1rem;
    font-size: 0.82rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.8);
}

.bouton-upgrade {
    display: inline-block;
    background-color: var(--accent);
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.6rem 1.2rem;
    border-radius: 50px;
    transition: background-color 0.25s ease, transform 0.25s ease;
}

.bouton-upgrade:hover {
    background-color: var(--accent-fonce);
    transform: translateY(-2px);
}

.overlay-sidebar {
    display: none;
}

/* ===== ZONE PRINCIPALE (Flexbox colonne) ===== */
.principal {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* ===== HEADER STICKY ===== */
.barre-haute {
    display: flex;
    align-items: center;
    gap: var(--espacement);
    padding: 1.5rem var(--espacement) 0.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--fond-body);
}

.bouton-sidebar {
    display: none;
    background: var(--fond-carte);
    border: 1px solid var(--bordure);
    color: var(--texte-principal);
    font-size: 1.2rem;
    padding: 0.4rem 0.65rem;
    border-radius: var(--rayon-petit);
    cursor: pointer;
}

.barre-haute-titre h1 {
    font-size: 1.6rem;
    font-weight: 700;
}

.barre-haute-titre p {
    margin: 0.15rem 0 0;
    color: var(--texte-secondaire);
    font-size: 0.85rem;
}

.barre-haute-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.bouton-icone {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--bordure);
    background: var(--fond-carte);
    cursor: pointer;
    font-size: 1.05rem;
    color: var(--texte-menu);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: box-shadow 0.25s ease, color 0.25s ease, background-color 0.25s ease;
    position: relative;
}

.bouton-icone:hover {
    box-shadow: var(--ombre-legere);
    color: var(--accent);
    background-color: var(--fond-carte-hover);
}

.bouton-notif .point-notif {
    position: absolute;
    top: 8px;
    right: 9px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--fond-carte);
}

.profil-utilisateur {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 8px;
}

.profil-nom {
    font-weight: 600;
    font-size: 0.88rem;
    display: block;
    text-align: right;
}

.profil-role {
    font-size: 0.75rem;
    color: var(--texte-secondaire);
    display: block;
    text-align: right;
}

.profil-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center top;
    flex-shrink: 0;
    display: block;
}

/* ===== MAIN CONTENT — Grid 4 colonnes (énoncé) ===== */
.contenu {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--espacement);
    padding: var(--espacement);
}

.statistiques,
.grille-graphiques,
.tableau-donnees {
    grid-column: 1 / -1;
}

/* ===== STATS ===== */
.statistiques {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--espacement);
}

.carte-stat {
    background-color: var(--fond-carte);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    padding: 1.25rem;
    box-shadow: var(--ombre-carte);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
}

.carte-stat:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    background-color: var(--fond-carte-hover);
}

.carte-stat.vedette {
    background: linear-gradient(135deg, var(--accent), #6b84ff);
    border-color: transparent;
    color: #ffffff;
}

.carte-stat.vedette:hover {
    background: linear-gradient(135deg, var(--accent-fonce), #5a75f0);
}

.carte-stat-haut {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.carte-stat-icone {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent-clair);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    color: var(--accent);
}

.carte-stat.vedette .carte-stat-icone {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.carte-stat h2 {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--texte-secondaire);
    margin-bottom: 0.35rem;
}

.carte-stat.vedette h2 {
    color: rgba(255, 255, 255, 0.85);
}

.carte-stat-valeur {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.carte-stat-sous-texte {
    font-size: 0.75rem;
    color: var(--texte-secondaire);
    margin-top: 0.25rem;
    display: block;
}

.carte-stat.vedette .carte-stat-sous-texte {
    color: rgba(255, 255, 255, 0.75);
}

.pastille {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 50px;
}

.pastille.positive {
    background: var(--succes-fond);
    color: var(--succes);
}

.pastille.negative {
    background: var(--danger-fond);
    color: var(--danger);
}

.pastille-claire.positive {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

/* ===== GRILLE GRAPHIQUES ===== */
.grille-graphiques {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: var(--espacement);
}

.carte-graphique {
    background: var(--fond-carte);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    padding: 1.25rem;
    box-shadow: var(--ombre-carte);
    transition: box-shadow 0.3s ease;
}

.carte-graphique:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.carte-graphique h2 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.carte-graphique-entete {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.carte-graphique-entete h2 {
    margin-bottom: 0;
}

.selecteur {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--bordure);
    border-radius: 8px;
    background: var(--fond-body);
    font-family: inherit;
    font-size: 0.8rem;
    color: var(--texte-secondaire);
    cursor: pointer;
}

.colonne-droite {
    display: flex;
    flex-direction: column;
    gap: var(--espacement);
}

.graphique-barres {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 6px;
    height: 200px;
    padding: 0 0.5rem;
    background: var(--fond-graphique);
    border-radius: var(--rayon-petit);
}

.groupe-barres {
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    height: 100%;
    position: relative;
    padding-bottom: 1.5rem;
}

.barre {
    width: 12px;
    height: var(--h);
    border-radius: 6px 6px 0 0;
    transition: opacity 0.3s ease;
}

.barre-grise {
    background: var(--barre-grise);
}

.barre-bleue {
    background: var(--accent);
}

.groupe-barres:hover .barre {
    opacity: 0.85;
}

.mois {
    position: absolute;
    bottom: 0;
    font-size: 0.7rem;
    color: var(--texte-secondaire);
}

.legende-graphique {
    display: flex;
    gap: 1.25rem;
    margin-top: 1rem;
    font-size: 0.78rem;
    color: var(--texte-secondaire);
}

.point-legende {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}

.point-legende.gris { background: var(--barre-grise); }
.point-legende.bleu { background: var(--accent); }

/* ===== Cours récents — carrousel CSS pur (radio + :checked) ===== */
.cours-recents {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--bordure);
}

.cours-recents-entete {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.85rem;
}

.cours-recents-entete h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--texte-principal);
}

.cours-recents-entete p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--texte-secondaire);
}

.carrousel {
    position: relative;
}

.carrousel-radio {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.carrousel-fenetre {
    overflow: hidden;
    border-radius: var(--rayon-petit);
    border: 1px solid var(--bordure);
    background: var(--fond-graphique);
}

.carrousel-piste {
    display: flex;
    width: 300%;
    transition: transform 0.45s ease;
}

.carrousel-slide {
    margin: 0;
    width: calc(100% / 3);
    position: relative;
    flex-shrink: 0;
}

.carrousel-slide img {
    display: block;
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.carrousel-slide figcaption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0.85rem 1rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
    color: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.carrousel-slide figcaption strong {
    font-size: 1rem;
}

.carrousel-slide figcaption span {
    font-size: 0.75rem;
    opacity: 0.85;
}

#cours-1:checked ~ .carrousel-fenetre .carrousel-piste {
    transform: translateX(0);
}

#cours-2:checked ~ .carrousel-fenetre .carrousel-piste {
    transform: translateX(-33.333%);
}

#cours-3:checked ~ .carrousel-fenetre .carrousel-piste {
    transform: translateX(-66.666%);
}

.carrousel-commandes {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.85rem;
}

.carrousel-point {
    display: block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--barre-grise);
    cursor: pointer;
    transition: background 0.25s ease, transform 0.25s ease;
}

.carrousel-point:hover {
    transform: scale(1.15);
}

#cours-1:checked ~ .carrousel-commandes label[for="cours-1"],
#cours-2:checked ~ .carrousel-commandes label[for="cours-2"],
#cours-3:checked ~ .carrousel-commandes label[for="cours-3"] {
    background: var(--accent);
    transform: scale(1.2);
}

.contenu-anneau {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.anneau-donut {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: conic-gradient(
        var(--accent) 0deg 140deg,
        #ef4444 140deg 220deg,
        #93b4ff 220deg 300deg,
        var(--barre-grise) 300deg 360deg
    );
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.anneau-donut::before {
    content: "";
    position: absolute;
    width: 95px;
    height: 95px;
    background: var(--fond-carte);
    border-radius: 50%;
}

.anneau-centre {
    position: relative;
    z-index: 1;
    text-align: center;
    font-size: 0.65rem;
    color: var(--texte-secondaire);
}

.anneau-centre strong {
    display: block;
    font-size: 1rem;
    color: var(--texte-principal);
}

.liste-produits {
    width: 100%;
}

.liste-produits li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--bordure);
    font-size: 0.82rem;
}

.liste-produits li:last-child {
    border-bottom: none;
}

.nom-produit {
    color: var(--texte-menu);
}

.valeur-produit {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.valeur-produit .pastille {
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
}

.contenu-bulles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: center;
}

.zone-bulles {
    position: relative;
    height: 140px;
    background: var(--accent-clair);
    border-radius: var(--rayon-petit);
}

.bulle {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: var(--s);
    height: var(--s);
    border-radius: 50%;
    background: rgba(3, 159, 244, 0.35);
    transform: translate(-50%, -50%);
}

.bulle-forte {
    background: rgba(3, 159, 244, 0.65);
}

.liste-pays li {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 0.6rem;
    font-size: 0.78rem;
}

.barre-progression {
    height: 6px;
    background: var(--bordure);
    border-radius: 50px;
    overflow: hidden;
}

.barre-progression span {
    display: block;
    height: 100%;
    width: var(--w);
    background: var(--accent);
    border-radius: 50px;
}

/* ===== TABLEAU ===== */
.tableau-donnees {
    background: var(--fond-carte);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    padding: 1.25rem;
    box-shadow: var(--ombre-carte);
}

.tableau-entete {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.tableau-entete h2 {
    font-size: 0.95rem;
}

.lien-voir-tout {
    color: var(--lien-accent);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}

.lien-voir-tout:hover {
    text-decoration: underline;
}

.tableau-conteneur {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    color: var(--texte-secondaire);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--bordure);
    white-space: nowrap;
}

tbody td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--bordure);
    vertical-align: middle;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr {
    transition: background-color 0.2s ease;
}

tbody tr:hover {
    background-color: var(--accent-clair);
}

.cours-cellule {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    white-space: nowrap;
}

.cours-cellule img {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    object-fit: contain;
}

th:nth-child(4),
td:nth-child(4) { text-align: right; }
th:nth-child(5),
td:nth-child(5) { text-align: center; }
th:nth-child(6),
td:nth-child(6) { text-align: right; }

.badge {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 600;
}

.badge-succes {
    background: var(--succes-fond);
    color: var(--succes);
}

.badge-attente {
    background: var(--attention-fond);
    color: var(--attention);
}

.badge-annule {
    background: var(--danger-fond);
    color: var(--danger);
}

/* ===== FOOTER ===== */
.pied-page {
    padding: 1rem var(--espacement);
    text-align: center;
    border-top: 1px solid var(--bordure);
    background-color: var(--fond-entete);
}

.pied-page p {
    margin: 0;
    font-size: 0.78rem;
    color: var(--texte-secondaire);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .grille-graphiques {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1023px) {
    .contenu {
        grid-template-columns: repeat(2, 1fr);
    }

    .statistiques {
        grid-template-columns: repeat(2, 1fr);
    }

    .profil-texte {
        display: none;
    }
}

@media (max-width: 767px) {
    body {
        grid-template-columns: 1fr;
    }

    .bouton-sidebar {
        display: block;
    }

    .barre-laterale {
        position: fixed;
        top: 0;
        left: 0;
        width: var(--sidebar-largeur);
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: var(--ombre-carte);
    }

    .overlay-sidebar {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 110;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        cursor: pointer;
    }

    .bascule-sidebar:checked ~ .barre-laterale {
        transform: translateX(0);
    }

    .bascule-sidebar:checked ~ .overlay-sidebar {
        opacity: 1;
        visibility: visible;
    }

    .contenu {
        grid-template-columns: 1fr;
    }

    .statistiques {
        grid-template-columns: 1fr;
    }

    .barre-haute-titre h1 {
        font-size: 1.2rem;
    }

    .contenu-bulles {
        grid-template-columns: 1fr;
    }
}
