/* ============================================
   heterosis - GENEALOGY (arbre généalogique GENOTYPE)
   Popup + arbre ascendant / descendant
   ============================================ */

/* ====================================
   OVERLAY & MODAL
   ==================================== */

.gen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 12000;
}

.gen-overlay.active {
    display: flex;
}

.gen-modal {
    background: var(--color-white);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    width: 92%;
    max-width: 1100px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ====================================
   HEADER
   ==================================== */

.gen-header {
    padding: 16px 20px;
    background: var(--gradient-primary);
    color: var(--color-white);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gen-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
}

.gen-close {
    background: none;
    border: none;
    color: var(--color-white);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.gen-close:hover {
    opacity: 0.8;
}

/* ====================================
   TOOLBAR
   ==================================== */

.gen-toolbar {
    padding: 12px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    background: #fafafa;
}

.gen-toolbar label {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.gen-input {
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 14px;
    min-width: 220px;
}

.gen-input:focus {
    outline: none;
    border-color: var(--color-primary);
    background: var(--color-white);
}

.gen-btn {
    padding: 6px 14px;
    border: 1px solid var(--color-primary);
    border-radius: var(--border-radius);
    background: var(--color-primary);
    color: var(--color-white);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-base);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.gen-btn:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

.gen-btn.gen-btn-light {
    background: var(--color-white);
    color: var(--color-primary);
}

.gen-btn.gen-btn-light:hover {
    background: #e3eaff;
    color: var(--color-primary-dark);
}

/* Bascule Ascendant / Descendant */
.gen-direction {
    display: inline-flex;
    border: 1px solid var(--color-primary);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.gen-dir-btn {
    padding: 6px 14px;
    border: none;
    background: var(--color-white);
    color: var(--color-primary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-base);
}

.gen-dir-btn + .gen-dir-btn {
    border-left: 1px solid var(--color-primary);
}

.gen-dir-btn:hover {
    background: #e3eaff;
}

.gen-dir-btn.active {
    background: var(--color-primary);
    color: var(--color-white);
}

.gen-species-tag {
    margin-left: auto;
    font-size: 13px;
    border-radius: 12px;
    padding: 3px 12px;
    font-weight: 600;
    color: var(--color-primary);
    background: #e3eaff;
}

/* ====================================
   MESSAGE
   ==================================== */

.gen-message {
    font-size: 14px;
}

.gen-message:not(:empty) {
    padding: 10px 20px;
}

.gen-message.error {
    background: #fdecea;
    color: #d32f2f;
    border-bottom: 1px solid #f5c6cb;
}

.gen-message.warning {
    background: #fff8e1;
    color: #8a6d3b;
    border-bottom: 1px solid #ffe8a1;
}

.gen-message.info {
    background: #e3eaff;
    color: var(--color-primary);
    border-bottom: 1px solid #b0c4de;
}

/* ====================================
   ARBRE
   ==================================== */

.gen-tree {
    padding: 20px;
    overflow: auto;
    flex: 1;
    min-height: 200px;
}

.gen-tree ul {
    list-style: none;
    margin: 0;
    padding-left: 22px;
    position: relative;
}

.gen-tree > ul {
    padding-left: 0;
}

.gen-tree li {
    position: relative;
}

/* Lignes de connexion (arbre type explorateur de fichiers) */
.gen-tree ul ul {
    border-left: 1px solid #cfd8dc;
}

.gen-tree ul ul > li::before {
    content: "";
    position: absolute;
    left: -22px;
    top: 16px;
    width: 16px;
    height: 1px;
    background: #cfd8dc;
}

.gen-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px 3px 4px;
    margin: 1px 0;
    border-radius: var(--border-radius);
    transition: background 0.18s;
    max-width: 100%;
}

.gen-label:hover {
    background: #f0f4ff;
}

.gen-caret {
    width: 16px;
    min-width: 16px;
    border: none;
    background: none;
    color: var(--color-primary);
    cursor: pointer;
    font-size: 11px;
    padding: 0;
    line-height: 1;
}

.gen-caret.gen-caret-empty {
    cursor: default;
    color: transparent;
}

.gen-code {
    border: none;
    background: none;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    color: var(--color-primary);
    cursor: pointer;
    padding: 0;
    text-align: left;
}

.gen-code:hover {
    text-decoration: underline;
}

/* Racine mise en évidence */
.gen-label.gen-root .gen-code {
    font-size: 17px;
    font-weight: 700;
}

.gen-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    border-radius: 3px;
    padding: 1px 6px;
    letter-spacing: 0.4px;
    white-space: nowrap;
}

.gen-badge-female {
    background: #fce4ec;
    color: #ad1457;
}

.gen-badge-male {
    background: #e3f2fd;
    color: #1565c0;
}

.gen-badge-missing {
    background: #fff3e0;
    color: #e65100;
}

.gen-badge-cycle {
    background: #ede7f6;
    color: #4527a0;
}

.gen-badge-truncated {
    background: #eceff1;
    color: #455a64;
}

.gen-note {
    font-size: 12px;
    color: var(--color-text-secondary);
    font-style: italic;
}

.gen-label.gen-is-missing .gen-code {
    color: #e65100;
    font-style: italic;
    font-weight: 500;
}

.gen-label.gen-is-cycle .gen-code {
    color: #4527a0;
}

/* Nœud replié */
.gen-node.gen-collapsed > ul {
    display: none;
}

/* ====================================
   LEGENDE & FOOTER
   ==================================== */

.gen-footer {
    padding: 10px 20px;
    border-top: 1px solid #eee;
    background: #fafafa;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    font-size: 12px;
    color: var(--color-text-secondary);
}

.gen-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ====================================
   RESPONSIVE
   ==================================== */

@media (max-width: 768px) {
    .gen-modal {
        width: 96%;
        max-height: 94vh;
    }

    .gen-toolbar {
        gap: 8px;
    }

    .gen-input {
        min-width: 140px;
        flex: 1;
    }

    .gen-species-tag {
        margin-left: 0;
    }
}
