/* ============================================
   VARIABLES — Thème sombre (bleu / gris)
============================================ */
:root {
    --bg-page: #0b1324;
    /* fond général, bleu très sombre */
    --bg-panel: #111827;
    /* panneaux */
    --bg-muted: #1f2937;
    /* gris foncé */
    --bg-main: #1d4ed8;
    /* bleu principal boutons */
    --bg-accent: #334155;
    /* gris bleuté */
    --bg-chip-round: #1f2937;

    --border-soft: #1f2937;
    --border-strong: #334155;

    --text-main: #e5e7eb;
    /* texte clair */
    --text-muted: #9ca3af;
    --text-invert: #ffffff;

    --radius-md: 8px;
    --radius-pill: 999px;

    --gap-xs: 0.25rem;
    --gap-sm: 0.4rem;
    --gap: 0.7rem;
    --gap-lg: 1rem;

    --shadow-soft: 0 2px 6px rgba(0, 0, 0, 0.4);
    --btn-bg: var(--bg-panel);
        /* fond normal */
        --btn-fg: #f3f4f6;
        /* texte normal */
        --btn-bg-hover: #1c2740;
        /* foncé → hover */
        --btn-bg-active: var(--bg-main);
        /* bleu sélectionné */
        --btn-bg-disabled: #1b2333;
        /* désactivé */
        --btn-fg-disabled: #9ca3af;
        /* gris clair pour disabled */
        --btn-border-disabled: #0f172a;
}


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

html,
body {
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    background: var(--bg-page);
    color: var(--text-main);
}

a{
    text-decoration: none;
        color: inherit;
}
/* ============================================
   WRAP / PANELS
============================================ */
.wrap-main {
    max-width: 960px;
    margin: 0 auto;
    padding: var(--gap-lg);
}

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 1rem;
    box-shadow: var(--shadow-soft);
    margin-bottom: var(--gap);
}

.panel h2 {
    margin-top: 0;
    margin-bottom: 0.5rem;
}
.panel.danger {
    border-left: 4px solid #c0392b;
    background: #fff4f4;
    color: #8a1f1f;
}

.panel.success {
    border-left: 4px solid #3aa76d;
    background: #f1fbf6;
    color: #1f6f4a;
}

/* ============================================
   FLEX / GRID
============================================ */
.row {
    display: flex;
    align-items: center;
    gap: var(--gap);
}

.row.wrap {
    flex-wrap: wrap;
}

.grid {
    display: grid;
    gap: var(--gap);
}

.g3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 800px) {
    .g3 {
        grid-template-columns: 1fr;
    }
}


/* ============================================
   TEXT HELPERS
============================================ */
.muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.center {
    text-align: center;
}


/* ============================================
   BOUTONS
============================================ */
/* .btn {
    background: var(--bg-muted);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-pill);
    padding: 0.45rem 1rem;
    color: var(--text-main);
    font-size: 0.95rem;
    cursor: pointer;
}
.btn.active,
.btn.selected {
    background: var(--bg-main);
    color: var(--text-invert);
    border-color: var(--bg-main);
}

.btn:disabled {
    opacity: 0.5;
    cursor: default;
} */
/* Bouton générique */
.btn {
    background-color: var(--btn-bg);
    color: var(--btn-fg);
    border: 1px solid transparent;
    border-radius: 5px;
    padding: .35rem .7rem;
    font-size: .95rem;
    cursor: pointer;
}

/* .btn:hover:not(.is-disabled):not(:disabled) {
    background-color: var(--btn-bg-hover);
} */

/* Sélection (active) */
.btn.active {
    background-color: var(--btn-bg-active);
}

/* Désactivation (désactive la couleur active) */
.btn.is-disabled,
.btn.is-disabled.active,
.btn:disabled,
.btn:disabled.active {
    background-color: var(--btn-bg-disabled) !important;
    color: var(--btn-fg-disabled) !important;
    border-color: var(--btn-border-disabled) !important;
    cursor: default;
    opacity: 1;
}
.btn.ok {
    background: #16a34a;
    border-color: #15803d;
    color: white;
}

