/* ==========================================================================
   Livre Généalogique du Cheval — Styles front-end
   ========================================================================== */

/* ---------- Carte Leaflet inline (fiche cheval) ---------- */
.leaflet-map.leaflet-container.leaflet-touch.leaflet-fade-anim.leaflet-grab.leaflet-touch-drag.leaflet-touch-zoom {
    height: 240px !important;
}

/* ---------- Widget cheval (pedigree box) ---------- */
.cheval-widget {
    text-align: center;
    margin-bottom: 20px;
    border: 2px solid #ccc;
    border-radius: 20px;
    padding: 10px;
    background-color: #f9f9f9;
    box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.1);
    width: 200px;
}

.cheval-widget .image-cheval img {
    max-width: 100px;
    height: auto;
    border-radius: 10px;
}

.cheval-widget a {
    text-decoration: none;
    color: inherit;
}

h3.cheval-widget__nom {
    font-size: 14px;
}

/* ---------- Pedigree container ---------- */
.pedigree-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.cheval-actuel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.parent {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.pedigree-container > div {
    display: flex;
    gap: 40px;
}

/* ---------- Pedigree arbre (structure imbriquée) ---------- */
.pedigree {
    overflow: auto;
    width: 100%;
    padding: 20px 10px;
}

/* L'arbre prend sa largeur naturelle, le scroll et centrage sont gérés par JS */
.pedigree > .ped-node {
    width: max-content;
}

.pedigree img {
    border-radius: 10px;
    width: 90%;
    height: 120px;
    object-fit: cover;
}

/* Base commune pour toutes les boîtes pedigree */
.ped-box {
    font-size: 13px;
    width: 210px;
    min-height: 180px;
    border: 2px solid #bdbdbd;
    text-align: center;
    padding: 5px;
    border-radius: 10px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-shrink: 0;
}

.ped-box .cheval-widget__nom {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.box-gen0 {
    color: #000;
}

/* Reset : empêcher tout ::before/::after externe sur les boîtes */
.ped-box::before,
.ped-box::after {
    content: none !important;
    display: none !important;
}

/* Boîtes gen2 */
.box-gen2 {
    width: 190px;
    min-height: 160px;
    font-size: 12px;
}
.box-gen2 img { height: 100px; }

/* Boîtes gen3+ : taille réduite progressivement */
.box-gen3 {
    width: 160px;
    min-height: 140px;
    font-size: 11px;
}
.box-gen3 img { height: 80px; }

.box-gen4 {
    width: 140px;
    min-height: 120px;
    font-size: 10px;
}
.box-gen4 img { height: 65px; }

.box-gen5 {
    width: 120px;
    min-height: 100px;
    font-size: 9px;
}
.box-gen5 img { height: 50px; }

/* ---------- Structure arbre pedigree ---------- */
.ped-node {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: relative;
}

/* Les boîtes se centrent dans leur nœud (les branches restent en stretch pour éviter le débordement gauche) */
.ped-box {
    align-self: center;
}

.ped-expand {
    align-self: center;
}

.ped-branches {
    display: flex;
    position: relative;
    margin-top: 20px;
    padding-top: 20px;
}

.ped-branches > .ped-node {
    flex: 1 1 0;
}

/* ---------- Lignes de connexion pedigree ---------- */

/* Trait vertical du parent vers la barre horizontale */
.ped-branches::before {
    content: "";
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 20px;
    background: #bdbdbd;
    z-index: 1;
}

/* Demi-barre horizontale : du centre de chaque enfant vers la frontière commune */
.ped-branches > .ped-node::after {
    content: "";
    position: absolute;
    top: -20px;
    height: 2px;
    background: #bdbdbd;
}

/* Premier enfant (père) : barre du centre vers le bord droit */
.ped-branches > .ped-node:first-child::after {
    left: 50%;
    right: 0;
}

/* Dernier enfant (mère) : barre du bord gauche vers le centre */
.ped-branches > .ped-node:last-child::after {
    left: 0;
    right: 50%;
}

/* Trait vertical de la barre vers chaque enfant */
.ped-branches > .ped-node::before {
    content: "";
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 20px;
    background: #bdbdbd;
}

/* ---------- Bouton expansion pedigree ---------- */
.ped-expand,
.ped-expand:link,
.ped-expand:visited {
    all: unset !important;
    align-self: center !important;
    display: block !important;
    position: relative !important;
    margin: 10px auto 0 !important;
    width: 30px !important;
    height: 30px !important;
    border-radius: 50% !important;
    border: 2px solid #bdbdbd !important;
    background: transparent !important;
    cursor: pointer !important;
    transition: border-color 0.2s ease, background 0.2s ease !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    box-shadow: none !important;
}

/* Barre horizontale et verticale du + dessiné en CSS */
.ped-expand::before,
.ped-expand::after {
    content: "" !important;
    display: block !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    background: #bdbdbd !important;
    border-radius: 1px !important;
}

.ped-expand::before {
    width: 14px !important;
    height: 2px !important;
    transform: translate(-50%, -50%) !important;
}

.ped-expand::after {
    width: 2px !important;
    height: 14px !important;
    transform: translate(-50%, -50%) !important;
}

.ped-expand:hover,
.ped-expand:focus {
    background: #bdbdbd !important;
    transform: scale(1.1) !important;
    outline: none !important;
}

.ped-expand:hover::before,
.ped-expand:hover::after,
.ped-expand:focus::before,
.ped-expand:focus::after {
    background: #222 !important;
}

.ped-expand:disabled {
    cursor: wait !important;
    opacity: 0.5 !important;
    transform: none !important;
}

/* ---------- Indicateur de chargement pedigree ---------- */
.ped-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 10px 16px;
    color: #666;
    font-size: 13px;
}

.ped-loading__spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e0e0e0;
    border-top-color: #888;
    border-radius: 50%;
    animation: pedSpin 0.7s linear infinite;
}

@keyframes pedSpin {
    to { transform: rotate(360deg); }
}

/* Animation d'apparition des branches chargées */
.ped-branches--expanded {
    animation: pedFadeIn 0.3s ease forwards;
}

@keyframes pedFadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Pedigree responsive ---------- */
@media screen and (max-width: 820px) {
    .pedigree {
        overflow-x: auto;
    }
}

/* ---------- Produits (descendants) ---------- */
.produits-container {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.produit {
    text-align: center;
    border: 1px solid #ccc;
    padding: 5px;
    border-radius: 10px;
    width: 110px;
    background-color: #f9f9f9;
    transition: transform 0.2s ease-in-out;
}

@media screen and (max-width: 421px) {
    .produit {
        width: 31%;
    }
}

.produit:hover {
    transform: scale(1.05);
}

.produit img {
    width: 100px;
    height: auto;
    border-radius: 8px;
}

.produit p {
    margin: 5px 0 0;
    font-size: 14px;
    font-weight: bold;
}

.produit-details {
    color: #6f6f6f;
    line-height: 0.95em;
}

p.produit-robe,
p.produit-score {
    font-weight: normal;
}

.produit a {
    text-decoration: none;
    color: inherit;
}

/* ---------- Pointage ---------- */
.pointage-container {
    display: flex;
    gap: 30px;
    font-weight: bold;
}

/* ---------- Tableau chevaux ---------- */
.tableau-chevaux {
    overflow-x: auto;
}
