/* Family Tree Container */
.family-tree-container {
    position: relative;
    overflow: auto;
    min-height: 500px;
    padding: 20px;
    background: var(--tree-background, #f5f7fa);
    transition: all 0.3s ease;
}

.tree-wrapper {
    display: flex;
    justify-content: center;
    min-width: max-content;
}

/* Tree Controls with SVG Fallbacks */
.tree-controls {
    position: sticky;
    top: 80px;
    right: 20px;
    z-index: 100;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.tree-controls button {
    background: white;
    border: 1px solid #e1e8ed;
    border-radius: 5px;
    padding: 10px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    font-size: 16px;
    min-width: 40px;
    text-align: center;
}

.tree-controls button:hover {
    background: var(--primary-color, #4a90e2);
    color: white;
    transform: scale(1.05);
}

/* SVG Icons - Used as fallback if Font Awesome fails */
.tree-controls button svg {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    stroke: currentColor;
    fill: none;
}

.tree-controls button:hover svg {
    stroke: white;
}

/* Hide SVG when Font Awesome is available */
.fa, .fas, .far {
    font-family: 'Font Awesome 6 Free', 'Font Awesome 5 Free', 'FontAwesome', sans-serif;
}

/* Tree View Styles */
.tree-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.family-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    margin: 20px;
}

.couple-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    position: relative;
}

.spouse-connection {
    display: flex;
    align-items: center;
    gap: 20px;
}

.horizontal-line {
    width: 50px;
    height: 2px;
    background: var(--tree-line-color, #4a90e2);
}

.vertical-line {
    width: 2px;
    height: 40px;
    background: var(--tree-line-color, #4a90e2);
    margin: 10px auto;
}

.children-connection {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
    position: relative;
}

.children-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 40px;
    margin-top: 20px;
    position: relative;
}

.children-container::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--tree-line-color, #4a90e2);
}

.child-wrapper {
    position: relative;
}

/* Vertical Tree Styles */
.vertical-tree {
    display: flex;
    flex-direction: column;
}

.tree-level {
    margin: 20px 0;
    position: relative;
}

.couple-container-vertical {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    position: relative;
}

.spouse-connection-vertical {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 10px;
}

.children-wrapper-vertical {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
    position: relative;
}

.children-container-vertical {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 40px;
    margin-top: 20px;
    position: relative;
}

.children-container-vertical::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--tree-line-color, #4a90e2);
}

/* Horizontal Tree Styles */
.horizontal-tree {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.horizontal-generation {
    margin: 20px 0;
}

.couple-row {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-bottom: 20px;
}

.children-connection-horizontal {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-left: 40px;
    position: relative;
}

.children-row {
    display: flex;
    gap: 50px;
    margin-top: 20px;
    position: relative;
}

.children-row::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--tree-line-color, #4a90e2);
}

/* Compact Tree Styles */
.compact-tree {
    display: inline-block;
}

.compact-family-unit {
    position: relative;
    padding: 10px;
}

.compact-couple {
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative;
}

.compact-children-connection {
    margin-top: 20px;
    padding-top: 20px;
    position: relative;
}

.compact-children-connection::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 20px;
    background: var(--tree-line-color, #4a90e2);
    transform: translateX(-50%);
}

.compact-children-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    justify-content: center;
    margin-top: 20px;
}

/* Family Member Card */
.family-member-card {
    position: relative;
    width: 220px;
    background: var(--card-background, #ffffff);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}

.family-member-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.15);
}

.family-member-card.deceased {
    opacity: 0.85;
    background: #f8f9fa;
}

.family-member-card.deceased::before {
    content: '🕊️';
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 20px;
    z-index: 1;
}

.spouse-card {
    border-left: 4px solid var(--primary-color, #4a90e2);
}

.member-photo {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.member-photo-placeholder {
    width: 100%;
    height: 180px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.member-photo-placeholder i,
.member-photo-placeholder svg {
    font-size: 80px;
    width: 80px;
    height: 80px;
    color: white;
}

.member-info {
    padding: 15px;
}

.member-name {
    font-size: 1.1rem;
    font-weight: bold;
    margin: 0 0 5px 0;
    color: var(--secondary-color, #2c3e50);
}

.member-dates {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 8px;
}

.member-died {
    display: inline-block;
    margin-left: 8px;
    color: #e74c3c;
    font-size: 0.75rem;
}

.member-bio-excerpt {
    font-size: 0.85rem;
    color: #555;
    line-height: 1.4;
    margin-top: 8px;
}

/* Modal Styles */
.member-bio-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    animation: slideIn 0.3s ease;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #999;
    transition: color 0.3s ease;
    z-index: 1;
}

.close-modal:hover {
    color: #333;
}

.member-bio-full {
    padding: 2rem;
}

.member-bio-photo {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.bio-details {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
}

.bio-text {
    margin-top: 1rem;
}

.bio-text h3 {
    color: var(--primary-color, #4a90e2);
    margin-bottom: 0.5rem;
}

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

/* Error State */
.family-tree-error,
.condolence-error,
.condolence-info {
    text-align: center;
    padding: 60px 20px;
    background: #f8f9fa;
    border-radius: 12px;
    margin: 20px 0;
    border: 1px solid #e1e8ed;
}

.family-tree-error i,
.condolence-error i,
.condolence-info i,
.family-tree-error svg,
.condolence-error svg,
.condolence-info svg {
    font-size: 64px;
    width: 64px;
    height: 64px;
    color: var(--primary-color, #4a90e2);
    margin-bottom: 20px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.family-tree-error p,
.condolence-error p,
.condolence-info p {
    margin: 0;
    color: #666;
    font-size: 16px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .family-member-card {
        width: 180px;
    }
    
    .member-photo,
    .member-photo-placeholder {
        height: 150px;
    }
    
    .couple-container,
    .couple-row {
        flex-direction: column;
    }
    
    .spouse-connection,
    .spouse-connection-vertical {
        flex-direction: column;
    }
    
    .horizontal-line {
        width: 2px;
        height: 30px;
    }
    
    .children-container,
    .children-container-vertical {
        flex-direction: column;
        align-items: center;
    }
    
    .children-container::before,
    .children-container-vertical::before {
        width: 2px;
        height: 100%;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
    
    .children-row {
        flex-direction: column;
        align-items: center;
    }
    
    .children-row::before {
        width: 2px;
        height: 100%;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
    
    .tree-controls button {
        padding: 8px 12px;
    }
    
    .tree-controls button svg {
        width: 14px;
        height: 14px;
    }
}

/* Print Styles */
@media print {
    .tree-controls,
    .member-bio-modal,
    .no-print {
        display: none !important;
    }
    
    .family-member-card {
        break-inside: avoid;
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .family-tree-container {
        overflow: visible;
        padding: 0;
    }
}

/* Animation for loading */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.family-tree-container {
    animation: fadeIn 0.5s ease;
}