/* ==========================================
   EIP Org Chart Tree Specific Stylesheet
   Theme: Sleek Dark Glassmorphism Zoomable Tree
   ========================================== */

/* Main Layout & Viewport */
.org-chart-main {
    position: relative;
    overflow: hidden;
    background: radial-gradient(circle at center, hsla(222, 25%, 18%, 0.8) 0%, var(--bg-main) 100%);
    display: flex;
    flex-direction: column;
}

.org-chart-viewport {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    cursor: grab;
    user-select: none;
    outline: none;
}

.org-chart-viewport:active {
    cursor: grabbing;
}

.org-chart-canvas {
    position: absolute;
    width: max-content;
    height: max-content;
    transform-origin: 0 0; /* Important for scroll and drag zooming zoom-to-cursor mechanics */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 300px; /* Huge padding to allow scrolling beyond bounds */
    will-change: transform;
}

/* Sidebar Custom Controls Styling */
.control-section {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.control-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.control-btn {
    background: hsla(222, 25%, 16%, 0.6);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 600;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-fast);
}

.control-btn:hover {
    color: var(--text-primary);
    background-color: hsla(222, 20%, 20%, 0.5);
    border-color: hsla(201, 90%, 55%, 0.4);
}

.control-btn i {
    font-size: 14px;
    color: var(--accent);
}

.zoom-indicator-box {
    background-color: hsla(222, 20%, 8%, 0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12.5px;
}

.zoom-indicator-box span {
    color: var(--text-secondary);
}

.zoom-indicator-box strong {
    color: var(--accent);
}

.zoom-quick-controls {
    display: flex;
    gap: 4px;
}

.zoom-quick-controls button {
    background: hsla(222, 20%, 20%, 0.5);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 26px;
    height: 26px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 11px;
    transition: var(--transition-fast);
}

.zoom-quick-controls button:hover {
    color: var(--text-primary);
    border-color: var(--accent);
    background-color: hsla(201, 90%, 55%, 0.15);
}

/* Department Search & Feedback */
.dept-search-section {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.search-box-wrapper {
    position: relative;
}

#dept-search-input {
    width: 100%;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 32px 10px 12px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: var(--transition-fast);
}

#dept-search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}

.feedback-text {
    font-size: 11.5px;
    margin-top: 6px;
    min-height: 16px;
    color: var(--text-muted);
}

.feedback-text.success {
    color: var(--accent);
}

.feedback-text.error {
    color: hsl(0, 80%, 65%);
}

.tips-section {
    padding: 20px 24px;
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.6;
}

.tip-title {
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Department Card Node in the Tree */
.node-card {
    background-color: hsla(222, 25%, 16%, 0.7);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    width: 190px;
    text-align: center;
    cursor: pointer;
    position: relative;
    display: inline-block;
    vertical-align: middle;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(8px);
    transition: transform var(--transition-fast), border-color var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
    z-index: 10;
}

.node-card:hover {
    border-color: hsla(201, 90%, 55%, 0.5);
    background-color: hsla(222, 25%, 22%, 0.85);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5), 0 0 12px hsla(201, 90%, 55%, 0.15);
    transform: translateY(-2px);
}

.node-card.selected-node {
    border-color: var(--accent);
    background-color: hsla(201, 90%, 55%, 0.1);
    box-shadow: 0 0 15px hsla(201, 90%, 55%, 0.3);
}

.node-card.highlighted {
    border-color: var(--accent-secondary);
    background-color: hsla(260, 75%, 65%, 0.12);
    box-shadow: 0 0 20px hsla(260, 75%, 65%, 0.35);
    animation: pulseGlow 1.5s infinite alternate;
}

@keyframes pulseGlow {
    from { box-shadow: 0 0 10px hsla(260, 75%, 65%, 0.2); }
    to { box-shadow: 0 0 25px hsla(260, 75%, 65%, 0.6); }
}

.node-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.node-info-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.node-info-row span {
    display: flex;
    align-items: center;
    gap: 3px;
}

.node-info-row .count-val {
    color: var(--accent);
    font-weight: 600;
}

/* Node Toggle Collapse Button */
.node-toggle-btn {
    position: absolute;
    background-color: hsla(222, 25%, 10%, 0.9);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    cursor: pointer;
    transition: var(--transition-fast);
    z-index: 15;
}

.node-toggle-btn:hover {
    color: #fff;
    border-color: var(--accent);
    background-color: var(--accent);
    transform: scale(1.1);
}

/* ==========================================
   CSS Vertical Tree Connector Lines
   ========================================== */
.tree.vertical ul {
    padding-top: 24px;
    position: relative;
    display: flex;
    justify-content: center;
    gap: 16px;
}

.tree.vertical li {
    text-align: center;
    list-style-type: none;
    position: relative;
    padding: 24px 8px 0 8px;
}

/* Connectors using pseudo elements */
.tree.vertical li::before, 
.tree.vertical li::after {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 1.5px solid var(--border-color);
    width: 50%;
    height: 24px;
}

.tree.vertical li::after {
    right: auto;
    left: 50%;
    border-left: 1.5px solid var(--border-color);
}

/* Remove connectors from single child nodes */
.tree.vertical li:only-child::after, 
.tree.vertical li:only-child::before {
    display: none;
}

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

/* Remove left connector from first-child and right from last-child */
.tree.vertical li:first-child::before, 
.tree.vertical li:last-child::after {
    border: 0 none;
}

/* Draw vertical branch down lines to children from parents */
.tree.vertical li:last-child::before {
    border-right: 1.5px solid var(--border-color);
    border-radius: 0 8px 0 0;
}

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

/* Vertical parent branch drawing */
.tree.vertical ul ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    border-left: 1.5px solid var(--border-color);
    width: 0;
    height: 24px;
}