.btn.danger {
    background: #b91c1c;
    border-color: #7f1d1d;
    color: white;
}


/* ============================================
   INPUTS
============================================ */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
    background: #0f172a;
    border: 1px solid #1f2937;
    color: var(--text-main);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    width: 100%;
}

input::placeholder {
    color: #64748b;
}


/* ============================================
   CHIPS (rectangulaires)
============================================ */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap-xs);
}

.chip {
    background: var(--bg-muted);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-pill);
    padding: 0.2rem 0.7rem;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--text-main);
}

/* .chip:hover {
    background: var(--bg-accent);
} */

.chip.active {
    background: var(--bg-main);
    color: white;
    border-color: var(--bg-main);
}


/* ============================================
   CHIP RONDE (Set#, numéro, etc.)
============================================ */
.chip-round {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 999px;
    background: var(--bg-chip-round);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-soft);
    font-weight: bold;
}

.chip-round.active {
    background: var(--bg-main);
    border-color: var(--bg-main);
}


/* ============================================
   PLAYERS_SETUP (pills joueurs)
============================================ */
.players-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.6rem;
}

.player-pill {
    display: inline-flex;
    align-items: center;
    border-radius: var(--radius-pill);
    background: var(--bg-muted);
    border: 1px solid var(--border-soft);
    color: var(--text-main);
    cursor: pointer;
    padding: 0.35rem 0.8rem;
}

/* .player-pill:hover {
    background: var(--bg-accent);
} */

.player-pill input {
    display: none;
}

.player-pill input:checked+span {
    background: var(--bg-main);
    color: white;
    border-radius: var(--radius-pill);
}


/* ============================================
   FORMAT DE LA PARTIE (radio pills)
============================================ */
.format-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.format-pill {
    display: inline-flex;
    border-radius: var(--radius-pill);
    background: var(--bg-muted);
    border: 1px solid var(--border-soft);
    cursor: pointer;
}

.format-pill input {
    display: none;
}

.format-pill-label {
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-pill);
}

.format-pill input:checked+.format-pill-label {
    background: var(--bg-main);
    color: white;
}


/* ============================================
   TABLES (scores & historique)
============================================ */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table th,
.table td {
    border: 1px solid var(--border-soft);
    padding: 0.35rem;
    text-align: center;
}

.table thead th {
    background: var(--bg-muted);
    font-weight: bold;
}


/* ============================================
   HEADER (si tu veux garder l’ancien header sombre)
============================================ */
.app-header {
    background: #111827;
    color: #e5e7eb;
    padding: 0.6rem 1.2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-soft);
}


/* ============================================
   AUTH (page d'accueil / login)
============================================ */
.auth-body {
    background: var(--bg-panel);
}

.auth-body .wrap-main {
    max-width: 600px;
}

.auth-body h1 {
    color: #93c5fd;
}

.auth-body .panel {
    background: #111827;
    border: 1px solid #1f2937;
}

.auth-body .btn {
    background: var(--bg-main);
    border: none;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-md);
}

.auth-body input {
    width: 100%;
}
#timeline {
    margin-top: var(--gap);
}

/* Tu peux affiner quand on saura comment sont rendues les "panels" de timeline */

/* ========= Sections génériques ========= */

.section {
    margin-top: 0.6rem;
}

.section-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    font-size: 0.75rem;
    text-transform: uppercase;
}

/* /* Boutons "sélectionnés" (contrats, bouts, etc.) */
.btn.active,
.btn.selected {
    background: var(--bg-main);
    color: var(--text-invert);
    border-color: var(--border-strong);
}
.page-title {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
}

/* Colonnes de la liste des parties */
.games-table .col-code {
    font-weight: 600;
}

.games-table .col-date {
    white-space: nowrap;
}

.games-table .col-num {
    text-align: right;
}

/* survol d’une ligne de partie */
/* .game-row:hover {
    background: #f9fafb;
    cursor: pointer;
} */

/* ========= Header principal de l'application ========= */

