/* ---------- Thème ---------- */
:root {
    --bg: #f4f5fa;
    --surface: #ffffff;
    --surface-2: #f0f2f8;
    --border: #e2e5ef;
    --text: #1b2140;
    --muted: #68708c;
    --accent: #3b4fd8;
    --accent-hover: #2f40b8;
    --accent-soft: #e8ebfd;
    --on-accent: #ffffff;
    --gold: #f5b301;
    --gold-soft: #fff3cc;
    --gold-text: #6b4a00;
    --danger: #c9304a;
    --danger-soft: #fde8ec;
    --success: #17794c;
    --success-soft: #e2f5ea;
    --sidebar: #141a3a;
    --sidebar-text: #c5cae6;
    --sidebar-active: #252d5c;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(20, 26, 58, .06), 0 4px 16px rgba(20, 26, 58, .05);
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0e1124;
        --surface: #171b34;
        --surface-2: #1f2443;
        --border: #2a3055;
        --text: #eceefa;
        --muted: #9aa1c2;
        --accent: #7c8cff;
        --accent-hover: #96a3ff;
        --accent-soft: #252c5c;
        --on-accent: #0e1124;
        --gold-soft: #453607;
        --gold-text: #ffd761;
        --danger: #ff7d92;
        --danger-soft: #3d1a24;
        --success: #5fd49b;
        --success-soft: #143325;
        --sidebar: #0a0d1d;
        --sidebar-active: #1c2247;
        --shadow: none;
    }
}

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; margin-bottom: 14px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.icon { width: 18px; height: 18px; flex: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Structure ---------- */
body.app {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 22px 14px;
    background: var(--sidebar);
    color: var(--sidebar-text);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px;
    color: #fff;
}
.brand:hover { text-decoration: none; }
.brand__mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--gold);
    color: #1b2140;
    font-weight: 800;
    font-size: 1.1rem;
}
.brand__text { font-weight: 700; font-size: 1.1rem; line-height: 1.1; }
.brand__text small {
    display: block;
    font-weight: 500;
    font-size: .72rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    opacity: .65;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__title {
    margin: 18px 10px 6px;
    font-size: .7rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    opacity: .55;
}
.nav__link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: 9px;
    color: inherit;
    font-weight: 500;
}
.nav__count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--gold); color: #1b2140; font-size: .75rem; font-weight: 700; text-align: center; }
.nav__link:hover { background: var(--sidebar-active); color: #fff; text-decoration: none; }
.nav__link.is-active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }

.sidebar__user {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, .1);
}
.sidebar__identity { display: block; margin-bottom: 4px; padding: 8px 10px; border-radius: 9px; overflow: hidden; color: inherit; }
.sidebar__identity:hover, .sidebar__identity.is-active { background: var(--sidebar-active); text-decoration: none; }
.sidebar__identity strong { display: block; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__identity small { opacity: .65; }

.main {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 32px 32px 64px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.back { display: inline-block; margin-bottom: 6px; font-size: .9rem; }

.tabs { display: flex; gap: 6px; }
.tabs__link { padding: 7px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted); font-weight: 600; font-size: .9rem; }
.tabs__link:hover { text-decoration: none; color: var(--text); }
.tabs__link.is-active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ---------- Cartes ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}
.card--flush { padding: 0; overflow: hidden; }
.card--narrow { max-width: 560px; }
.card__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }

.eyebrow {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px 32px;
    flex-wrap: wrap;
}
.hero__actions { display: flex; gap: 10px; margin-left: auto; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat__label { color: var(--muted); font-size: .85rem; font-weight: 500; }
.stat__value { font-size: 2rem; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat__value--sm { font-size: 1.35rem; line-height: 1.6; }
.stat__hint { color: var(--muted); font-size: .85rem; }

/* ---------- Boules ---------- */
.draw { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.draw__sep { width: 1px; height: 22px; margin: 0 4px; background: var(--border); }

.ball {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.ball--star { background: var(--gold-soft); color: var(--gold-text); box-shadow: inset 0 0 0 2px var(--gold); }
.ball.is-hit { background: var(--accent); color: var(--on-accent); }
.ball--star.is-hit { background: var(--gold); color: #1b2140; }
.ball.is-miss { opacity: .4; }

.draw--sm { gap: 5px; }
.draw--sm .ball { width: 30px; height: 30px; font-size: .82rem; }
.draw--sm .draw__sep { height: 16px; margin: 0 3px; }
.draw--lg { gap: 10px; }
.draw--lg .ball { width: 56px; height: 56px; font-size: 1.3rem; }
.draw--lg .draw__sep { height: 32px; margin: 0 6px; }

/* ---------- Boutons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--danger { color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn--sm { padding: 5px 10px; font-size: .85rem; border-radius: 8px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge--accent { background: var(--accent-soft); color: var(--accent); }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Formulaires ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.form__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > legend { padding: 0; color: var(--muted); font-size: .85rem; font-weight: 600; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"], select {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
input:focus-visible, select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

.field--check { flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 10px; }
.field--check > label { color: var(--text); font-weight: 500; }
.field--choices > div { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.field--choices > div label { margin-right: 14px; }

/* Erreurs et aides rendues par le thème de formulaire Symfony */
.field ul, .form > ul { margin: 0; padding: 0; list-style: none; color: var(--danger); font-size: .85rem; }
.help-text, .field [id$="_help"] { color: var(--muted); font-size: .82rem; }

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    align-items: end;
    padding: 18px 22px;
}
.filters__actions { display: flex; gap: 8px; grid-column: 1 / -1; }
.filters--inline { padding: 14px 0 8px; }
.field--wide { grid-column: span 2; }

/* ---------- Résultat du générateur ---------- */
.result { display: flex; align-items: center; justify-content: space-between; gap: 20px 32px; flex-wrap: wrap; }
.result__head { flex: 1 1 280px; display: flex; flex-direction: column; gap: 4px; }
.result__grids { display: flex; flex-direction: column; gap: 10px; }
.result--multi { align-items: flex-start; }
.result--multi .result__grids { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); flex: 1 1 100%; gap: 12px 24px; }
.result__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.card.is-active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 12px; text-align: left; vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: 22px; }
.table th:last-child, .table td:last-child { padding-right: 22px; }
.table th.num, .table td.num { text-align: right; white-space: nowrap; }
.table thead th {
    background: var(--surface-2);
    color: var(--muted);
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
}
.table tbody tr + tr td { border-top: 1px solid var(--border); }
.table tbody tr:hover td { background: var(--surface-2); }
.card:not(.card--flush) .table th, .card:not(.card--flush) .table td { padding-left: 0; }
.card:not(.card--flush) .table tbody tr:hover td { background: none; }

.table .draw { flex-wrap: nowrap; }
.table tr.is-reference td { background: var(--accent-soft); }
.notes { margin: 0; padding-left: 18px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.notes strong { color: var(--text); }
.table td .sub { display: block; color: var(--muted); font-size: .82rem; }
.table td.detail { color: var(--muted); font-size: .9rem; }

.actions { text-align: right; white-space: nowrap; }
.actions form { display: inline; }
.actions > * + * { margin-left: 6px; }

.empty { padding: 28px 22px; color: var(--muted); text-align: center; }
p.empty { padding: 12px 0 0; text-align: left; }

/* ---------- Classements (paires, triplets) ---------- */
.rank { margin: 0; padding: 0; list-style: none; }
.rank li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.rank li + li { border-top: 1px solid var(--border); }
.rank__count { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Méthodes du générateur ---------- */
.methods { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.method { display: flex; flex-direction: column; gap: 6px; color: var(--text); transition: border-color .15s, transform .15s; }
.method:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); }
.method.is-active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.method span { color: var(--muted); font-size: .9rem; }

/* ---------- Messages ---------- */
.alert { padding: 12px 16px; border-radius: 10px; border: 1px solid transparent; font-weight: 500; }
.alert--success { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.alert--info { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.alert--error, .alert--danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

/* ---------- Pagination (KnpPaginator) ---------- */
.pagination { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; font-variant-numeric: tabular-nums; }
.pagination > span > a, .pagination > .current, .pagination > .dots {
    display: inline-grid;
    place-items: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border-radius: 9px;
    font-weight: 600;
}
.pagination > span > a { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.pagination > span > a:hover { background: var(--surface-2); text-decoration: none; }
.pagination > .current { background: var(--accent); color: var(--on-accent); }

/* ---------- Connexion / inscription ---------- */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth__card {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.brand--auth { padding: 0; margin-bottom: 8px; color: var(--text); }
.auth__alt { color: var(--muted); font-size: .9rem; text-align: center; }

/* ---------- Petits écrans ---------- */
@media (max-width: 860px) {
    body.app { display: block; }
    .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 8px; padding: 10px 12px; overflow-x: auto; }
    .brand__text, .nav__title, .sidebar__identity { display: none; }
    .nav { flex-direction: row; }
    .nav__link { white-space: nowrap; }
    .nav__link.is-active { box-shadow: inset 0 -3px 0 var(--gold); }
    .sidebar__user { margin: 0 0 0 auto; padding: 0; border: 0; }
    .main { padding: 20px 16px 48px; }
    .table th, .table td { padding: 10px 14px; }
    .draw--lg .ball { width: 44px; height: 44px; font-size: 1.05rem; }
    .hero__actions { margin-left: 0; }
}

/* ---------- Graphiques (page Statistiques) ---------- */
.chart__lead { margin: -8px 0 18px; font-size: .9rem; }

.chart { display: flex; gap: 8px; --bar: var(--accent); }
.chart--etoiles { --bar: var(--gold); }
.chart__scale {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    /* Hauteur du tracé plus une demi-ligne de chaque côté : chaque libellé est centré sur sa ligne de grille */
    height: 216px;
    margin-top: -8px;
    color: var(--muted);
    font-size: .72rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
    line-height: 16px;
}
.chart__body { flex: 1; min-width: 0; }
.chart__plot {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 200px;
    border-bottom: 1px solid var(--border);
    background: repeating-linear-gradient(to bottom, var(--border) 0 1px, transparent 1px calc(100% / var(--lignes)));
}
.chart__col { flex: 1; display: flex; align-items: flex-end; justify-content: center; height: 100%; min-width: 0; }
.chart__bar { position: relative; width: 100%; max-width: 22px; min-height: 1px; border-radius: 4px 4px 0 0; background: var(--bar); }
.chart__col:hover .chart__bar { filter: brightness(1.15); }
.chart__value {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding-bottom: 2px;
    color: var(--text);
    font-size: .72rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.chart__mean { position: absolute; z-index: 1; left: 0; right: 0; border-top: 1px dashed var(--muted); pointer-events: none; }
.chart__mean span { position: absolute; right: 0; bottom: 2px; padding: 0 4px; border-radius: 4px; background: var(--surface); color: var(--muted); font-size: .72rem; }
.chart__axis { display: flex; gap: 2px; margin-top: 4px; color: var(--muted); font-size: .68rem; font-variant-numeric: tabular-nums; }
.chart__axis span { flex: 1; min-width: 0; text-align: center; }

.heatmap-wrap { overflow-x: auto; }
.heatmap {
    display: grid;
    grid-template-columns: 22px repeat(50, minmax(13px, 1fr));
    gap: 1px;
    min-width: 720px;
    max-width: 900px;
}
.heatmap__label { color: var(--muted); font-size: .68rem; line-height: 1; text-align: center; align-self: center; font-variant-numeric: tabular-nums; }
.heatmap__cell { aspect-ratio: 1; border-radius: 2px; background: color-mix(in oklab, var(--accent) calc(var(--t) * 100%), var(--surface-2)); }
.heatmap__cell--vide { background: none; }
.heatmap__cell:hover { outline: 2px solid var(--text); outline-offset: -1px; }
.heatmap__legend { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; color: var(--muted); font-size: .8rem; }
.heatmap__ramp { width: 160px; height: 10px; border-radius: 5px; background: linear-gradient(to right in oklab, var(--surface-2), var(--accent)); }

.tip {
    position: fixed;
    z-index: 100;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--text);
    color: var(--bg);
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
}

.data summary { cursor: pointer; font-weight: 600; }
.data__tables { margin-top: 16px; align-items: start; }
.data__tables .table + .table { margin-top: 24px; }
