/* Process Explorer Sidebar Styles */

.process-explorer {
    position: fixed;
    left: 0;
    top: 56px; /* Below navbar */
    bottom: 0;
    width: 300px;
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;
    z-index: 1000;
    display: none; /* Hidden by default */
    flex-direction: column;
    transition: transform 0.3s ease;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}

/* Resize handle */
.explorer-resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    cursor: ew-resize;
    background-color: transparent;
    z-index: 1001;
    transition: background-color 0.2s;
}

.explorer-resize-handle:hover {
    background-color: #0d6efd;
}

.explorer-resize-handle:active {
    background-color: #0b5ed7;
}

/* Show explorer only when JS determines it should be visible */
.process-explorer.visible {
    display: flex;
}

.process-explorer.collapsed {
    transform: translateX(-100%);
}

.explorer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: #e9ecef;
    border-bottom: 1px solid #dee2e6;
}

.explorer-header h6 {
    font-weight: 600;
    color: #212529;
}

.explorer-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
}

.explorer-tree {
    font-size: 14px;
}

.tree-node {
    margin: 2px 0;
    user-select: none;
}

.tree-node-header {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.tree-node-header:hover {
    background-color: #e9ecef;
}

.tree-node-header.active {
    background-color: #0d6efd;
    color: white;
}

.tree-node-header.active:hover {
    background-color: #0b5ed7;
}

.tree-toggle {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    font-size: 12px;
    transition: transform 0.2s;
    cursor: pointer;
}

.tree-toggle.expanded {
    transform: rotate(90deg);
}

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

.tree-icon {
    margin-right: 6px;
    font-size: 14px;
}

.tree-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-children {
    margin-left: 16px;
    display: none;
}

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

/* Different colors for different types */
.tree-node-header[data-type="tenant"] {
    font-weight: 600;
}

.tree-node-header[data-type="business_unit"] {
    font-weight: 500;
}

.tree-node-header[data-type="area"] .tree-icon {
    color: #0d6efd;
}

.tree-node-header[data-type="process"] .tree-icon {
    color: #198754;
}

.tree-node-header[data-type="activity"] .tree-icon {
    color: #fd7e14;
}

/* Show Explorer Button (when sidebar is collapsed) */
.show-explorer-btn {
    position: fixed;
    left: 0;
    top: 70px;
    z-index: 999;
    border-radius: 0 4px 4px 0;
    padding: 8px 12px;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
}

/* Content shift when explorer is visible */
:root {
    --explorer-width: 300px;
}

body.explorer-open {
    padding-left: var(--explorer-width);
}

body.explorer-open main.container,
body.explorer-open .container {
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}

body.explorer-open footer {
    padding-left: var(--explorer-width);
}

/* Ensure smooth transitions */
body {
    transition: padding-left 0.3s ease;
}

main.container {
    transition: max-width 0.3s ease;
}

/* Scrollbar styling for explorer */
.explorer-content::-webkit-scrollbar {
    width: 8px;
}

.explorer-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.explorer-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.explorer-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Loading and error states */
#explorerLoading {
    color: #6c757d;
}

#explorerError {
    margin: 10px;
    font-size: 13px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .process-explorer {
        width: 250px;
    }

    body.explorer-open {
        padding-left: 250px;
    }

    body.explorer-open footer {
        padding-left: 250px;
    }
}

@media (max-width: 576px) {
    .process-explorer {
        width: 100%;
        max-width: 280px;
    }

    body.explorer-open {
        padding-left: 0;
    }

    body.explorer-open footer {
        padding-left: 0;
    }

    /* On mobile, overlay instead of pushing content */
    .process-explorer {
        box-shadow: 4px 0 10px rgba(0,0,0,0.3);
    }
}