/* .app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1.25rem;
    background: var(--bg-main);
    color: var(--text-invert);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.35);
} */

/* côté gauche : logo + nav */
.app-header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.app-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    text-decoration: none;
    color: inherit;
}

.app-logo-mark {
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 999px;
    background: #f97316;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
}

.app-logo-text {
    font-weight: 600;
    letter-spacing: 0.03em;
}

/* navigation principale */
.app-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.app-nav-link {
    font-size: 0.9rem;
    color: #e5e7eb;
    text-decoration: none;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
}

/* .app-nav-link:hover {
    background: rgba(15, 23, 42, 0.4);
} */

.app-nav-link.active {
    background: #f97316;
    color: #111827;
}

/* côté droit : user + logout */

.app-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.55);
}

.user-avatar {
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 999px;
    background: #f97316;
    color: #111827;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
}

.user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.user-name {
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.75rem;
    color: #e5e7eb;
}

/* bouton Quitter */

.btn-logout {
    text-decoration: none;
    font-size: 0.85rem;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    border: 1px solid #fca5a5;
    color: #fee2e2;
    background: rgba(185, 28, 28, 0.9);
}

/* .btn-logout:hover {
    background: #b91c1c;
} */

/* Désactive le soulignement sur les liens qui ressemblent à des boutons */
a.btn,
.btn {
    text-decoration: none;
}

/* Supprime le soulignement sur TOUS les liens dans l'appli */
a {
    text-decoration: none;
    color: inherit;
}

.center {
    justify-content: center;
}

.row.center {
    justify-content: center;
}

.btn.alt {
    background: var(--accent-soft);
    border-color: var(--border-soft);
    color: var(--text-main);
}

/* .btn.alt:hover {
    background: #d1d5db;
} */

/* ========= Thème sombre pour l'accueil non connecté ========= */
/* 
.auth-body {
    background: none !important;
    color: #e2e8f0;
}

.auth-body .wrap-main {
    max-width: 600px;
}

/* Titre principal comme hier : bleu clair */
.auth-body h1 {
    color: #93c5fd;
}

/* Panel sombre pour le bloc accueil */
.auth-body .panel {
    background: #111827;
    border: 1px solid #1f2937;
    border-radius: 12px;
    padding: 1rem;
}

/* Boutons bleus comme hier */
.auth-body .btn {
    background: #1d4ed8;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    margin: 0.3rem;
}

/* .auth-body .btn:hover {
    background: #1e40af;
} */

/* Variante secondaire */
.auth-body .btn.alt {
    background: #334155;
    color: #e5e7eb;
}

/* Champs de formulaire comme hier */
.auth-body input[type="text"],
.auth-body input[type="email"],
.auth-body input[type="password"] {
    display: block;
    width: 100%;
    padding: 0.5rem;
    margin: 0.4rem 0;
    border: 1px solid #334155;
    border-radius: 8px;
    background: #0b1324;
    color: #e2e8f0;
}

/* Texte d'aide 
.auth-body .hint {
    color: #9ca3af;
    font-size: 0.9rem;
}
 */
/* ========= players_setup : grille des joueurs ========= */
/* ========= players_setup : grille des joueurs ========= */

/* .players-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.5rem;
    margin-top: 0.5rem;
}

/* Le label entier est cliquable */
/* .player-pill {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    border-radius: var(--radius-pill);
    background: var(--bg-card);
    /* crème */
    /* color: var(--text-main);
    border: 1px solid var(--border-soft);
    padding: 0; */
    /* on laisse le padding au span 
} */

/* masque la checkbox native */
/* .player-pill input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
} */

/* apparence du pill (texte) */
.player-pill-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: inherit;
    border: none;
    padding: 0.15rem 0.55rem;
    font-size: 0.88rem;
    line-height: 1;
}

/* Survol (non encore sélectionné) */
/* .player-pill:hover {
    background: var(--accent-soft);
    border-color: var(--border-strong);
    transform: translateY(-1px);
} */