/* Vertical collapse button alignment */
.tree.vertical .node-toggle-btn {
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
}


/* ==========================================
   CSS Horizontal Tree Connector Lines
   ========================================== */
.tree.horizontal ul {
    padding-left: 36px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
}

.tree.horizontal li {
    position: relative;
    padding: 8px 0 8px 36px;
    display: flex;
    align-items: center;
    list-style-type: none;
    text-align: left;
}

.tree.horizontal li::before, 
.tree.horizontal li::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    border-left: 1.5px solid var(--border-color);
    width: 36px;
    height: 50%;
}

.tree.horizontal li::before {
    top: 0;
}

.tree.horizontal li::after {
    top: 50%;
    border-bottom: 1.5px solid var(--border-color);
}

/* Remove connectors from single child nodes */
.tree.horizontal li:only-child::after, 
.tree.horizontal li:only-child::before {
    display: none;
}

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

/* Remove connector from top/bottom elements of hierarchy */
.tree.horizontal li:first-child::before, 
.tree.horizontal li:last-child::after {
    border: 0 none;
}

/* Adjust connector rounding borders */
.tree.horizontal li:last-child::before {
    border-bottom: 1.5px solid var(--border-color);
    border-radius: 0 0 0 8px;
    height: 50%;
}

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

/* Parent horizontal lines going out to children */
.tree.horizontal ul ul::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    border-top: 1.5px solid var(--border-color);
    width: 36px;
    height: 0;
}

/* Wrap department card + sub-list inside li in horizontal view */
.tree.horizontal li > .node-wrapper {
    display: flex;
    align-items: center;
    gap: 0px;
    position: relative;
}

/* Horizontal collapse button alignment */
.tree.horizontal .node-toggle-btn {
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
}


/* General Collapsed state hiding children nodes */
.tree ul.collapsed-tree {
    display: none !important;
}


/* ==========================================
   Department Details Panel (Right Sidebar Slide-in)
   ========================================== */
.dept-detail-panel {
    position: fixed;
    top: 0;
    right: -420px; /* Hidden by default */
    width: 400px;
    height: 100vh;
    background: linear-gradient(180deg, hsla(222, 25%, 12%, 0.95), hsla(222, 25%, 8%, 0.98));
    border-left: 1px solid var(--border-color);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.6);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(15px);
}

