/* Asset Hierarchy Page Styles */

.hierarchy-container {
    display: flex;
    gap: 24px;
    height: calc(100vh - 140px); /* Adjust based on header and padding */
    overflow: hidden;
}

/* Tree View Section */
.hierarchy-tree-section {
    flex: 1;
    background: var(--background-card);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.tree-header {
    margin-bottom: 20px;
}

.tree-search-box {
    position: relative;
    margin-top: 16px;
}

.tree-search-box input {
    width: 100%;
    padding: 12px 16px 12px 42px;
    background: var(--background-dark);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: 'Vazirmatn', sans-serif;
    transition: all 0.3s ease;
}

.tree-search-box input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.tree-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    width: 20px;
    height: 20px;
}

/* Tree Structure */
.tree-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px; /* For scrollbar */
}

.tree-root {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tree-node {
    margin: 4px 0;
}

.node-content {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.node-content:hover {
    background: var(--background-hover);
}

.node-content.selected {
    background: rgba(14, 165, 233, 0.1);
    border-color: var(--primary-color);
}

/* Node Icons and Text */
.node-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.node-toggle.expanded {
    transform: rotate(-90deg); /* Adjust based on RTL */
}

html[dir="ltr"] .node-toggle.expanded {
    transform: rotate(90deg);
}

.node-toggle.empty {
    visibility: hidden;
}

.node-icon {
    width: 24px;
    height: 24px;
    margin-left: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: white;
    font-size: 0.8rem;
}

html[dir="ltr"] .node-icon {
    margin-left: 0;
    margin-right: 12px;
}

.node-label {
    flex: 1;
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.node-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--background-dark);
    padding: 2px 8px;
    border-radius: 12px;
    margin-right: 8px;
}

html[dir="ltr"] .node-count {
    margin-right: 0;
    margin-left: 8px;
}

/* Hierarchy Levels & Colors */
/* Level 0: Province */
.node-level-0 > .node-content .node-icon {
    background: linear-gradient(135deg, #475569, #64748b); /* Slate */
}

/* Level 1: City */
.node-level-1 > .node-content .node-icon {
    background: linear-gradient(135deg, #4f46e5, #6366f1); /* Indigo */
}

/* Level 2: Hospital */
.node-level-2 > .node-content .node-icon {
    background: linear-gradient(135deg, #059669, #10b981); /* Emerald */
}

/* Level 3: Department */
.node-level-3 > .node-content .node-icon {
    background: linear-gradient(135deg, #d97706, #f59e0b); /* Amber */
}

/* Tree Indentation and Lines */
.node-children {
    padding-right: 28px; /* Indent for children (RTL) */
    position: relative;
    display: none; /* Hidden by default */
}

html[dir="ltr"] .node-children {
    padding-right: 0;
    padding-left: 28px; /* Indent for children (LTR) */
}

.node-children.expanded {
    display: block;
}

/* Connecting Lines (Optional cosmetic enhancement) */
.node-children::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 12px; /* Stop before last child */
    right: 12px; /* Align with parent toggle */
    width: 2px;
    background: var(--border-color);
}

html[dir="ltr"] .node-children::before {
    right: auto;
    left: 12px;
}

/* Details Panel */
.hierarchy-details-panel {
    width: 350px;
    background: var(--background-card);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.details-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-secondary);
    gap: 16px;
}

.details-empty svg {
    width: 64px;
    height: 64px;
    opacity: 0.5;
}

.details-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.details-content.active {
    display: block;
}

.details-header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.details-icon-large {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.details-icon-large svg {
    width: 40px;
    height: 40px;
    color: white;
}

.details-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.details-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.details-stat-card {
    background: var(--background-dark);
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-light);
}

/* Responsive */
@media (max-width: 1024px) {
    .hierarchy-container {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }

    .hierarchy-details-panel {
        width: 100%;
        min-height: 200px;
    }
    
    .tree-content {
        max-height: 500px; /* Limit height on mobile */
    }
}