/* État sélectionné 
.player-pill input[type="checkbox"]:checked+.player-pill-label {
   
    on colore le conteneur entier via :has si dispo,
       mais cette règle suffit déjà visuellement
} */

.player-pill:has(input[type="checkbox"]:checked) {
    background: var(--bg-main);
    color: var(--text-invert);
    border-color: var(--border-strong);
    transform: none;
}

/* ========= format de la partie : pills radio ========= */
/* .chip-round {
    background: #154c3f;
    color: #fdf5e6;
    border: 1px solid #1e293b;
    width: 2.2rem;
    height: 2.2rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-weight: 600;
}

.chip-round.active {
    background: var(--bg-main);
    color: var(--text-invert);
    border-color: var(--border-strong);
} */

/* .format-toggle {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.4rem;
}

.format-pill {
    position: relative;
    display: inline-flex;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    background: var(--bg-card);
    color: var(--text-main);
}

.format-pill input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.format-pill-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    font-size: 0.9rem;
}

/* pill active */
.format-pill input[type="radio"]:checked+.format-pill-label {
    background: var(--bg-main);
    color: var(--text-invert);
    border-radius: 999px;
}
 
/* Grille des joueurs */


/* Survol (non encore sélectionné) */
/* .player-pill:hover .player-pill-label {
    background: var(--accent-soft);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}
 */
/* État sélectionné : quand la case est cochée */
/* .player-pill input[type="checkbox"]:checked+.player-pill-label {
    background: var(--bg-main);
    /* rouge Tarot */
    /*color: var(--text-invert);
     crème 
    border-color: var(--border-strong);
    transform: none;
} */

.center {
    text-align: center;
}

/* .player-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;

    background: var(--bg-card);
    /* crème */
    /* color: var(--text-main);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-pill);
    pastille ovale
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    font-size: 0.95rem;  */

    /* transition: background 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease,
        transform 0.05s ease;
}*/

/* Survol */
/* .player-pill:hover {
    background: var(--accent-soft);
    /* crème + chaud 
    border-color: var(--border-strong);
    transform: translateY(-1px);
} */

/* État sélectionné (quand input:checked + label associés) */
.player-pill.selected,
.player-pill.active,
.player-pill.checked {
    background: var(--bg-main);
    /* rouge tarot */
    color: var(--text-invert);
    /* crème */
    border-color: var(--border-strong);
    transform: none;
}

/* Pour les labels utilisés comme boutons liés à un input caché */
.player-pill input[type="checkbox"],
.player-pill input[type="radio"] {
    display: none;
}


.align-start>div {
    align-self: flex-start;
}

.grid.g4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .75rem;
}

.cols-main {
    display: flex;
    gap: .75rem;
    align-items: flex-start;
}

/* chaque bloc (Contrat, Bouts, Points, Bonus) prend sa colonne */
.cols-main .col-block {
    flex: 1;
    min-width: 0;
    /* évite que ça déborde */
}

@media (max-width: 768px) {
    .cols-main {
        flex-direction: column;
    }
}

/* Pour la ligne Contrat / Bouts / Points / Bonus */
.cols-main .group {
    display: flex;
    flex-wrap: wrap;
    /* permet de passer à la ligne si ça manque un peu de place */
    gap: .25rem;
    /* petit espace régulier entre les boutons */
}

.cols-main .group .btn {
    flex: 0 0 auto;
    /* NE PAS rétrécir les boutons en largeur */
}


/* Timeline dans le panneau "Scores cumulés" */

/* Les cartes de donne rendues à l'intérieur de #timeline */
#timeline .panel {
    margin-top: .25rem;
    width: 100%;
    max-width: none;
    box-sizing: border-box;
}

#timeline .timeline-panel {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    margin-top: .35rem;
}

/* Le conteneur des "Dernières donnes" occupe toute la largeur du panneau */
#timeline {
    width: 100%;
}

/* La boîte qui contient la liste des donnes */
.timeline-box {
    width: 100%;
    max-width: none;
    box-sizing: border-box;

    /* On lui donne le même aspect qu'un panel,
     mais sans imbriquer .panel dans .panel */
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-soft);
    margin-top: .35rem;
}

