/* Tree Component Styles */

/* Hierarchy Tree */
.hierarchy-tree {
    background: transparent;
    position: relative;
    margin-top: 0;
    padding-top: 0;
}

/* Sticky Tree Header */
.sidebar-header-content:has(.tree-title),
.hierarchy-tree .sidebar-header-content {
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 10;
    padding: 16px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
    /* Add subtle shadow when content scrolls behind */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Smooth transition for shadow and background */
    transition: box-shadow 0.2s ease, background-color 0.2s ease;
    /* Ensure consistent height and no gaps */
    min-height: 48px;
    box-sizing: border-box;
}

/* Tree Title Styling */
.tree-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* Sidebar Controls in Tree Header */
.sidebar-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Tree Control Buttons */
.sidebar-controls .collapse-all-btn,
.sidebar-controls .turn-all-off-btn {
    background: transparent;
    border: 1px solid var(--border-default);
    color: var(--text-muted);
    padding: 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
}

.sidebar-controls .collapse-all-btn:hover,
.sidebar-controls .turn-all-off-btn:hover {
    background: var(--bg-interactive);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.tree-node {
    margin-bottom: 8px;
    padding-left: 16px;
    user-select: none;
}

.tree-node-header {
    display: flex;
    align-items: center;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
}

.tree-node-header:hover {
    background: var(--bg-interactive);
}

/* Highlighted tree items (for mobile overlay "show in tree" functionality) */
/* Use same light grey color as desktop version (#21262d) */
.tree-node-header.highlighted,
.variable-item.highlighted,
.variable-child.highlighted,
.collection-item.highlighted,
.style-item.highlighted {
    background-color: #21262d !important;
    border-radius: 8px;
    animation: treeHighlightPulse 1.5s ease-in-out;
}

@keyframes treeHighlightPulse {
    0% { 
        background-color: #21262d;
    }
    50% { 
        background-color: #2d3339;
    }
    100% { 
        background-color: #21262d;
    }
}

.tree-expand-icon {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-muted);
}

.tree-node-label {
    flex: 1;
    font-size: 12px;
    font-weight: 500;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    min-width: 0;
}

/* Unchecked tree item labels with 80% opacity */
.tree-node-header:has(input[type="checkbox"]:not(:checked)) .tree-node-label,
.variable-item:has(input[type="checkbox"]:not(:checked)) .tree-node-label {
    opacity: 0.6;
}

/* Override opacity for partially activated folder labels - ensure they go to 100% opacity */
.tree-node-header:has(input[type="checkbox"]:indeterminate) .tree-node-label,
.tree-node-header.partially-active .tree-node-label,
.tree-node-header.active .tree-node-label {
    opacity: 1 !important;
}

.tree-node-count {
    font-size: 12px;
    color: var(--text-muted);
    background: transparent;
    padding: 2px 6px;
    border-radius: 8px;
    margin-left: 8px;
    font-weight: normal;
    min-width: 20px;
    text-align: right;
}

.tree-children {
    margin-left: 16px;
    border-left: 1px solid var(--border-default);
    padding-left: 8px;
}

.tree-children.collapsed {
    display: none;
}

/* Tree Specific Styles */
.item-visually-hidden {
    display: none !important;
}

/* ===== SOLO BUTTON CONTEXT-SPECIFIC STYLING ===== */
/* Hide solo buttons ONLY in style categories - they are redundant there */
.style-category-header .solo-mode-icon {
    display: none !important;
}

/* Add toggle visibility controls */
.hierarchy-controls {
    margin-bottom: 16px;
    padding: 8px;
    background: var(--bg-interactive);
    border-radius: 8px;
}

.hierarchy-controls h4 {
    font-size: 12.24px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.visibility-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.visibility-toggle label {
    font-size: 11.56px;
    color: var(--text-primary);
    cursor: pointer;
}

/* Empty state for trees */
.tree-empty-state {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
}

.tree-empty-message p {
    margin: 8px 0;
    font-size: 14px;
}

.tree-empty-help {
    font-size: 12px;
    opacity: 0.7;
    font-style: italic;
}

/* Dark Mode Checkbox Styling - Enhanced */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 16px;
    height: 16px;
    background: #21262d00;
    border: 2px solid var(--border-default);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    margin-right: 8px;
    flex-shrink: 0;
}

input[type="checkbox"]:hover {
    border-color: var(--accent-primary);
    background: #2d3339;
}

input[type="checkbox"]:checked {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

input[type="checkbox"]:checked::after {
    content: "✓";
    position: absolute;
    top: 0px;
    left: 2px;
    color: var(--text-primary);
    font-size: 12px;
    font-weight: bold;
    line-height: 1;
}

input[type="checkbox"]:indeterminate {
    background: var(--accent-warning);
    border-color: var(--accent-warning);
}

input[type="checkbox"]:indeterminate::after {
    content: "−";
    position: absolute;
    top: -2px;
    left: 2px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
}

input[type="checkbox"]:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

input[type="checkbox"]:disabled {
    background: var(--bg-secondary);
    border-color: var(--bg-interactive);
    cursor: not-allowed;
    opacity: 0.5;
}

/* Tree sidebar now uses global scrollbar styling via global-scrollbar class */

/* Error Display Styles */
.error-display-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    padding: 16px;
    text-align: center;
}

.error-display-container h3 {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.error-message-detail {
    font-size: 14.4px;
    color: var(--text-tertiary);
    margin-top: 8px;
}

.button-retry {
    margin-top: 16px;
    padding: 8px 16px;
    background: var(--accent-button);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14.4px;
    transition: background-color 0.2s;
}

.button-retry:hover {
    background: var(--accent-button-hover);
}
