/* ── Constructeur d'arbre généalogique ── */

.constructeur-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}

.constructeur-toolbar__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.btn {
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(36, 30, 24, 0.85);
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
}

.btn:hover { background: var(--gold-soft); }

.btn--primary {
    border-color: var(--gold);
    color: var(--gold);
}

.btn--danger {
    border-color: rgba(220, 100, 100, 0.4);
    color: #e8a0a0;
}

/* ── Recherche intelligente ── */

.smart-search {
    position: relative;
    width: min(100%, 18rem);
    margin-inline: auto;
}

.smart-search__input {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font: inherit;
    font-size: 1rem;
}

.smart-search__input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-soft);
}

.smart-search__suggestions {
    position: absolute;
    z-index: 20;
    left: 0;
    right: 0;
    top: calc(100% + 0.35rem);
    max-height: 14rem;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
    box-shadow: var(--shadow);
}

.smart-search__suggestions:not([hidden]) {
    display: block;
}

.smart-search__empty {
    padding: 0.65rem 0.85rem;
    font-size: 0.85rem;
    color: var(--muted);
    text-align: center;
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    border-bottom: 1px solid rgba(212, 168, 106, 0.1);
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.92rem;
    text-align: left;
    cursor: pointer;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item--active {
    background: var(--gold-soft);
}

.suggestion-item strong {
    color: var(--gold);
    font-weight: 600;
}

.suggestion-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-soft);
}

/* ── Arbre par générations ── */

.gen-tree {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: max-content;
    min-width: 100%;
    padding: 0.5rem 0;
}

.gen-tree__links {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

.gen-tree__links path {
    fill: none;
    stroke: rgba(212, 168, 106, 0.55);
    stroke-width: 2;
}

.gen-tree__body {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.gen-row {
    display: flex;
    justify-content: center;
    width: 100%;
}

.gen-row__inner {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    justify-content: center;
    gap: 0;
}

.gen-row-gap {
    height: 1.75rem;
    width: 100%;
    flex-shrink: 0;
}

.gen-slot {
    width: var(--tree-person-w, 8.5rem);
    flex-shrink: 0;
    display: flex;
    justify-content: center;
}

.gen-slot-spacer {
    width: calc(var(--tree-person-w, 8.5rem) * 0.5);
    flex-shrink: 0;
}

.couple__connector {
    display: flex;
    align-items: center;
    align-self: flex-start;
    width: 3rem;
    height: calc(0.5rem + 6.5rem + 0.55rem);
    flex-shrink: 0;
    pointer-events: none;
}

.couple__link {
    width: 100%;
    height: 2px;
    background: var(--gold);
}

.person-bubble {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    z-index: 2;
}

.person-bubble .person {
    gap: 0.55rem;
}

.person-add {
    width: 1.65rem;
    height: 1.65rem;
    margin-top: 0.15rem;
    border-radius: 50%;
    border: 2px solid var(--bg-soft);
    background: linear-gradient(145deg, var(--gold), #8b5a2b);
    color: #1a1208;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    transition: transform 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
    position: relative;
    z-index: 3;
}

.person-add:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.add-menu {
    position: fixed;
    z-index: 40;
    min-width: 8.5rem;
    padding: 0.35rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    box-shadow: var(--shadow);
}

.add-menu[hidden] {
    display: none;
}

.add-menu__item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    padding: 0.45rem 0.65rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
}

.add-menu__item:hover {
    background: var(--gold-soft);
    color: var(--gold);
}

.add-menu__item--danger {
    color: #e8a0a0;
}

.add-menu__item--danger:hover {
    background: rgba(220, 100, 100, 0.12);
    color: #f0b0b0;
}

.add-menu__icon {
    width: 1.1rem;
    text-align: center;
    opacity: 0.85;
}

.person__avatar--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--display);
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--gold);
    background: var(--card);
}

/* ── Écran de départ ── */

.constructeur-start {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    min-height: 16rem;
    padding: 2rem 1rem;
    text-align: center;
}

.constructeur-start__title {
    margin: 0;
    font-family: var(--display);
    font-size: 1.35rem;
    font-weight: 600;
}

.constructeur-start__hint {
    margin: 0;
    font-size: 0.88rem;
    color: var(--muted);
}

/* ── Picker flottant (ajout parent/enfant) ── */

.picker-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.45);
}

.picker-overlay[hidden] {
    display: none;
}

.picker {
    width: min(100%, 20rem);
    padding: 1.15rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-soft);
    box-shadow: var(--shadow);
}

.picker__title {
    margin: 0 0 0.75rem;
    font-family: var(--display);
    font-size: 1.15rem;
    font-weight: 600;
}

.picker__hint {
    margin: 0 0 0.75rem;
    font-size: 0.78rem;
    color: var(--muted);
}

.picker__error {
    margin: 0.5rem 0 0;
    font-size: 0.82rem;
    color: #e8a0a0;
}

.picker__actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.85rem;
}

.constructeur-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
}

@media (max-width: 640px) {
    .gen-slot {
        width: 7rem;
    }

    .person-add {
        opacity: 1;
    }
}
