/**
 * Gene-Niegles CMS - Styles Arbre Généalogique
 * Inspiré de ma-genealogie-tree.css
 */

.tree-page {
    min-height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
}

.tree-header {
    background: var(--bg-secondary);
    padding: var(--spacing-lg) 0;
    border-bottom: 1px solid var(--border);
}

.tree-header h1 {
    font-size: var(--font-xl);
    margin-top: var(--spacing-md);
}

.tree-controls {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

.tree-page .tree-controls .tree-btn {
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    background: #ffffff !important;
    border: 1px solid #d1d5db !important;
    color: #374151 !important;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
    transform: none !important;
}

.tree-page .tree-controls .tree-btn svg {
    width: 20px !important;
    height: 20px !important;
    stroke: #374151 !important;
    stroke-width: 2 !important;
    fill: none !important;
    display: block !important;
}

.tree-page .tree-controls .tree-btn:hover {
    background: #8b5cf6 !important;
    border-color: #8b5cf6 !important;
    color: white !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 6px rgba(0,0,0,0.15) !important;
}

.tree-page .tree-controls .tree-btn:hover svg {
    stroke: white !important;
}

/* Container de l'arbre */
.tree-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--bg);
    cursor: grab;
}

.tree-container:active {
    cursor: grabbing;
}

.tree-canvas {
    position: absolute;
    min-width: 100%;
    min-height: 100%;
    transform-origin: 0 0;
    transition: transform 0.1s ease-out;
}

.tree-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--spacing-md);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Légende */
.tree-legend {
    position: fixed;
    bottom: var(--spacing-lg);
    left: var(--spacing-lg);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    z-index: 100;
    max-width: 200px;
}

.tree-legend h4 {
    font-size: var(--font-sm);
    margin-bottom: var(--spacing-sm);
    color: var(--text-secondary);
}

.legend-items {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: var(--font-sm);
    color: var(--text-secondary);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: var(--radius-sm);
}

.legend-color.parents { background: #3b82f6; }
.legend-color.selected { background: #f59e0b; }
.legend-color.siblings { background: #8b5cf6; }
.legend-color.spouses { background: #ec4899; }
.legend-color.children { background: #22c55e; }

/* Cartes de l'arbre */
.tree-person {
    position: absolute;
    width: 180px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    color: var(--text);
}

.tree-person:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
    z-index: 10;
}

/* Types de personnes */
.tree-person.selected {
    border-color: #f59e0b;
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
}

.tree-person.parent {
    border-color: #3b82f6;
}

.tree-person.sibling {
    border-color: #8b5cf6;
}

.tree-person.spouse {
    border-color: #ec4899;
}

.tree-person.child {
    border-color: #22c55e;
}

/* Genre */
.tree-person.m {
    border-left-width: 4px;
    border-left-color: var(--male);
}

.tree-person.f {
    border-left-width: 4px;
    border-left-color: var(--female);
}

.tree-person-avatar {
    width: 50px;
    height: 50px;
    margin: 0 auto var(--spacing-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-elevated);
}

.tree-person.m .tree-person-avatar { color: var(--male); }
.tree-person.f .tree-person-avatar { color: var(--female); }

.tree-person-avatar svg {
    width: 28px;
    height: 28px;
}

.tree-person-name {
    font-weight: 600;
    font-size: var(--font-sm);
    margin-bottom: 2px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.3;
}

.tree-person-dates {
    font-size: var(--font-xs);
    color: var(--text-secondary);
}

/* Lignes de connexion */
.tree-line {
    position: absolute;
    background: var(--border);
    pointer-events: none;
}

.tree-line.horizontal {
    height: 2px;
}

.tree-line.vertical {
    width: 2px;
}

.tree-line.parent { background: #3b82f6; }
.tree-line.spouse { background: #ec4899; }
.tree-line.child { background: #22c55e; }
.tree-line.sibling { background: #8b5cf6; }

/* Générations */
.tree-generation {
    position: absolute;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: var(--spacing-xl);
}

.tree-generation.grandparents {
    top: 0;
}

.tree-generation.parents {
    top: 200px;
}

.tree-generation.main {
    top: 400px;
}

.tree-generation.children {
    top: 600px;
}

/* Responsive */
@media (max-width: 768px) {
    .tree-legend {
        bottom: auto;
        top: var(--spacing-lg);
        left: var(--spacing-sm);
        right: var(--spacing-sm);
        max-width: none;
    }

    .legend-items {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .tree-person {
        width: 140px;
        padding: var(--spacing-sm);
    }

    .tree-person-avatar {
        width: 40px;
        height: 40px;
    }

    .tree-person-avatar svg {
        width: 20px;
        height: 20px;
    }
}