/* Chaque ligne de donne à l'intérieur */
.timeline-box>div {
    width: 100%;
}

#btn-close-game {
    padding: .2rem .6rem;
    line-height: 1.1rem;
}

header .row {
    flex-wrap: nowrap;
}

#master-name {
    white-space: nowrap;
}

.icon-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0 .25rem;
    font-size: .8rem;
    line-height: 1;
    opacity: .3;
}

/* .icon-btn:hover {
    opacity: .8;
} */

.panel .edit-hand-btn {
    font-weight: 500;
}
/* === FORCER L'ICÔNE EDIT À ÊTRE VISIBLE === */

.edit-hand-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;

    min-width: 1.4rem;
    min-height: 1.4rem;

    padding: 0 0.3rem !important;
    margin: 0 !important;

    /* border: 1px solid rgba(255, 255, 255, 0.6) !important; */
    border-radius: 4px !important;

    background: #0f172a !important;
    /* ton bleu nuit */
    color: #ffffff !important;
    font-size: 1rem !important;
    line-height: 1 !important;

    opacity: 1 !important;
    visibility: visible !important;
}

.edit-hand-btn.is-editing {
    background-color: #0f172a;
    border: 1px solid;
    border-radius: 999px;
    padding-inline: .4rem;
    /* Ligne des totaux : plus visible */
        #scores-table tbody tr.scores-row-total {
            font-weight: 600;
            border-bottom: 1px solid rgba(148, 163, 184, 0.5);
            /* gris léger */
        }
    
        /* Lignes des donnes (vue per_hand) */
        #scores-table tbody tr.scores-row-hand {
            font-size: 0.9rem;
            color: #e5e7eb;
            /* gris clair */
        }
    
        #scores-table tbody tr.scores-row-hand:nth-child(odd) {
            background-color: rgba(15, 23, 42, 0.5);
            /* léger fond alterné */
        }
    
        /* Cellules numériques déjà alignées via .col-num, ici on ajoute couleurs */
        #scores-table td.col-num.is-positive {
            /* vert doux pour les points gagnés */
            color: #22c55e;
        }
    
        #scores-table td.col-num.is-negative {
            /* rouge doux pour les points perdus */
            color: #f97373;
        }
    
        /* Facultatif : centrer les en-têtes */
        #scores-table thead th {
            text-align: center;
        }
}
.user-settings-btn {
    margin-left: .5rem;
    text-decoration: none;
    font-size: 1.1rem;
    opacity: .8;
}

/* .user-settings-btn:hover {
    opacity: 1;
} */
.current-contract-banner {
    margin-top: 1rem;
    padding: .4rem .75rem;
    border-radius: .5rem;
    font-weight: 600;
    background: var(--bg-card, #0f172a);
    border: 1px solid var(--border-soft, #374151);
}
#scores-table .totals-row td {
    font-weight: 700;
    border-top: 2px solid var(--border-strong);
    background: var(--bg-card-strong, rgba(255, 255, 255, .06));
}
#scores-table {
    width: 100%;
    border-collapse: collapse;
}

#scores-table tr {
    display: table-row !important;
}

#scores-table th,
#scores-table td {
    display: table-cell;
    padding: .3rem .5rem;
    vertical-align: middle;
}

#scores-table th {
    text-align: left;
    font-weight: 600;
}

#scores-table td.right {
    text-align: right;
}

/* Ligne Totaux mise en valeur */
#scores-table .totals-row td {
    font-weight: 700;
    border-top: 2px solid var(--border-strong);
    background: var(--bg-card-strong, rgba(255, 255, 255, .06));
}
/* Tableau de scores : colonnes bien alignées */
#scores-table {
    table-layout: fixed;
    width: 100%;
}

#scores-table th,
#scores-table td {
    text-align: center;
}

/* Première colonne (# donne ou TOTAL) un peu plus étroite */
#scores-table th:first-child,
#scores-table td:first-child {
    width: 80px;
    /* tu peux ajuster */
}