/**
 * Styles du générateur de personnages D&D.
 * Cohérent avec le thème sombre des panneaux du plugin.
 */

/* ============================================================
   Formulaire de génération
   ============================================================ */

.dnd-perso-formulaire {
    background: var(--dnd-panneau-fond, #1a1a2e);
    color: var(--dnd-panneau-texte, #e0e0e0);
    border: 1px solid var(--dnd-bordure, rgba(255,255,255,0.1));
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.dnd-perso-formulaire h2,
.dnd-perso-formulaire h3 {
    font-family: 'Cinzel', serif;
    color: var(--dnd-accent-or, #c89b4a);
    margin: 0 0 1rem;
}

.dnd-perso-grille-champs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.8rem 1rem;
    margin-bottom: 1.2rem;
}

.dnd-perso-champ label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--dnd-accent-or, #c89b4a);
    margin-bottom: 4px;
}

.dnd-perso-champ select,
.dnd-perso-champ input {
    width: 100%;
    padding: 0.45rem 0.6rem;
    background: rgba(255,255,255,0.05);
    color: inherit;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    font-size: 14px;
}

.dnd-perso-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.dnd-perso-actions button,
.dnd-perso-actions .button {
    background: var(--dnd-accent-or, #c89b4a);
    color: #1a1a2e;
    border: none;
    padding: 0.7rem 1.2rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    transition: background 0.15s ease;
}
.dnd-perso-actions button:hover { background: #d9ac5c; }

.dnd-perso-actions .dnd-perso-imprimer,
.dnd-perso-actions .dnd-perso-tout-relancer {
    background: rgba(255,255,255,0.1);
    color: inherit;
}

/* ============================================================
   Résultats : grille de fiches
   ============================================================ */

.dnd-perso-resultats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.dnd-perso-loading,
.dnd-perso-erreur {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: rgba(255,255,255,0.7);
    font-style: italic;
}
.dnd-perso-erreur { color: #e74c3c; }

/* ============================================================
   Fiche personnage
   ============================================================ */

.dnd-fiche-perso {
    background: linear-gradient(180deg, #232340 0%, #1a1a2e 100%);
    color: var(--dnd-panneau-texte, #e0e0e0);
    border: 1px solid var(--dnd-accent-or, #c89b4a);
    border-radius: 6px;
    padding: 1rem 1.1rem 1.2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    break-inside: avoid;
    page-break-inside: avoid;
}

.dnd-perso-entete {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 0.6rem;
    margin-bottom: 0.8rem;
}

.dnd-perso-nom {
    font-family: 'Cinzel', serif;
    color: var(--dnd-accent-or, #c89b4a);
    font-size: 1.3rem;
    margin: 0 0 0.2rem;
    line-height: 1.1;
}

.dnd-perso-sous-titre {
    margin: 0;
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    font-style: italic;
}

.dnd-perso-relancer {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.15);
    color: inherit;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.15s ease, transform 0.2s ease;
}
.dnd-perso-relancer:hover {
    background: var(--dnd-accent-or, #c89b4a);
    color: #1a1a2e;
    transform: rotate(180deg);
}

/* Bloc défenses (CA/PV/Init…) */
.dnd-perso-defenses {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-bottom: 0.8rem;
}

.dnd-perso-stat {
    background: rgba(255,255,255,0.05);
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
    text-align: center;
}

.dnd-perso-stat-label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--dnd-accent-or, #c89b4a);
    margin-bottom: 2px;
}

.dnd-perso-stat-val {
    font-size: 1.1rem;
    font-weight: 700;
}

/* Tableau des 6 attributs */
.dnd-perso-attributs {
    width: 100%;
    border-collapse: collapse;
    margin: 0.8rem 0;
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
    overflow: hidden;
    text-align: center;
}

.dnd-perso-attributs th {
    background: var(--dnd-accent, #8b3a3a);
    color: #fff;
    padding: 4px 0;
    font-family: 'Cinzel', serif;
    font-size: 11px;
    letter-spacing: 1px;
}

.dnd-perso-attributs td {
    padding: 6px 4px;
    border-top: 1px solid rgba(255,255,255,0.05);
    position: relative;
}

.dnd-perso-attributs td.dnd-attr-sauv {
    background: rgba(184, 137, 61, 0.12);
}

.dnd-attr-score {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
}

.dnd-perso-attributs small {
    display: block;
    color: var(--dnd-accent-or, #c89b4a);
    font-weight: 600;
    font-size: 11px;
}

.dnd-attr-sauv-marque {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 10px;
    color: var(--dnd-accent-or, #c89b4a);
}

/* Traits */
.dnd-perso-traits {
    margin: 0.8rem 0 0;
    font-size: 13px;
    line-height: 1.4;
}

.dnd-perso-traits dt {
    font-weight: 700;
    color: var(--dnd-accent-or, #c89b4a);
    display: inline;
}
.dnd-perso-traits dt::after { content: ' : '; }

.dnd-perso-traits dd {
    display: inline;
    margin: 0;
}

.dnd-perso-traits dd::after {
    content: '';
    display: block;
    margin-bottom: 4px;
}

.dnd-perso-xp {
    margin: 0.6rem 0 0;
    text-align: right;
    color: rgba(255,255,255,0.5);
}

.dnd-perso-xp-inline {
    margin: 4px 0 0;
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    font-style: italic;
}

/* ============================================================
   FICHE COMPLÈTE : sections (sauvegardes, compétences, etc.)
   ============================================================ */

.dnd-perso-section {
    margin-top: 0.8rem;
    padding-top: 0.6rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.dnd-perso-section-titre {
    font-family: 'Cinzel', serif;
    color: var(--dnd-accent-or, #c89b4a);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 0.5rem;
}

.dnd-perso-section p {
    margin: 4px 0;
    font-size: 12px;
    line-height: 1.4;
}

.dnd-perso-section ul {
    margin: 4px 0;
    padding-left: 1.2rem;
    font-size: 12px;
    line-height: 1.4;
}

.dnd-perso-section ul li {
    margin: 2px 0;
}

/* ============================================================
   Deux colonnes : sauvegardes + compétences
   ============================================================ */

.dnd-perso-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 0.8rem;
}

@media (max-width: 600px) {
    .dnd-perso-2col {
        grid-template-columns: 1fr;
    }
}

/* Listes "mécaniques" (sauvegardes + compétences) */
.dnd-perso-liste-mecas {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
}

.dnd-perso-liste-mecas li {
    display: grid;
    grid-template-columns: 14px 30px 1fr;
    gap: 6px;
    align-items: center;
    padding: 2px 0;
    border-bottom: 1px dotted rgba(255,255,255,0.04);
}

.dnd-meca-marque {
    font-size: 12px;
    color: rgba(255,255,255,0.3);
}

.dnd-meca-marque.maitrise {
    color: var(--dnd-accent-or, #c89b4a);
    font-weight: 700;
}

.dnd-meca-val {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    text-align: center;
    color: var(--dnd-accent-or, #c89b4a);
}

.dnd-meca-nom {
    color: inherit;
}

.dnd-meca-nom small {
    color: rgba(255,255,255,0.4);
    font-size: 10px;
}

/* ============================================================
   Bloc équipement de combat (armure + tableau d'armes)
   ============================================================ */

.dnd-perso-armure {
    margin: 4px 0;
    font-size: 12px;
}

.dnd-perso-armes-tableau {
    width: 100%;
    border-collapse: collapse;
    margin-top: 6px;
    font-size: 12px;
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
    overflow: hidden;
}

.dnd-perso-armes-tableau th {
    background: var(--dnd-accent, #8b3a3a);
    color: #fff;
    padding: 4px 6px;
    text-align: left;
    font-family: 'Cinzel', serif;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.dnd-perso-armes-tableau td {
    padding: 4px 6px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.dnd-perso-armes-tableau td:nth-child(2) {
    color: var(--dnd-accent-or, #c89b4a);
    font-family: 'Cinzel', serif;
    text-align: center;
}

/* ============================================================
   Équipement (liste à puces)
   ============================================================ */

.dnd-perso-equipement {
    columns: 2;
    column-gap: 20px;
    font-size: 12px;
    margin: 6px 0;
}

@media (max-width: 600px) {
    .dnd-perso-equipement {
        columns: 1;
    }
}

.dnd-perso-equipement li {
    break-inside: avoid;
}

.dnd-perso-argent {
    margin: 8px 0 0;
    font-size: 13px;
}

/* ============================================================
   Sorts (lanceurs)
   ============================================================ */

.dnd-perso-sorts {
    background: rgba(142, 68, 173, 0.08);
    border-left: 3px solid #8e44ad;
    padding-left: 0.6rem;
    margin-left: -0.6rem;
    padding-bottom: 0.4rem;
    border-radius: 0 4px 4px 0;
}

.dnd-perso-sorts-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 4px 0 8px;
    font-size: 12px;
}

.dnd-perso-sorts-stats span {
    background: rgba(0,0,0,0.2);
    padding: 2px 8px;
    border-radius: 3px;
}

/* ============================================================
   Liste de traits (classe/race/historique)
   ============================================================ */

.dnd-perso-trait-titre {
    margin: 8px 0 2px !important;
    color: var(--dnd-accent-or, #c89b4a);
}

.dnd-perso-traits-liste {
    margin: 0 0 6px 1.2rem !important;
    padding: 0;
    font-size: 12px;
    line-height: 1.4;
}

.dnd-perso-traits-liste li {
    margin: 2px 0;
}

/* ============================================================
   Impression : layout adapté A4 / 2 pages
   ============================================================ */
@media print {
    .dnd-fiche-perso {
        font-size: 11px;
    }
    .dnd-perso-2col {
        grid-template-columns: 1fr 1fr !important;
    }
    .dnd-perso-section-titre {
        color: #8b3a3a !important;
    }
    .dnd-meca-marque.maitrise,
    .dnd-meca-val,
    .dnd-perso-trait-titre {
        color: #8b3a3a !important;
    }
    .dnd-perso-sorts {
        background: #f0e8f5 !important;
        border-left-color: #8e44ad !important;
    }
}

/* ============================================================
   Impression : on masque le formulaire et on étale les fiches
   ============================================================ */
@media print {
    .dnd-perso-formulaire .dnd-perso-grille-champs,
    .dnd-perso-formulaire .dnd-perso-actions,
    .dnd-perso-relancer {
        display: none !important;
    }
    .dnd-perso-formulaire {
        border: none;
        padding: 0;
        background: none;
        color: #000;
    }
    .dnd-fiche-perso {
        background: #fff !important;
        color: #000 !important;
        border: 1px solid #888;
        box-shadow: none;
    }
    .dnd-fiche-perso .dnd-perso-nom,
    .dnd-fiche-perso .dnd-perso-stat-label,
    .dnd-fiche-perso .dnd-perso-traits dt {
        color: #8b3a3a;
    }
    .dnd-perso-resultats {
        grid-template-columns: 1fr 1fr;
    }
}

/* ============================================================
   Admin (page Générer dans wp-admin) : adaptations légères
   ============================================================ */
.wrap .dnd-perso-formulaire {
    margin-top: 1.5rem;
}

/* ============================================================
   Onglet IA dans l'admin
   ============================================================ */
.dnd-ia-formulaire {
    max-width: 900px;
    background: #fff;
    padding: 1.5rem;
    border: 1px solid #ccd0d4;
    margin-top: 1rem;
}

.dnd-ia-grille {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.dnd-ia-champ label {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
}

.dnd-ia-champ select,
.dnd-ia-champ input,
.dnd-ia-champ textarea {
    width: 100%;
}

.dnd-ia-status {
    margin: 1rem 0;
    padding: 0.8rem 1rem;
    border-radius: 4px;
    background: #f0f6fc;
    border-left: 4px solid #2271b1;
    display: none;
}
.dnd-ia-status.actif { display: block; }
.dnd-ia-status.succes { background: #e8f5e9; border-color: #46b450; }
.dnd-ia-status.erreur { background: #fef2f2; border-color: #d63638; }

.dnd-ia-apercu-json {
    margin-top: 1rem;
    max-height: 300px;
    overflow: auto;
    background: #1d2327;
    color: #c3c4c7;
    padding: 1rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ============================================================
   FICHE OFFICIELLE D&D 5e (style PHB / Wizards of the Coast)
   Mise en page 4 colonnes, fond parchemin, imprimable A4 paysage.
   ============================================================ */

.dnd-fiche-officielle {
    background: #fdf8f0;
    color: #1a1a1a;
    font-family: Georgia, 'Times New Roman', serif;
    padding: 14px 16px;
    border: 2px solid #6b4423;
    border-radius: 6px;
    max-width: 1240px;
    margin: 1.5rem auto;
    box-shadow: 0 4px 18px rgba(0,0,0,0.15);
    line-height: 1.3;
}

/* --- Barre d'actions --- */
.dnd-fiche-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-bottom: 10px;
}

.dnd-fiche-bouton {
    background: #6b4423;
    color: #fdf8f0;
    border: none;
    padding: 6px 14px;
    border-radius: 3px;
    cursor: pointer;
    font-family: Georgia, serif;
    font-size: 13px;
    transition: background 0.15s ease;
}

.dnd-fiche-bouton:hover { background: #8b5a2b; }

/* --- En-tête : nom + bandeau de méta --- */
.dnd-fiche-entete {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 10px;
    align-items: stretch;
    margin-bottom: 12px;
    border-bottom: 2px solid #6b4423;
    padding-bottom: 12px;
}

.dnd-fiche-titre-bloc {
    border: 2px solid #6b4423;
    border-radius: 3px;
    padding: 10px 12px;
    background: #fff;
}

.dnd-fiche-titre-nom {
    font-family: 'Cinzel', Georgia, serif;
    font-size: 22px;
    font-weight: 700;
    color: #6b4423;
    letter-spacing: 0.5px;
}

.dnd-fiche-libelle {
    font-size: 9px;
    letter-spacing: 1.2px;
    color: #6b4423;
    text-transform: uppercase;
    margin-top: 4px;
    font-weight: 600;
}

.dnd-fiche-entete-grille {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 1fr 1fr;
    gap: 6px;
}

.dnd-fiche-cellule {
    border: 1px solid #6b4423;
    border-radius: 3px;
    padding: 6px 10px;
    background: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.dnd-fiche-valeur {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    min-height: 18px;
}

.dnd-fiche-vide {
    color: #999;
    font-style: italic;
}

/* --- Corps : 4 colonnes --- */
.dnd-fiche-corps {
    display: grid;
    grid-template-columns: 110px 280px 1fr 280px;
    gap: 10px;
    align-items: start;
}

/* === COLONNE 1 : 6 caractéristiques === */
.dnd-fiche-col-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dnd-stat-bloc {
    background: #fff;
    border: 2px solid #6b4423;
    border-radius: 8px;
    padding: 6px 4px;
    text-align: center;
    position: relative;
    aspect-ratio: 1.05;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.dnd-stat-nom {
    font-size: 9px;
    letter-spacing: 1px;
    font-weight: 700;
    color: #6b4423;
}

.dnd-stat-mod {
    font-family: 'Cinzel', Georgia, serif;
    font-size: 26px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1;
}

.dnd-stat-score {
    background: #fdf8f0;
    border: 1.5px solid #6b4423;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: #1a1a1a;
}

/* === COLONNE 2 : inspiration / saves / skills / passive perception === */
.dnd-fiche-col-comps {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dnd-fiche-bloc-inline {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.dnd-fiche-petit-bloc {
    border: 2px solid #6b4423;
    border-radius: 3px;
    background: #fff;
    padding: 4px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dnd-petit-rond {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
}

.dnd-petit-libelle {
    font-size: 8px;
    letter-spacing: 0.8px;
    color: #6b4423;
    font-weight: 600;
    text-transform: uppercase;
}

.dnd-fiche-encadre {
    border: 2px solid #6b4423;
    border-radius: 3px;
    background: #fff;
    padding: 8px 8px 18px;
    position: relative;
}

.dnd-fiche-titre-encadre {
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 9px;
    letter-spacing: 1.2px;
    color: #fdf8f0;
    background: #6b4423;
    padding: 3px 0;
    border-radius: 0 0 1px 1px;
    font-weight: 700;
    text-transform: uppercase;
}

.dnd-fiche-liste-coche {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 11px;
}

.dnd-fiche-liste-coche li {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    border-bottom: 1px dotted rgba(107, 68, 35, 0.2);
}

.dnd-fiche-liste-coche li:last-child {
    border-bottom: none;
}

.dnd-coche {
    font-size: 12px;
    color: #6b4423;
    width: 14px;
    text-align: center;
}

.dnd-valeur-jet {
    font-weight: 700;
    width: 22px;
    text-align: center;
    color: #1a1a1a;
    background: #fdf8f0;
    border: 1px solid #6b4423;
    border-radius: 2px;
    padding: 0 2px;
    font-size: 10px;
}

.dnd-nom-jet {
    flex: 1;
    font-size: 11px;
}

.dnd-attr-lie {
    font-size: 9px;
    color: #888;
}

.dnd-fiche-liste-comps {
    columns: 1;
}

/* Perception passive : bandeau spécial. */
.dnd-fiche-perception {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 2px solid #6b4423;
    border-radius: 3px;
    padding: 6px 10px;
}

.dnd-perception-valeur {
    font-family: 'Cinzel', Georgia, serif;
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
    background: #fdf8f0;
    border: 1.5px solid #6b4423;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dnd-perception-libelle {
    font-size: 9px;
    letter-spacing: 0.8px;
    color: #6b4423;
    font-weight: 600;
}

.dnd-fiche-encadre-bas {
    min-height: 80px;
}

.dnd-fiche-multi-contenu p {
    margin: 0 0 4px;
    font-size: 11px;
    line-height: 1.4;
}

/* === COLONNE 3 : combat / attaques / équipement === */
.dnd-fiche-col-droite {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dnd-fiche-ligne-combat {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

.dnd-fiche-stat-combat {
    border: 2px solid #6b4423;
    border-radius: 3px;
    background: #fff;
    padding: 8px 4px;
    text-align: center;
}

.dnd-stat-combat-val {
    font-family: 'Cinzel', Georgia, serif;
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1;
}

.dnd-stat-combat-lib {
    font-size: 8px;
    letter-spacing: 1px;
    color: #6b4423;
    font-weight: 600;
    text-transform: uppercase;
    margin-top: 4px;
}

.dnd-stat-ca {
    /* Bouclier stylisé : on simule avec un border-radius asymétrique. */
    border-radius: 3px 3px 30% 30%;
}

/* Points de vie. */
.dnd-fiche-pv {
    border: 2px solid #6b4423;
    border-radius: 3px;
    background: #fff;
    padding: 6px 10px;
}

.dnd-pv-ligne {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    border-bottom: 1px dotted rgba(107, 68, 35, 0.2);
    font-size: 11px;
}

.dnd-pv-ligne:last-child { border-bottom: none; }

.dnd-pv-libelle {
    font-size: 10px;
    color: #6b4423;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dnd-pv-valeur {
    font-weight: 700;
    font-size: 14px;
}

/* Ligne dés de vie + jets contre la mort. */
.dnd-fiche-ligne-secondaire {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.dnd-fiche-encadre-mini {
    border: 2px solid #6b4423;
    border-radius: 3px;
    background: #fff;
    padding: 6px 8px;
}

.dnd-mini-titre {
    font-size: 8px;
    letter-spacing: 1px;
    color: #6b4423;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.dnd-mini-val {
    font-size: 11px;
    font-weight: 600;
}

.dnd-mort-grille {
    font-size: 11px;
    line-height: 1.6;
}

/* Tableau attaques / sorts. */
.dnd-fiche-table-attaques {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.dnd-fiche-table-attaques th {
    font-size: 8px;
    letter-spacing: 1px;
    color: #6b4423;
    font-weight: 700;
    text-transform: uppercase;
    padding: 4px;
    border-bottom: 1.5px solid #6b4423;
    text-align: left;
}

.dnd-fiche-table-attaques th:nth-child(2),
.dnd-fiche-table-attaques th:nth-child(3) {
    text-align: center;
}

.dnd-fiche-table-attaques td {
    padding: 4px;
    border-bottom: 1px dotted rgba(107, 68, 35, 0.3);
    height: 22px;
}

.dnd-fiche-table-attaques td:nth-child(2),
.dnd-fiche-table-attaques td:nth-child(3) {
    text-align: center;
}

/* Équipement. */
.dnd-fiche-liste-equip {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 11px;
    line-height: 1.5;
    columns: 1;
}

.dnd-fiche-liste-equip li {
    padding: 2px 0;
    border-bottom: 1px dotted rgba(107, 68, 35, 0.2);
}

/* === COLONNE 4 : personnalité + capacités === */
.dnd-fiche-col-perso {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dnd-fiche-texte-perso {
    margin: 0 0 4px;
    font-size: 11px;
    font-style: italic;
    line-height: 1.4;
    min-height: 30px;
}

.dnd-fiche-capacites {
    min-height: 220px;
}

.dnd-capacite-section {
    margin-bottom: 8px;
}

.dnd-capacite-section h5 {
    font-family: 'Cinzel', Georgia, serif;
    font-size: 11px;
    margin: 0 0 4px;
    color: #6b4423;
    border-bottom: 1px solid rgba(107, 68, 35, 0.3);
    padding-bottom: 2px;
}

.dnd-capacite-section ul {
    margin: 0;
    padding-left: 16px;
    font-size: 11px;
    line-height: 1.4;
}

.dnd-capacite-section p {
    margin: 0;
    font-size: 11px;
    line-height: 1.4;
}

/* ============================================================
   IMPRESSION (A4 portrait — format officiel D&D, tient sur 1 page)
   ============================================================ */
@media print {
    /* RESET AGRESSIF : on neutralise toute la chrome WordPress / TT25
       qui ajoute du padding et pousse la fiche vers le bas.
       Le sélecteur :has() cible tout ancêtre de la fiche pour neutraliser
       padding/margin sans connaître la structure exacte du thème. */
    html, body,
    body *:has(.dnd-fiche-officielle),
    .wp-site-blocks,
    .is-layout-flow,
    .is-layout-constrained,
    .has-global-padding,
    main, article,
    .entry-content,
    .wp-block-post-content,
    .wp-block-group {
        margin: 0 !important;
        padding: 0 !important;
        max-width: none !important;
        width: 100% !important;
    }

    /* Si .dnd-fiche-actions est vide ou la fiche est dans un wrapper, on évite
       qu'un parent crée un nouveau contexte de positionnement. */
    body *:has(.dnd-fiche-officielle) {
        position: static !important;
        transform: none !important;
    }

    /* Masque tout sauf la fiche */
    body * { visibility: hidden; }
    .dnd-fiche-officielle, .dnd-fiche-officielle * { visibility: visible; }
    .dnd-fiche-officielle {
        position: fixed;          /* fixed = relatif à la page, pas au parent */
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 3mm;
        border: none;
        box-shadow: none;
        font-size: 8pt;
        background: #fff;
    }
    .no-print, .dnd-fiche-actions { display: none !important; }

    /* A4 portrait, marges minimales pour maximiser la zone utile */
    @page {
        size: A4 portrait;
        margin: 3mm;
    }

    /* En-tête ultra-compact */
    .dnd-fiche-officielle .dnd-fiche-entete {
        grid-template-columns: 1fr 1.4fr;
        gap: 3px;
        padding-bottom: 4px;
        margin-bottom: 4px;
    }
    .dnd-fiche-officielle .dnd-fiche-titre-bloc { padding: 4px 8px; }
    .dnd-fiche-officielle .dnd-fiche-titre-nom { font-size: 13pt; }
    .dnd-fiche-officielle .dnd-fiche-libelle   { font-size: 5.5pt; margin-top: 1px; }
    .dnd-fiche-officielle .dnd-fiche-valeur    { font-size: 9pt; min-height: 14px; }
    .dnd-fiche-officielle .dnd-fiche-cellule   { padding: 3px 6px; }

    /* Corps : 3 cols en haut + personnalité pleine largeur en bas */
    .dnd-fiche-officielle .dnd-fiche-corps {
        grid-template-columns: 58px 145px 1fr !important;
        gap: 3px;
    }
    .dnd-fiche-officielle .dnd-fiche-col-stats   { grid-column: 1; grid-row: 1; }
    .dnd-fiche-officielle .dnd-fiche-col-comps   { grid-column: 2; grid-row: 1; }
    .dnd-fiche-officielle .dnd-fiche-col-droite  { grid-column: 3; grid-row: 1; }
    .dnd-fiche-officielle .dnd-fiche-col-perso   {
        grid-column: 1 / -1;
        grid-row: 2;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 3px;
        margin-top: 3px;
    }
    /* Capacités pleine largeur sous les 4 boîtes personnalité */
    .dnd-fiche-officielle .dnd-fiche-col-perso .dnd-fiche-capacites {
        grid-column: 1 / -1;
    }

    /* Caractéristiques compactes */
    .dnd-fiche-officielle .dnd-fiche-col-stats { gap: 4px; }
    .dnd-fiche-officielle .dnd-stat-bloc { padding: 2px; gap: 1px; aspect-ratio: 1.2; }
    .dnd-fiche-officielle .dnd-stat-nom   { font-size: 5.5pt; }
    .dnd-fiche-officielle .dnd-stat-mod   { font-size: 14pt; line-height: 1; }
    .dnd-fiche-officielle .dnd-stat-score { width: 18px; height: 18px; font-size: 9pt; border-width: 1px; }

    /* Bloc inspiration + bonus maîtrise compact */
    .dnd-fiche-officielle .dnd-fiche-petit-bloc { padding: 2px; }
    .dnd-fiche-officielle .dnd-petit-rond { font-size: 11pt; }
    .dnd-fiche-officielle .dnd-petit-libelle { font-size: 5.5pt; }

    /* Listes (jets + compétences) très denses */
    .dnd-fiche-officielle .dnd-fiche-encadre { padding: 4px 4px 12px; }
    .dnd-fiche-officielle .dnd-fiche-liste-coche { font-size: 7pt; }
    .dnd-fiche-officielle .dnd-fiche-liste-coche li { padding: 0; gap: 3px; line-height: 1.2; }
    .dnd-fiche-officielle .dnd-coche { font-size: 8pt; width: 8px; }
    .dnd-fiche-officielle .dnd-valeur-jet { font-size: 6.5pt; width: 14px; padding: 0 1px; }
    .dnd-fiche-officielle .dnd-nom-jet { font-size: 7pt; }
    .dnd-fiche-officielle .dnd-attr-lie { font-size: 6pt; }
    .dnd-fiche-officielle .dnd-fiche-titre-encadre { font-size: 6pt; padding: 2px 0; }

    /* Perception passive compacte */
    .dnd-fiche-officielle .dnd-fiche-perception { padding: 3px 6px; gap: 6px; }
    .dnd-fiche-officielle .dnd-perception-valeur { width: 24px; height: 24px; font-size: 13pt; }
    .dnd-fiche-officielle .dnd-perception-libelle { font-size: 6pt; }

    /* Autres maîtrises */
    .dnd-fiche-officielle .dnd-fiche-encadre-bas { min-height: 0; }
    .dnd-fiche-officielle .dnd-fiche-multi-contenu p { font-size: 7pt; margin: 0 0 2px; }

    /* Combat */
    .dnd-fiche-officielle .dnd-fiche-stat-combat { padding: 3px 2px; }
    .dnd-fiche-officielle .dnd-stat-combat-val { font-size: 14pt; }
    .dnd-fiche-officielle .dnd-stat-combat-lib { font-size: 5.5pt; margin-top: 2px; }
    .dnd-fiche-officielle .dnd-fiche-ligne-combat,
    .dnd-fiche-officielle .dnd-fiche-ligne-secondaire { gap: 4px; }

    /* Points de vie */
    .dnd-fiche-officielle .dnd-fiche-pv { padding: 3px 6px; }
    .dnd-fiche-officielle .dnd-pv-ligne { padding: 1px 0; font-size: 7pt; }
    .dnd-fiche-officielle .dnd-pv-libelle { font-size: 6.5pt; }
    .dnd-fiche-officielle .dnd-pv-valeur { font-size: 10pt; }

    /* Dés de vie + jets contre la mort */
    .dnd-fiche-officielle .dnd-fiche-encadre-mini { padding: 3px 6px; }
    .dnd-fiche-officielle .dnd-mini-titre { font-size: 5.5pt; margin-bottom: 1px; }
    .dnd-fiche-officielle .dnd-mini-val,
    .dnd-fiche-officielle .dnd-mort-grille { font-size: 7pt; line-height: 1.3; }

    /* Tableau attaques */
    .dnd-fiche-officielle .dnd-fiche-table-attaques { font-size: 7pt; }
    .dnd-fiche-officielle .dnd-fiche-table-attaques th { font-size: 5.5pt; padding: 2px; }
    .dnd-fiche-officielle .dnd-fiche-table-attaques td { padding: 2px; height: 14px; }

    /* Équipement */
    .dnd-fiche-officielle .dnd-fiche-liste-equip { font-size: 7pt; line-height: 1.3; }
    .dnd-fiche-officielle .dnd-fiche-liste-equip li { padding: 1px 0; }

    /* Personnalité — boîtes compactes */
    .dnd-fiche-officielle .dnd-fiche-col-perso .dnd-fiche-encadre { padding: 3px 6px 11px; }
    .dnd-fiche-officielle .dnd-fiche-texte-perso { min-height: 0; font-size: 7.5pt; line-height: 1.3; margin: 0; }

    /* CAPACITÉS & TRAITS — rendu inline ultra-compact :
       « Classe (Moine) : Défense sans armure • Arts martiaux • ... » */
    .dnd-fiche-officielle .dnd-fiche-capacites { min-height: 0; padding: 4px 8px 12px; }
    .dnd-fiche-officielle .dnd-capacite-section {
        margin-bottom: 2px;
        font-size: 7pt;
        line-height: 1.3;
    }
    .dnd-fiche-officielle .dnd-capacite-section h5 {
        display: inline;
        font-size: 7pt;
        margin: 0;
        padding: 0;
        border: none;
        font-family: 'Cinzel', Georgia, serif;
        color: #6b4423;
    }
    .dnd-fiche-officielle .dnd-capacite-section h5::after { content: ' : '; }
    .dnd-fiche-officielle .dnd-capacite-section ul {
        display: inline;
        list-style: none;
        padding: 0;
        margin: 0;
    }
    .dnd-fiche-officielle .dnd-capacite-section ul li {
        display: inline;
        font-size: 7pt;
    }
    .dnd-fiche-officielle .dnd-capacite-section ul li:not(:last-child)::after {
        content: ' • ';
        color: #6b4423;
        font-weight: 700;
    }
    .dnd-fiche-officielle .dnd-capacite-section p { display: inline; font-size: 7pt; margin: 0; }

    /* Évite les coupures intempestives */
    .dnd-fiche-officielle .dnd-fiche-encadre {
        page-break-inside: avoid;
        break-inside: avoid;
    }
}

/* ============================================================
   RESPONSIVE — sur mobile la fiche passe en mode empilé
   ============================================================ */
@media screen and (max-width: 1100px) {
    .dnd-fiche-corps {
        grid-template-columns: 110px 1fr;
    }
    .dnd-fiche-col-droite,
    .dnd-fiche-col-perso {
        grid-column: 2;
    }
}

@media screen and (max-width: 720px) {
    .dnd-fiche-corps {
        grid-template-columns: 1fr;
    }
    .dnd-fiche-col-stats {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .dnd-stat-bloc {
        flex: 1 1 calc(33% - 8px);
        aspect-ratio: auto;
        padding: 8px 4px;
    }
    .dnd-fiche-entete {
        grid-template-columns: 1fr;
    }
    .dnd-fiche-entete-grille {
        grid-template-columns: 1fr 1fr;
    }
}
