/*
 * eMédissance — deux thèmes :
 *  - défaut  : moderne, doux, arrondi (Nunito) — NES.css n'est PAS chargé
 *  - rétro   : 8-bit NES.css (Press Start 2P) — activé via data-theme="retro"
 *
 * Les templates n'utilisent que le vocabulaire NES (nes-btn, nes-container,
 * nes-table, nes-icon…) : le thème par défaut réinterprète ces classes.
 */

/* ======================================================================
   Layout commun aux deux thèmes
   ====================================================================== */

* { box-sizing: border-box; }

body { margin: 0; }

.container { max-width: 960px; margin: 0 auto; padding: 2rem 1rem 6rem; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin: .5rem 0 1.75rem;
    flex-wrap: wrap;
}

.navbar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: .9rem 1.5rem;
    flex-wrap: wrap;
}
.nav-links { display: flex; gap: 1.4rem; flex: 1; flex-wrap: wrap; }
.nav-right { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }

.balance-badge {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.nav-badge {
    display: inline-block;
    min-width: 1.3em;
    padding: .05em .35em;
    text-align: center;
    font-size: .72em;
    background: #e11d48;
    color: #fff;
    border-radius: 999px;
    vertical-align: super;
}
[data-theme="retro"] .nav-badge { border-radius: 0; background: #e76e55; }

.leaderboard-me td { background: rgba(99, 102, 241, .07); }
[data-theme="retro"] .leaderboard-me td { background: #fdf6d8; }
.balance-hero { display: flex; align-items: center; gap: .8rem; margin: 0; }

.card { margin-bottom: 1.75rem; overflow-x: auto; }
.card.narrow { max-width: 560px; }

.num { text-align: right; font-variant-numeric: tabular-nums; }

.form-row { margin-bottom: 1.4rem; }
label { display: block; margin-bottom: .45rem; }
.nes-choices { display: flex; flex-direction: column; gap: .5rem; }
.nes-choices label, label.nes-pointer { display: block; cursor: pointer; }
.form-errors { list-style: none; margin: .5rem 0 0; padding: 0; }
.checkbox-row label { display: block; }

.inline-form {
    display: flex;
    gap: .9rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.inline-form input[type="number"] { width: 220px; }

/* Formulaire de création de pari : grille compacte, radios en colonnes */
.bet-form .form-grid { display: grid; gap: 0 1.75rem; align-items: start; }
.bet-form .form-grid-2 { grid-template-columns: 1fr 1fr; }
.bet-form .form-grid-3 { grid-template-columns: 1fr 1fr 1.4fr; }
.bet-form .form-row { margin-bottom: 1rem; }
.bet-form .nes-choices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: .25rem 1rem;
}
.bet-form .form-checkboxes label { margin-bottom: .5rem; }
@media (max-width: 720px) {
    .bet-form .form-grid-2, .bet-form .form-grid-3 { grid-template-columns: 1fr; }
}

/* Saisie élément par élément (options, bornes) */
.item-list-add { display: flex; gap: .6rem; align-items: center; }
.item-list-add input { flex: 1; max-width: 340px; width: auto; }
.item-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    padding: 0;
    margin: .6rem 0 0;
}
.item-list li { display: inline-flex; align-items: center; gap: .45rem; }
.item-remove {
    cursor: pointer;
    border: none;
    background: none;
    font: inherit;
    padding: 0;
    line-height: 1;
}

/* Classement par glisser-déposer */
.ranking-dnd { width: 100%; }
.ranking-dnd ul {
    list-style: none;
    margin: .5rem 0 1rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-width: 460px;
}
.ranking-dnd li {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .55rem .9rem;
    cursor: grab;
    user-select: none;
}
.ranking-dnd li.is-dragging { opacity: .4; }
.ranking-dnd .rank-pos { font-weight: 700; min-width: 1.6rem; }
.ranking-dnd .rank-label { flex: 1; }
.ranking-dnd .rank-arrows { display: flex; gap: .3rem; }
.ranking-dnd .rank-arrows button {
    cursor: pointer;
    border: none;
    background: none;
    font: inherit;
    padding: .1rem .3rem;
    line-height: 1;
}

.tags { display: inline-flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.tag { white-space: nowrap; }

.bet-list, .penalty-list { list-style: none; margin: 0; padding: 0; }
.bet-list li, .penalty-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .9rem 0;
    flex-wrap: wrap;
}

.notifications {
    position: fixed;
    top: 5rem;
    right: 1rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: .8rem;
    max-width: 380px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

.theme-toggle {
    position: fixed;
    bottom: 3.25rem;
    right: 1.25rem;
    z-index: 90;
    text-decoration: none;
}

.invite-box { margin: 1.25rem 0; }
.invite-box code { display: block; margin-top: .6rem; word-break: break-all; }

/* ======================================================================
   Thème par défaut — moderne, doux, arrondi
   ====================================================================== */

html:not([data-theme="retro"]) {
    --text: #23263b;
    --muted: #767b93;
    --line: #e8eaf3;
    --primary: #6366f1;
    --primary-2: #8b5cf6;
    font-size: 16px;
}

html:not([data-theme="retro"]) body {
    font-family: 'Nunito', system-ui, -apple-system, sans-serif;
    background: linear-gradient(180deg, #f7f7fd 0%, #eef0fa 100%) fixed;
    color: var(--text);
    line-height: 1.6;
}

html:not([data-theme="retro"]) h1 { font-size: 1.7rem; font-weight: 800; margin: 0; }
html:not([data-theme="retro"]) a { color: var(--primary); }
html:not([data-theme="retro"]) .muted { color: var(--muted); }

/* Navbar en verre dépoli */
html:not([data-theme="retro"]) .navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, .82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(35, 38, 59, .07);
}
html:not([data-theme="retro"]) .navbar .brand {
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--text);
    text-decoration: none;
}
html:not([data-theme="retro"]) .nav-links a,
html:not([data-theme="retro"]) .nav-right a {
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
}
html:not([data-theme="retro"]) .nav-links a:hover,
html:not([data-theme="retro"]) .nav-right a:hover { color: var(--primary); }

html:not([data-theme="retro"]) .balance-badge {
    background: var(--text);
    color: #fbbf24;
    font-weight: 800;
    padding: .4rem .9rem;
    border-radius: 999px;
}

html:not([data-theme="retro"]) .balance-hero { font-size: 2.1rem; font-weight: 800; }
html:not([data-theme="retro"]) .balance-hero small { font-size: 1rem; color: var(--muted); font-weight: 600; }

/* Cartes */
html:not([data-theme="retro"]) .nes-container {
    background: #fff;
    border: 1px solid rgba(35, 38, 59, .06);
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(35, 38, 59, .07);
    padding: 1.5rem 1.75rem;
}
html:not([data-theme="retro"]) .nes-container > .title {
    display: block;
    font-size: 1.05rem;
    font-weight: 800;
    margin: 0 0 1rem;
    background: none;
    padding: 0;
}
html:not([data-theme="retro"]) .card-warning {
    background: #fffaf0;
    border-color: #fde5b8;
}
html:not([data-theme="retro"]) .auth-card { max-width: 480px; margin: 3.5rem auto; }
html:not([data-theme="retro"]) .auth-card form { margin: 1.5rem 0; }

/* Boutons : le thème moderne réutilise les classes NES (nes-btn, is-*) */
html:not([data-theme="retro"]) .nes-btn {
    display: inline-block;
    border: none;
    border-radius: 12px;
    padding: .6rem 1.25rem;
    font: inherit;
    font-weight: 700;
    color: var(--text);
    background: #eef0fa;
    cursor: pointer;
    text-decoration: none;
    transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
html:not([data-theme="retro"]) .nes-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
    box-shadow: 0 6px 16px rgba(35, 38, 59, .14);
}
html:not([data-theme="retro"]) .nes-btn.is-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, .35);
}
html:not([data-theme="retro"]) .nes-btn.is-success {
    background: linear-gradient(135deg, #10b981, #34d399);
    color: #fff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, .3);
}
html:not([data-theme="retro"]) .nes-btn.is-error {
    background: linear-gradient(135deg, #ef4444, #f87171);
    color: #fff;
    box-shadow: 0 4px 14px rgba(239, 68, 68, .3);
}

/* Champs de formulaire */
html:not([data-theme="retro"]) label { font-weight: 700; font-size: .95rem; }
html:not([data-theme="retro"]) .nes-input,
html:not([data-theme="retro"]) .nes-textarea,
html:not([data-theme="retro"]) .nes-select select {
    width: 100%;
    padding: .65rem .9rem;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    font: inherit;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: border-color .12s ease, box-shadow .12s ease;
}
html:not([data-theme="retro"]) .nes-input:focus,
html:not([data-theme="retro"]) .nes-textarea:focus,
html:not([data-theme="retro"]) .nes-select select:focus {
    border-color: var(--primary-2);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, .15);
}
html:not([data-theme="retro"]) .nes-checkbox,
html:not([data-theme="retro"]) .nes-radio {
    accent-color: var(--primary);
    width: 1.05rem;
    height: 1.05rem;
    margin-right: .5rem;
    vertical-align: -2px;
}
html:not([data-theme="retro"]) .nes-choices label { font-weight: 600; }
html:not([data-theme="retro"]) .help-text { color: var(--muted); font-size: .85rem; margin: .35rem 0 0; }
html:not([data-theme="retro"]) .form-errors { color: #dc2626; font-size: .88rem; }

/* Tables */
html:not([data-theme="retro"]) table { width: 100%; border-collapse: collapse; font-size: .95rem; }
html:not([data-theme="retro"]) th {
    text-align: left;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: .5rem .7rem;
    border-bottom: 2px solid var(--line);
}
html:not([data-theme="retro"]) th.num { text-align: right; }
html:not([data-theme="retro"]) td { padding: .65rem .7rem; border-bottom: 1px solid var(--line); }
html:not([data-theme="retro"]) tr:last-child td { border-bottom: none; }

html:not([data-theme="retro"]) .amount-pos { color: #059669; font-weight: 800; }
html:not([data-theme="retro"]) .amount-neg { color: #dc2626; font-weight: 800; }

/* Tags */
html:not([data-theme="retro"]) .tag {
    background: #eef0fa;
    color: #4b5069;
    border-radius: 999px;
    padding: .22rem .75rem;
    font-size: .78rem;
    font-weight: 700;
}
html:not([data-theme="retro"]) .tag-open { background: #d1fae5; color: #065f46; }
html:not([data-theme="retro"]) .tag-awaiting_confirmation { background: #fef3c7; color: #92400e; }
html:not([data-theme="retro"]) .tag-settled { background: #e0e7ff; color: #3730a3; }
html:not([data-theme="retro"]) .tag-cancelled { background: #fee2e2; color: #991b1b; }
html:not([data-theme="retro"]) .tag-special { background: #fef3c7; color: #92400e; }

/* Listes */
html:not([data-theme="retro"]) .bet-list li,
html:not([data-theme="retro"]) .penalty-list li { border-bottom: 1px solid var(--line); }
html:not([data-theme="retro"]) .bet-list li:last-child,
html:not([data-theme="retro"]) .penalty-list li:last-child { border-bottom: none; }
html:not([data-theme="retro"]) .bet-list a { color: var(--text); font-weight: 700; text-decoration: none; }
html:not([data-theme="retro"]) .bet-list a:hover { color: var(--primary); }

html:not([data-theme="retro"]) .ranking-dnd li {
    background: #fff;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(35, 38, 59, .06);
}
html:not([data-theme="retro"]) .ranking-dnd li:active { cursor: grabbing; }
html:not([data-theme="retro"]) .ranking-dnd .rank-pos { color: var(--primary); }
html:not([data-theme="retro"]) .ranking-dnd .rank-arrows button { color: var(--muted); }
html:not([data-theme="retro"]) .ranking-dnd .rank-arrows button:hover { color: var(--primary); }

html:not([data-theme="retro"]) .item-list li {
    background: #eef0fa;
    border-radius: 999px;
    padding: .3rem .5rem .3rem .9rem;
    font-weight: 700;
    font-size: .9rem;
}
html:not([data-theme="retro"]) .item-remove { color: var(--muted); }
html:not([data-theme="retro"]) .item-remove:hover { color: #dc2626; }

html:not([data-theme="retro"]) .invite-box {
    background: #eef2ff;
    border: 2px dashed #a5b4fc;
    border-radius: 12px;
    padding: 1rem 1.2rem;
    font-size: .92rem;
}
html:not([data-theme="retro"]) .invite-box code {
    background: #fff;
    border-radius: 8px;
    padding: .5rem .7rem;
    font-size: .85rem;
}

html:not([data-theme="retro"]) .result-box { font-size: 1.05rem; }

/* Icônes NES remplacées par des emojis */
html:not([data-theme="retro"]) .nes-icon { font-style: normal; }
html:not([data-theme="retro"]) .nes-icon.coin::before { content: '🪙'; }
html:not([data-theme="retro"]) .nes-icon.trophy::before { content: '🏆'; }
html:not([data-theme="retro"]) .nes-icon.star::before { content: '⭐'; }
html:not([data-theme="retro"]) .nes-icon.is-medium { font-size: 1.6rem; }

/* Toasts */
html:not([data-theme="retro"]) .toast {
    background: #fff;
    border-radius: 14px;
    border: 1px solid rgba(35, 38, 59, .07);
    border-left: 5px solid var(--primary);
    box-shadow: 0 10px 30px rgba(35, 38, 59, .16);
    padding: .9rem 1.1rem;
    font-size: .92rem;
    animation: toast-slide .25s ease-out;
}
html:not([data-theme="retro"]) .toast-success { border-left-color: #10b981; }
html:not([data-theme="retro"]) .toast-error { border-left-color: #ef4444; }

@keyframes toast-slide {
    from { opacity: 0; transform: translateX(24px); }
    to { opacity: 1; transform: none; }
}

html:not([data-theme="retro"]) .theme-toggle {
    background: #fff;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: .45rem .9rem;
    font-family: 'Nunito', system-ui, sans-serif;
    font-size: .82rem;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(35, 38, 59, .12);
}
html:not([data-theme="retro"]) .theme-toggle:hover { color: var(--primary); }

/* ======================================================================
   Thème rétro — ajustements par-dessus NES.css
   ====================================================================== */

html[data-theme="retro"] { font-size: 12px; }

[data-theme="retro"] body {
    font-family: 'Press Start 2P', monospace;
    background: #f8f8f8;
    color: #212529;
    line-height: 1.8;
}

[data-theme="retro"] h1 { font-size: 1.4rem; margin: 0; line-height: 1.6; }
[data-theme="retro"] .muted { color: #6b7686; }

[data-theme="retro"] .navbar {
    background: #fff;
    border-bottom: 4px solid #212529;
    padding: 1rem 1.5rem;
}
[data-theme="retro"] .navbar .brand { font-size: 1.1rem; color: #212529; text-decoration: none; }
[data-theme="retro"] .navbar .brand:hover { color: #209cee; }
[data-theme="retro"] .nav-links a, [data-theme="retro"] .nav-right a { color: #212529; text-decoration: none; }
[data-theme="retro"] .nav-links a:hover, [data-theme="retro"] .nav-right a:hover { color: #209cee; }

[data-theme="retro"] .balance-badge {
    background: #212529;
    color: #f7d51d;
    padding: .5rem .8rem;
}

[data-theme="retro"] .balance-hero { font-size: 2rem; }
[data-theme="retro"] .balance-hero small { font-size: 1rem; color: #6b7686; }

/* .nes-container.is-rounded pose margin: 4px avec une spécificité (0,2,0) :
   on scope + double classe pour reprendre la main sur les marges. */
[data-theme="retro"] .card.nes-container { background: #fff; margin: 0 0 2rem; }
[data-theme="retro"] .card-warning.nes-container { background: #fffbea; }
[data-theme="retro"] .auth-card.nes-container { max-width: 480px; margin: 3rem auto; background: #fff; }
[data-theme="retro"] .auth-card form { margin: 1.5rem 0; }

[data-theme="retro"] table { font-size: .85rem; }
[data-theme="retro"] th, [data-theme="retro"] td { padding: .6rem .8rem; }
[data-theme="retro"] .amount-pos { color: #4aa52e; }
[data-theme="retro"] .amount-neg { color: #e76e55; }

[data-theme="retro"] label { font-size: .9rem; }
[data-theme="retro"] .help-text { color: #6b7686; font-size: .75rem; margin: .4rem 0 0; }
[data-theme="retro"] .form-errors { color: #e76e55; font-size: .8rem; }

[data-theme="retro"] .tag {
    background: #e8e8e8;
    color: #212529;
    border: 2px solid #212529;
    padding: .2rem .5rem;
    font-size: .7rem;
}
[data-theme="retro"] .tag-open { background: #92cc41; }
[data-theme="retro"] .tag-awaiting_confirmation { background: #f7d51d; }
[data-theme="retro"] .tag-settled { background: #209cee; color: #fff; }
[data-theme="retro"] .tag-cancelled { background: #e76e55; color: #fff; }
[data-theme="retro"] .tag-special { background: #f7d51d; }

[data-theme="retro"] .bet-list li, [data-theme="retro"] .penalty-list li { border-bottom: 4px dotted #d3d3d3; }
[data-theme="retro"] .bet-list li:last-child, [data-theme="retro"] .penalty-list li:last-child { border-bottom: none; }
[data-theme="retro"] .bet-list a { color: #212529; }
[data-theme="retro"] .bet-list a:hover { color: #209cee; }

[data-theme="retro"] .ranking-dnd li {
    background: #fff;
    border: 3px solid #212529;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, .15);
}
[data-theme="retro"] .ranking-dnd .rank-pos { color: #209cee; }
[data-theme="retro"] .ranking-dnd .rank-arrows button { color: #6b7686; }
[data-theme="retro"] .ranking-dnd .rank-arrows button:hover { color: #209cee; }

[data-theme="retro"] .item-list li {
    background: #fff;
    border: 2px solid #212529;
    padding: .2rem .4rem .2rem .7rem;
    font-size: .8rem;
}
[data-theme="retro"] .item-remove { color: #e76e55; }

[data-theme="retro"] .invite-box {
    background: #e7f5ff;
    border: 4px dashed #209cee;
    padding: 1rem;
    font-size: .8rem;
}
[data-theme="retro"] .invite-box code { background: #fff; padding: .6rem; font-family: inherit; font-size: .7rem; }

[data-theme="retro"] .result-box { font-size: 1rem; }

[data-theme="retro"] .toast {
    padding: 1rem 1.2rem;
    background: #fff;
    border: 4px solid #212529;
    box-shadow: 6px 6px 0 rgba(0, 0, 0, .2);
    font-size: .75rem;
    line-height: 1.7;
    animation: toast-steps .2s steps(4);
}
[data-theme="retro"] .toast-success { border-color: #4aa52e; }
[data-theme="retro"] .toast-error { border-color: #e76e55; }
[data-theme="retro"] .toast-notification { border-color: #209cee; }

@keyframes toast-steps {
    from { opacity: 0; transform: translateX(24px); }
    to { opacity: 1; transform: none; }
}

[data-theme="retro"] .nes-btn { font-size: .85rem; }

[data-theme="retro"] .theme-toggle {
    background: #fff;
    color: #212529;
    border: 4px solid #212529;
    padding: .5rem .8rem;
    font-size: .7rem;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, .2);
}
[data-theme="retro"] .theme-toggle:hover { color: #209cee; }
