/* Tree Visualization Styles */
.tree {
    width: 100%;
    overflow-x: auto;
    padding: 2rem 0;
    min-height: 500px;
}

.tree ul {
    padding-top: 20px;
    position: relative;
    transition: all 0.5s;
    display: flex;
    justify-content: center;
    margin: 0;
}

.tree li {
    float: left;
    text-align: center;
    list-style-type: none;
    position: relative;
    padding: 20px 10px 0 10px;
    transition: all 0.5s;
}

/* We will use ::before and ::after to draw the connectors */
.tree li::before,
.tree li::after {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 2px solid var(--text-secondary);
    width: 50%;
    height: 20px;
}

.tree li::after {
    right: auto;
    left: 50%;
    border-left: 2px solid var(--text-secondary);
}

/* Remove connectors from the single root node elements if they act as roots */
.tree li:only-child::after,
.tree li:only-child::before {
    display: none;
}

.tree li:only-child {
    padding-top: 0;
}

.tree li:first-child::before,
.tree li:last-child::after {
    border: 0 none;
}

/* Adding the curve connectors */
.tree li:last-child::before {
    border-right: 2px solid var(--text-secondary);
    border-radius: 0 5px 0 0;
}

.tree li:first-child::after {
    border-radius: 5px 0 0 0;
}

/* Time to add the downward connector from the parent */
.tree ul ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    border-left: 2px solid var(--text-secondary);
    width: 0;
    height: 20px;
}

/* Fix for Root Level Horizontal Connection Only (No Verticals) */
.tree>ul>li::after {
    border-left: 0 none;
}

.tree>ul>li:last-child::before {
    border-right: 0 none;
}

.tree>ul>li::before {
    border-top: 2px solid var(--text-secondary);
}

.tree>ul>li::after {
    border-top: 2px solid var(--text-secondary);
}

.tree>ul>li:first-child::before {
    border: 0 none;
}

.tree>ul>li:last-child::after {
    border: 0 none;
}


/* The Node Card itself */
.tree-node-card {
    background: #27272a;
    /* Zinc 800 */
    border: 1px solid #3f3f46;
    /* Zinc 700 */
    padding: 1rem;
    border-radius: 12px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.3s ease;
    min-width: 180px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    position: relative;
    z-index: 2;
}

.tree-node-card:hover {
    background: #18181b;
    /* Zinc 900 */
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(var(--theme-primary-rgb), 0.3);
    /* Orange Shadow */
    border-color: var(--theme-orange);
    /* Orange Border */
}

.tree-node-card .avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin-bottom: 0.75rem;
    border: 2px solid var(--theme-orange);
    /* Orange Border */
    object-fit: cover;
}

.tree-node-card h4 {
    margin: 0.25rem 0;
    font-size: 1rem;
    font-weight: 600;
}

.tree-node-card p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.tree-node-card .details-badge {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    background: rgba(var(--theme-primary-rgb), 0.15);
    /* Orange Tint */
    color: var(--theme-orange);
    /* Light Orange text */
    padding: 2px 8px;
    border-radius: 12px;
    border: 1px solid rgba(var(--theme-primary-rgb), 0.3);
}

/* Modal/Edit Panel Styles */
.node-edit-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.node-edit-content {
    background: rgba(24, 24, 27, 0.85);
    /* Glassmorphism base */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: 16px;
    width: 400px;
    max-width: 90%;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.node-edit-content h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.form-group {
    margin-bottom: 1.25rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.form-group input,
.form-group textarea,
/* Ensure plain inputs match premium styles */
.node-edit-content input[type="text"],
.node-edit-content textarea {
    width: 100%;
    padding: 0.75rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    /* Premium Input Pattern */
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.95rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-group input:focus,
.form-group textarea:focus,
.node-edit-content input[type="text"]:focus,
.node-edit-content textarea:focus {
    outline: none;
    border-color: var(--theme-orange);
    box-shadow: 0 0 0 2px rgba(var(--theme-primary-rgb), 0.2);
    background: rgba(0, 0, 0, 0.4);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

.btn-secondary {
    background: transparent;
    border: 1px solid #3f3f46;
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: #27272a;
    border-color: #52525b;
}

.btn-primary {
    background: var(--primary-gradient);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(var(--theme-primary-rgb), 0.3);
    transition: all 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(var(--theme-primary-rgb), 0.5);
}