/* Tree Controls Styles */

/* Main controls container */
.tree-controls {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #e0e0e0;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Control button base */
.control-btn {
    background: #f5f5f5;
    border: none;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: #333;
    min-width: 40px;
    height: 40px;
}

.control-btn:hover {
    background: #e0e0e0;
    transform: translateY(-1px);
}

.control-btn:active {
    transform: translateY(0);
}

.control-btn.active {
    background: var(--primary-color);
    color: white;
}

.control-btn .material-icons {
    font-size: 20px;
}

/* Zoom controls */
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f5f5f5;
    border-radius: 12px;
    padding: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.zoom-level {
    min-width: 80px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    padding: 0 8px;
}

/* Zoom slider */
.zoom-slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 12px;
}

.zoom-slider {
    width: 120px;
    height: 4px;
    background: #ddd;
    border-radius: 2px;
    position: relative;
    cursor: pointer;
}

.zoom-slider-track {
    height: 100%;
    background: var(--primary-color);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.zoom-slider-thumb {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    cursor: grab;
    transition: transform 0.2s;
}

.zoom-slider-thumb:hover {
    transform: translate(-50%, -50%) scale(1.2);
}

.zoom-slider-thumb:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.1);
}

/* View controls */
.view-controls {
    display: flex;
    gap: 4px;
    background: #f5f5f5;
    border-radius: 8px;
    padding: 4px;
}

/* Action controls */
.action-controls {
    display: flex;
    gap: 8px;
}

/* Tree search */
.tree-search {
    flex: 1;
    max-width: 300px;
    position: relative;
}

.tree-search-input {
    width: 100%;
    padding: 8px 40px 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

.tree-search-input:focus {
    border-color: var(--primary-color);
}

.tree-search-btn {
    position: absolute;
    right: 0;
    top: 0;
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
}

.tree-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #333;
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    margin-top: 4px;
    font-size: 12px;
    display: none;
}

/* Tree container updates */
.tree-container {
    position: relative;
    cursor: grab;
    user-select: none;
}

.tree-container:active {
    cursor: grabbing;
}

/* Search highlighting */
.tree-node.search-match {
    background: #fff59d !important;
    box-shadow: 0 0 0 3px #ffd54f;
}

.tree-node.search-dimmed {
    opacity: 0.3;
}

/* Mini-map */
.tree-minimap {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 200px;
    height: 150px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: none;
    overflow: hidden;
}

.tree-minimap.active {
    display: block;
}

.minimap-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.minimap-tree {
    position: absolute;
    width: 100%;
    height: 100%;
    background: #f5f5f5;
}

.minimap-viewport {
    position: absolute;
    border: 2px solid var(--primary-color);
    background: rgba(0, 33, 125, 0.1);
    pointer-events: none;
}

.minimap-toggle {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Export modal */
.export-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.export-modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
}

.export-modal-content h3 {
    margin: 0 0 20px 0;
    font-size: 20px;
}

.export-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.export-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f5f5f5;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s;
}

.export-option:hover {
    background: #e0e0e0;
}

.close-export-modal {
    width: 100%;
    padding: 12px;
    background: #f5f5f5;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
}

/* Fullscreen mode */
#treeView.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 9999;
}

#treeView.fullscreen .tree-container {
    height: calc(100vh - 60px);
}

/* Print styles */
@media print {
    .tree-controls,
    .tree-minimap,
    .minimap-toggle {
        display: none !important;
    }
    
    .tree-wrapper {
        transform: none !important;
    }
    
    .tree-node.search-dimmed {
        opacity: 1 !important;
    }
}

/* Dark mode support */
body.dark-mode .tree-controls {
    background: #1a1a1a;
    border-bottom-color: #333;
}

body.dark-mode .control-btn {
    background: #2a2a2a;
    color: #f0f0f0;
}

body.dark-mode .control-btn:hover {
    background: #3a3a3a;
}

body.dark-mode .zoom-controls,
body.dark-mode .view-controls {
    background: #2a2a2a;
}

body.dark-mode .tree-search-input {
    background: #2a2a2a;
    border-color: #444;
    color: #f0f0f0;
}

body.dark-mode .tree-minimap {
    background: #1a1a1a;
    border-color: #333;
}

body.dark-mode .export-modal-content {
    background: #1a1a1a;
    color: #f0f0f0;
}

body.dark-mode .export-option,
body.dark-mode .close-export-modal {
    background: #2a2a2a;
    color: #f0f0f0;
}

/* Tree parent styles for ancestor view */
.tree-parents {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 40px;
    position: relative;
}

.tree-parents::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 50%;
    width: 2px;
    height: 20px;
    background: #ddd;
    transform: translateX(-50%);
}

.tree-parent {
    position: relative;
}

.tree-parent::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 50%;
    width: 2px;
    height: 20px;
    background: #ddd;
    transform: translateX(-50%);
}

/* When there are two parents, connect them */
.tree-parents .tree-parent:first-child:not(:only-child)::before {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 50%;
    right: -20px;
    height: 2px;
    background: #ddd;
}

.tree-parents .tree-parent:last-child:not(:only-child)::before {
    content: '';
    position: absolute;
    bottom: -20px;
    right: 50%;
    left: -20px;
    height: 2px;
    background: #ddd;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .tree-controls {
        padding: 8px;
        gap: 8px;
    }
    
    .tree-search {
        order: -1;
        flex: 1 1 100%;
        max-width: none;
    }
    
    .zoom-controls,
    .view-controls {
        flex: 1;
    }
    
    .tree-minimap {
        width: 150px;
        height: 100px;
        bottom: 10px;
        right: 10px;
    }
}