* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    color: #333;
    font-size: 24px;
}

.controls {
    display: flex;
    gap: 10px;
}

.controls button {
    padding: 8px 15px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
}

.controls button:hover {
    background: #45a049;
}

.main-content {
    display: flex;
    gap: 20px;
}

.sidebar {
    flex: 0 0 300px;
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.tree-container {
    flex: 1;
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    overflow: auto;
    min-height: 600px;
}

#tree {
    width: 100%;
    height: 100%;
}

/* Tree Node Styles */
.node {
    cursor: pointer;
    transition: all 0.3s;
}

.node rect {
    fill: #fff;
    stroke: #4CAF50;
    stroke-width: 2px;
    rx: 5;
    ry: 5;
}

.node.male rect {
    fill: #e3f2fd;
}

.node.female rect {
    fill: #fce4ec;
}

.node text {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    fill: #333;
}

.link {
    fill: none;
    stroke: #999;
    stroke-width: 2px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    position: relative;
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    cursor: pointer;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.btn-submit {
    background: #4CAF50;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    width: 100%;
}

/* Member Details */
#memberDetails {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

/* Search */
#searchInput {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
}

#searchResults {
    max-height: 200px;
    overflow-y: auto;
}

.search-result-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.search-result-item:hover {
    background: #f0f0f0;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        flex: none;
        width: 100%;
    }
}

/* Empty and Error States */
.empty-state, .error-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-state i, .error-state i {
    margin-bottom: 20px;
    color: #ddd;
}

.error-state i {
    color: #ff6b6b;
}

.btn-add-root {
    background: #4CAF50;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    margin-top: 20px;
}

.btn-add-root:hover {
    background: #45a049;
}

/* Member Card in Sidebar */
.member-card {
    background: #f8f9fa;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.member-header {
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.member-header.male {
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
}

.member-header.female {
    background: linear-gradient(135deg, #E91E63 0%, #C2185B 100%);
}

.member-header i {
    font-size: 24px;
}

.member-header h4 {
    margin: 0;
    flex: 1;
}

.gender-badge {
    background: rgba(255,255,255,0.2);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

.member-info {
    padding: 15px;
}

.member-info p {
    margin: 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.member-info i {
    color: #666;
    width: 20px;
}

.member-actions {
    padding: 15px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-action {
    flex: 1;
    padding: 8px 12px;
    background: #f0f0f0;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn-action:hover {
    background: #e0e0e0;
}

/* Search Results */
.search-result-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-result-item:hover {
    background: #f5f5f5;
}

.search-result-item i {
    font-size: 14px;
}

.search-result-item .male-icon {
    color: #2196F3;
}

.search-result-item .female-icon {
    color: #E91E63;
}

.search-gender {
    margin-left: auto;
    font-size: 12px;
    color: #999;
}

.no-results {
    padding: 10px;
    text-align: center;
    color: #999;
}

/* Modal */
.modal-content h2 {
    margin-bottom: 20px;
    color: #333;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #4CAF50;
}

/* Tree node hover effects */
.node:hover rect {
    stroke-width: 3px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.node.male:hover rect {
    stroke: #1976D2;
}

.node.female:hover rect {
    stroke: #C2185B;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .member-actions {
        flex-direction: column;
    }
    
    .node text {
        font-size: 10px;
    }
    
    .node rect {
        width: 100px;
        height: 40px;
        x: -50;
        y: -20;
    }
}