.dept-detail-panel.open {
    right: 0;
}

.panel-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: var(--transition-fast);
}

.panel-close-btn:hover {
    color: #fff;
    background-color: rgba(0, 0, 0, 0.6);
    transform: rotate(90deg);
}

.panel-header {
    padding: 32px 24px 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
}

.panel-header .dept-icon {
    font-size: 28px;
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.panel-header-text h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.panel-header-text span {
    font-size: 11px;
    color: var(--text-muted);
}

.panel-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px 24px 40px 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Manager Highlight Card */
.manager-card {
    background-color: hsla(201, 90%, 55%, 0.06);
    border: 1px solid hsla(201, 90%, 55%, 0.2);
    border-radius: 14px;
    padding: 16px;
}

.card-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.manager-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.manager-avatar-fallback {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: hsla(201, 90%, 55%, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--accent);
    border: 1.5px solid var(--accent);
}

.manager-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.manager-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.manager-title {
    font-size: 12.5px;
    color: var(--text-secondary);
}

/* Member List Section */
.member-list-section {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 250px;
}

.member-count-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 12px;
}

.count-badge {
    background-color: hsla(222, 20%, 20%, 0.5);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    color: var(--accent);
}

.member-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    flex-grow: 1;
}

.member-item {
    background-color: hsla(222, 25%, 14%, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition-fast);
}

.member-item:hover {
    background-color: hsla(222, 25%, 18%, 0.7);
    border-color: hsla(201, 90%, 55%, 0.25);
}

.member-main-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.member-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.member-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.member-item-badge {
    font-size: 10px;
    background-color: hsla(260, 75%, 65%, 0.2);
    border: 1px solid hsla(260, 75%, 65%, 0.4);
    color: hsl(260, 75%, 75%);
    padding: 1px 5px;
    border-radius: 4px;
}

.member-item-title {
    font-size: 11.5px;
    color: var(--text-muted);
}

.member-item-ext {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.member-item-ext i {
    font-size: 11px;
    color: var(--text-muted);
}

.member-item-ext strong {
    color: var(--accent);
}

/* Light mode overrides for org chart elements */
.light-mode .node-card {
    background-color: hsla(220, 20%, 100%, 0.85);
    border-color: hsla(220, 15%, 80%, 0.6);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.light-mode .node-card:hover {
    background-color: hsla(220, 20%, 100%, 1);
    border-color: var(--accent);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 0 12px hsla(201, 90%, 55%, 0.15);
}

.light-mode .node-card.selected-node {
    border-color: var(--accent);
    background-color: hsla(201, 90%, 55%, 0.08);
}

.light-mode .node-card.highlighted {
    border-color: var(--accent-secondary);
    background-color: hsla(260, 75%, 65%, 0.08);
}

.light-mode .node-toggle-btn {
    background-color: hsla(220, 20%, 93%, 0.95);
    border-color: hsla(220, 15%, 80%, 0.6);
    color: var(--text-secondary);
}

.light-mode .node-toggle-btn:hover {
    background-color: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.light-mode .dept-detail-panel {
    background: linear-gradient(180deg, hsla(220, 20%, 98%, 0.96), hsla(220, 20%, 94%, 0.98));
    border-left: 1px solid hsla(220, 15%, 80%, 0.5);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
}

.light-mode .manager-card {
    background-color: hsla(201, 90%, 45%, 0.05);
    border-color: hsla(201, 90%, 45%, 0.2);
}

.light-mode .manager-avatar-fallback {
    background-color: hsla(201, 90%, 45%, 0.1);
    color: var(--accent);
    border-color: var(--accent);
}

.light-mode .count-badge {
    background-color: hsla(201, 90%, 45%, 0.08);
    border-color: hsla(201, 90%, 45%, 0.15);
    color: var(--accent);
}

.light-mode .member-item {
    background-color: hsla(220, 20%, 96%, 0.5);
    border-color: hsla(220, 15%, 85%, 0.5);
}

.light-mode .member-item:hover {
    background-color: hsla(220, 20%, 100%, 0.85);
    border-color: var(--accent);
}

