/* Define CSS Variables in :root */
/* Theme 1: Midnight Blue */
:root {

    --top-status-width:35%;
    --top-spacer-width:5%; 
    --top-right-group-width:60%;

    --scale-factor: 1;               /* Initial scale factor (1 = 100%) */


    /* Dynamic Scaling Variables */
    --gray-100: #ececec;
    --gray-200: #e3e3e3;
    --gray-300: #cdcdcd;
    --gray-400: #b4b4b4;
    --gray-500: #9b9b9b;
    --gray-600: #676767;
    --gray-700: #424242;
    --gray-750: #2f2f2f;
    --gray-800: #212121;
    --gray-900: #171717;
    --gray-950: #0d0d0d;

    --color-1:#ff8f00;
    --color-2:#C66F00;
    --color-3:var(--gray-700);


    /* --color-3:#03a9f4; */
    --color-4:#00796B;
    --color-5:#1B7B34;
    --color-6:#07601E;
    --color-7:#004312;
    --color-12:#0270a3;
    --color-13:#006da1;


    --color-8:#6a1B9a;

    --color-9:#C0392B;
    --color-10:#f45303;
    --color-11:#d24600;

    /* Button Theme Colors */
    --button-step-default: #2E7D32;    /* Darker Blue */
    --button-step-hover: #0D47A1;
    --button-step-active: #0A3880;
    
    --button-redraw-default: #607D8B;  /* Darker Green */
    --button-redraw-hover: #1B5E20;
    --button-redraw-active: #154A18;
    
    --button-random-default: #607D8B;  /* Darker Purple */
    --button-random-hover: #4A148C;
    --button-random-active: #38108C;
    
    /* Common button styles */
    --button-text: #FFFFFF;
    --button-shadow: rgba(0, 0, 0, 0.1);
    --button-highlight: rgba(255, 255, 255, 0.1);

    /* 1. Primary Background Colors */
    --color-primary-bg: var(--gray-800); /* Dark Charcoal */
    --color-primary-bg-alt: var(--gray-800); /* Dim Gray */
    --color-top-pane-bg: var(--gray-900); /* Dim Gray */
    /* 2. Text Colors */
    --color-text-primary: #D3D3D3; /* Light Gray */
    --color-text-secondary: #A9A9A9; /* Dark Gray */
    --color-text-accent: #FF9800; /* Bright Orange */
    --color-text-black: #000000; /* Black */

    /* 3. Input and Dropdown Backgrounds */
    --color-input-bg: var(--gray-800); /* Dark Slate Gray */

    /* 4. Numbers in list */
    --color-numbersList-bg: var(--gray-950); /* Vivid Blue */
    --color-numberList-item-bg: #03A9F4;
    --color-numberList-text: var(--gray-200);
    --color-numbersList-border:var(--gray-700);

    /* 5. Borders and Lines */
    --color-border: #555555; /* Medium Dark Gray */

    /* 6. Buttons */
    --button-color: var(--gray-600); 
    --button-color-hover: var(--gray-700); /* Darker Green */
    --button-text-color: #ffffff; /* White */

    --color-button-next-hover-bg: #6a1B9a; /* Dark Mustard */
    --color-button-next-bg: #00796B; /* Mustard */
    --color-button-next-text: #ffffff; /* White */
    
    /* 7. Binary Tree Nodes */
    /* --color-node-bg: #a76004; Forest Green */
    --color-node-bg: var(--color-5); /* Forest Green */

    --color-node-text: var(--gray-200); /* White */
    --color-node-bg-highlighted: #03A9F4; /* Amber */
    --color-node-text-highlighted:var(--button-text-color);
 
    --color-node-greyed-out: #444444;
    --color-node-text-greyed-out: #888888;
    --color-node-focus: #d24600;
    --color-node-text-focus: var(--button-text-color);

    /* --color-node-bg-highlighted: #EAB126; Amber */
    --color-node-hover: var(--color-node-focus); /* Red */
    
    /* 8. Lines Connecting Nodes */
    --color-line: var(--gray-400); /* Light Gray */
    --color-line-node: var(--gray-500); /* Light Gray */


    
    /* 9. Status Message */
    --color-status-message-bg: var(--gray-950); /* Dim Gray */
    --color-status-message-border: var(--gray-800); /* Dim Gray */
    --color-status-border: var(--gray-700); /* Medium Dark Gray */
    --color-status-text: var(--gray-300); /* Amber */
    --color-status-container-bg: var(--gray-950); /* Dim Gray */

    /* 10. Hover Effects */
    --color-hover-bg: #757575; /* Gray */
    --color-hover-text: var(--color-text-primary); /* Light Gray */
        
    /* 12. antEffect Colors */
    --color-ant: #EAB126; /* Amber */
}

/* Reset and Basic Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Set height to 100% for html and body to ensure #container fills the viewport */
html, body {
    height: 100%; /* Ensures the container spans the full viewport height */
}

/* Gradient Animation Keyframes */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Numbers List Styles */
#numbersList {
    display: flex;
    flex-wrap: wrap;           /* Allow items to wrap to the next line */
    width: 100%;                /* Span full width of parent */
    height: calc(150px * var(--scale-factor));             /* Fixed height */
    overflow-y: auto;          /* Enable vertical scrolling if content overflows */
    padding: calc(10px * var(--scale-factor));  
    border-radius:  calc(5px * var(--scale-factor));
    box-sizing: border-box;    /* Include padding and border in width calculations */
    /*remove gap between lines when wrapping*/
    gap: 0px;
    margin: 0px;

}



/* Number Item Styles */
.number-item {
    background-color: var(--color-numberList-item-bg); /* Input background */
    border: 1px solid var(--color-border);   /* Border color */
    border-radius:  calc(5px * var(--scale-factor));
    padding: calc(10px * var(--scale-factor));
    margin: calc(2px * var(--scale-factor));
    font-size: 10px;
    cursor: pointer;
    color: var(--color-numberList-text);        /* Text color */
    line-height: normal;                     /* Reset line height */
    box-sizing: border-box;                  /* Include padding and border in width and height calculations */
    flex: 0 1 auto;                          /* Allow items to shrink and wrap */
    max-width: 100%;                         /* Prevent items from exceeding container width */
    height: calc(30px * var(--scale-factor));
    display: flex;                           /* Enable flex layout for alignment */
    align-items: center;                     /* Vertically center content */
    justify-content: center;                 /* Horizontally center content */
    overflow: hidden;                        /* Hide overflow if content is too large */
}

.number-item.highlight {
    background-color: var(--color-node-hover); /* Highlight color */
    color: var(--button-text-color);           /* Ensure text is readable */

}

.traversal-number-item {
    background: var(--color-numberList-item-bg);

    border: 1px solid var(--color-border);
    border-radius:  calc(5px * var(--scale-factor));
    padding: 0px 0px;
    margin: calc(1px * var(--scale-factor)); /* Minimize margin */
    font-size: calc(12px * var(--scale-factor));
    cursor: pointer;
    color: var(--button-text-color);
    line-height: 1; /* Ensure tight line height */
    box-sizing: border-box;
    width: calc(30px * var(--scale-factor));
    height: calc(30px * var(--scale-factor));
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    backdrop-filter: blur(10px);
    cursor: grab;

}

.traversal-number-item.highlight {
    background-color: var(--color-node-hover); /* Highlight color */
    color: var(--button-text-color);           /* Ensure text is readable */
} 


#numbersList::-webkit-scrollbar {
    width:  calc(8px * var(--scale-factor));
}

#numbersList::-webkit-scrollbar-track {
    background: var(--color-primary-bg);
}

#numbersList::-webkit-scrollbar-thumb {
    background-color: var(--color-button-randomize-bg);
    border-radius:  calc(4px * var(--scale-factor));
    border: 2px solid var(--color-primary-bg);
}

.number-item:hover {
    background-color: var(--color-node-hover); /* Use the hover color */
    color: var(--button-text-color); /* Ensure text is readable */
}

.number-item.inserted:hover {
    /* Disable hover effect for inserted items */
    background-color: #555555; /* Same as the inserted background */
    color: #A9A9A9;            /* Same as the inserted text color */
    cursor: default;
}

/* Styles for Inserted Numbers */
.number-item.inserted {
    background-color: #555555; /* Dark Grey Background */
    color: #A9A9A9;            /* Grey Text */
    cursor: default;
    opacity: 0.6;
}

/* Highlight Animation for Current Number */
.number-item.current {
    background-color: #EAB126; /* Highlighted Background Color */
    color: #000000;            /* Black Text */
    opacity: 1;                /* Fully opaque */
}

@keyframes antEffect {
    0% {
        box-shadow: 0 0 5px var(--color-ant), 0 0 10px var(--color-ant), 0 0 15px var(--color-ant), 0 0 20px var(--color-ant);
    }
    50% {
        box-shadow: 0 0 10px var(--color-ant), 0 0 15px var(--color-ant), 0 0 20px var(--color-ant), 0 0 25px var(--color-ant);
    }
    100% {
        box-shadow: 0 0 5px var(--color-ant), 0 0 10px var(--color-ant), 0 0 15px var(--color-ant), 0 0 20px var(--color-ant);
    }
}

/* List Edit Box */
#listEditBox {

    display: flex;
    flex-direction: column;
    gap: calc(10px * var(--scale-factor));
}

/* Style the Textarea */
.resizable-input {

    position: relative;
    width: 100%;
    height: auto;
}

.resizable-input textarea {
    font-family: 'Roboto', sans-serif; /* Roboto Font */

    width: 100%; /* Full width */
    height: calc(40px * var(--scale-factor));
    padding: calc(10px * var(--scale-factor));
    font-size: calc(12px * var(--scale-factor));
    border: 1px solid var(--color-border); /* Borders and Secondary Elements */
    border-radius:  calc(5px * var(--scale-factor));
    background-color: #D3D3D3; /* Dropdown and Input Field Backgrounds */
    color: black; /* Light Gray Text */
    resize: none; /* Disable default resizing to use custom resizer */
    overflow: auto; /* Enable scroll if content overflows */
    box-sizing: border-box; /* Include padding in height */
    white-space: pre-wrap; /* Allow lines to wrap */
    word-wrap: break-word; /* Break long words to prevent overflow */
}

/* Resizer Handle */
.resizable-input .resizer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(20px * var(--scale-factor)); /* Height of the resizer area */
    cursor: ns-resize; /* Vertical resize cursor */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10; /* Ensure resizer is on top */
}

/* Resizer SVG Icon Styling */
.resizable-input .resizer svg {
    fill: black; /* Icon color */
    opacity: 0.6;
}

/* Fade-Out Animation for Number Items */
.number-item.fade-out {
    opacity: 0;
    transition: opacity 0.005s ease, transform 0.005s ease;
}

/* Transform Group Inside SVG */
#transformGroup {
    transform-origin: top center; /* Ensure scaling and translation originate from the top center */
    /* Removed transition for instant scaling and transformation */
    /* transition: transform 0.3s ease-out; */
}

/* Button Styles */
.button-group button,
#controlButtons button { 
    padding: calc(8px * var(--scale-factor)) calc(16px * var(--scale-factor));
    font-size: calc(14px * var(--scale-factor));
    cursor: pointer;
    border: none;
    border-radius:  calc(5px * var(--scale-factor));
    transition: background-color 0.3s;
    color: var(--button-text-color); /* Light Gray Text */
    margin:0;
    height: calc(60px * var(--scale-factor));
    /*gap to the right*/
    margin-right: calc(10px * var(--scale-factor));
   
    
}



/* Buttons Container: Holds the buttons stacked vertically */
.buttonsContainer {
    display: flex;
    flex-direction: column;
    align-items: flex-end;     /* Align items to the right */
    gap: calc(12px * var(--scale-factor));
    width: calc(220px * var(--scale-factor));
    padding: calc(12px * var(--scale-factor));
    border-radius:  calc(16px * var(--scale-factor));
    box-sizing: border-box;    /* Include padding and border in width calculations */
    margin-right: calc(0px * var(--scale-factor));             /* Control spacing to the right */
    
}

/* Button Group: Ensure it fills the container */
.buttonsContainer .button-group {
    display: flex;
    justify-content: flex-end; /* Align buttons to the right */
    width: 100%;               /* Ensure full width for alignment */
}

.traversalsButtonsContainer {
    
    gap: calc(10px * var(--scale-factor));
    display: flex;
    flex-direction: column;
    width: 80%;
    justify-content: flex-end;
    align-items: right;
    margin-top: calc(40px * var(--scale-factor)); /* Add space above the container */

 
 
 }

/* TraversalsButtonsContainer */
.traversalsButtonsContainer button {
    padding: calc(10px * var(--scale-factor)) calc(20px * var(--scale-factor));
    font-size: calc(14px * var(--scale-factor));
    cursor: pointer;
    border: none;
    border-radius:  calc(5px * var(--scale-factor));
    transition: background-color 0.3s;

    color: black;
    height: calc(40px * var(--scale-factor));
    display: flex;
    align-items: center;
    justify-content: center;


}

.button-group button {
    display: flex;
    align-items: center;
    justify-content: center; /* Changed from flex-start to center */
    padding: 1em;
    border-radius:  1em;
    border: none;
    font-size: 0.7em;
    font-weight: 600;
    color: var(--button-text);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px var(--button-shadow);
    width: 9em;
    height: 2.75em;
    background-image: linear-gradient(
        to bottom,
        var(--button-highlight),
        transparent
    );
}

/* Larger icons */
.button-group button svg {
    width: 2.4em;
    height: 2.4em;
    flex-shrink: 0;
    padding-right: 0.7em;
}

/* Traversal Buttons (Pre-order, In-order, Post-order) */

#startTraversalsButton { /* Traversal Button */
    background-color: var(--button-color); /* Deep Purple */
    color: var(--button-text-color); /* Light Gray Text */
}

#startTraversalsButton:hover {
    background-color: var(--color-6); /* Deep Purple */
    color: var(--button-text-color); /* Light Gray Text */

}

#inorderNextButton { /* Traversal Button */
    background-color: var(--gray-700); /* Deep Purple */
    color: var(--button-text-color); /* Light Gray Text */
}

#inorderNextButton:hover {
    background-color: var(--gray-800); /* Deep Purple */
    color: var(--button-text-color); /* Light Gray Text */
}

#inorderNextButton:active {
    background-color: var(--gray-950);
    transform: translateY(1px);
    box-shadow: 0 1px 2px var(--button-shadow);
}

#postorderNextButton { /* Traversal Button */
    background-color: var(--gray-700); /* Deep Purple */
    color: var(--button-text-color); /* Light Gray Text */
}

#postorderNextButton:hover {
    background-color: var(--gray-800); /* Deep Purple */
    color: var(--button-text-color); /* Light Gray Text */
}

#postorderNextButton:active {
    background-color: var(--gray-950);
    transform: translateY(1px);
    box-shadow: 0 1px 2px var(--button-shadow);
}

#preorderNextButton { /* Traversal Button */
    background-color: var(--gray-700); /* Deep Purple */
    color: var(--button-text-color); /* Light Gray Text */
}

#preorderNextButton:hover {
    background-color: var(--gray-800); /* Deep Purple */
    color: var(--button-text-color); /* Light Gray Text */
}

#preorderNextButton:active {
    background-color: var(--gray-950);
    transform: translateY(1px);
    box-shadow: 0 1px 2px var(--button-shadow);
}


/* Randomize Button */
#randomizeButton {
    background-color: var(--gray-700);
}

#randomizeButton:hover {
    background-color: var(--gray-800);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px var(--button-shadow);
}

#randomizeButton:active {
    background-color: var(--gray-950);
    transform: translateY(1px);
    box-shadow: 0 1px 2px var(--button-shadow);
}

/* Add Button */
#addButton {
    background-color: var(--gray-700); /* Dark Blue-Gray */
    color: var(--button-text-color); /* Light Gray Text */
}

#addButton:hover {
    background-color: var(--gray-800); /* Slightly Lighter Purple on Hover */
}

/* Start Button */
#nextButton {
    background-color: var(--button-step-default);

}

#nextButton svg {
    display: inline-block; /* Ensure it's displayed */
    visibility: visible;   /* Ensure it's visible */
    opacity: 1;            /* Ensure it's fully opaque */
}

#nextButton:hover {
    background-color: var(--color-6);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px var(--button-shadow);
}

#nextButton:hover svg {
    fill: var(--button-text);
    color: var(--button-text);
    opacity: 1;
}

#nextButton span {
    display: inline-block; /* Ensure it's displayed */
    visibility: visible;   /* Ensure it's visible */
    opacity: 1;            /* Ensure it's fully opaque */
}

/* Ensure icon visibility during button state changes */
.button-group button:hover svg,
.button-group button:active svg {
    opacity: 1;
    fill: currentColor;
}

#nextButton:active {
    background-color: var(--gray-950);
    transform: translateY(1px);
    box-shadow: 0 1px 2px var(--button-shadow);
}

/* Redraw button specific styles */
#redrawButton {
    background-color: var(--gray-700);
}

#redrawButton:hover {
    background-color:var(--gray-800);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px var(--button-shadow);
}

#redrawButton:active {
    background-color: var(--gray-950);
    transform: translateY(1px);
    box-shadow: 0 1px 2px var(--button-shadow);
}

/* Control Buttons */
#controlButtons {
    display: flex;
    flex-direction: column;
    gap: calc(10px * var(--scale-factor));
}

#controlButtons button {
    background-color: var(--color-button-randomize-bg); /* Dark Blue-Gray */
    color: var(--color-button-randomize-text); /* Light Gray Text */
}

#controlButtons button:hover {
    background-color: #455A64; /* Slightly Lighter Blue-Gray on Hover */
}

/* Main Content Area */
.rightColumn {
    flex: 1; /* Allow it to grow and fill the remaining space */
    display: flex;
    flex-direction: column; /* Stack topPane and mainPane vertically */
    overflow: hidden; /* Prevent overflow */
}



/* Top Pane */
#topPane {
    position: relative; /* Make #topPane the reference point for absolute positioning */

    display: flex;
    justify-content: space-between; /* Distribute space between children */
    align-items: center; /* Changed from flex-start to center for better alignment */
    padding: 0.5%; /* Reduced padding to prevent overflow */
    background-color: var(--color-top-pane-bg);
    overflow: visible;
    box-sizing: border-box;
    z-index: 2; /* Ensure it stays above other elements */
    filter: drop-shadow(3px 3px 3px rgba(0, 0, 0, 0.7)); /* Updated drop shadow */
    height:18vh;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10"><line x1="0" y1="0" x2="0" y2="10" stroke="%23212121" stroke-width="1" transform="rotate(45 5 5)"/></svg>');
    background-size: 0.5%; /* Match the pattern size */

}

/* Mobile-First Adjustments */

/* Small Devices - Portrait */
@media (max-width: 600px) and (orientation: portrait) {
    #topPane {
        height: 10vh;
    }
}

/* Small Devices - Landscape */
@media (max-width: 600px) and (orientation: landscape) {
    #topPane {
        height: 15vh;
    }
}

/* Medium Devices (601px - 1024px) - Portrait */
@media (min-width: 601px) and (max-width: 1024px) and (orientation: portrait) {
    #topPane {
        height: 12vh;
    }
}

/* Medium Devices (601px - 1024px) - Landscape */
@media (min-width: 601px) and (max-width: 1024px) and (orientation: landscape) {
    #topPane {
        height: 14vh;
    }
}

/* Large Devices (1025px - 1440px) - Portrait */
@media (min-width: 1025px) and (max-width: 1440px) and (orientation: portrait) {
    #topPane {
        height: 16vh;
    }
}

/* Large Devices (1025px - 1440px) - Landscape */
@media (min-width: 1025px) and (max-width: 1440px) and (orientation: landscape) {
    #topPane {
        height: 18vh;
    }
}

/* Extra Large Devices (1441px and above) */
@media (min-width: 1441px) {
    #topPane {
        height: 20vh; /* Maintain default height */
    }
}
    





/* Status Container: Holds comparisonBox and Buttons side by side */
.statusContainer {
    
    width: var(--top-status-width); /* Fixed width */

    display: flex;
    align-items: center; /* Align items to the center vertically */
    gap: 0.5%;
    border: 1px solid var(--color-status-border);
    padding: calc(10px * var(--scale-factor));
    border-radius:  calc(16px * var(--scale-factor));
    background-color: var(--color-status-container-bg);
    margin-top: 0.5%;
    margin-bottom: 0.5%;
    height: 100%;             /* Fixed height */
    flex: 1;                        /* Allow status box to take available space */
}

.spacer{
    height: 100%;
    width: var(--top-spacer-width);
}

.rightGroup {
    width: var(--top-right-group-width); /* Remaining width for the right group */

    display: flex;
    align-items: center; /* Align buttons and number list vertically */
    justify-content: flex-end; /* Align the right group to the right */
    gap: 0; /* Space between buttons and number list */
    background: var(--gray-950);
    border-radius:  calc(16px * var(--scale-factor));

    /*borders on top, right, bottom */
    border-top: 1px solid var(--color-numbersList-border); 
    border-left: 1px solid var(--color-numbersList-border);
    border-bottom: 1px solid var(--color-numbersList-border);
    border-right: none;
    height: 100%;             /* Fixed height */
}

/* Comparison Box */
#comparisonBox {
    padding: 0;
    border-radius:  calc(5px * var(--scale-factor));
    background-color: var(--color-status-message-bg); /* Status Message Background */
    border: 0px solid var(--color-status-message-border); /* Border Color */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    font-weight: 200;
    transition: opacity 0.3s ease;
    font-size: 1.2em; /* Use a CSS variable for scaling */
    color: var(--color-status-text);
    font-weight: 500;
    white-space: pre-wrap; /* Preserves newlines and spaces */

}
/* Portrait Orientation */
@media (orientation: portrait) {
    #comparisonBox {
        font-size: 0.8em; /* Adjust font size for portrait mode */
    }
}

/* Landscape Orientation */
@media (orientation: landscape) {
    #comparisonBox {
        font-size: 1em; /* Adjust font size for landscape mode */
    }
}

/* Responsive Breakpoints */

/* Small Devices (e.g., Smartphones) */
@media (max-width: 600px) {
    #comparisonBox {
        font-size: 0.9em; /* Slightly smaller font for small screens */
    }
}

/* Medium Devices (e.g., Tablets) */
@media (min-width: 601px) and (max-width: 1024px) {
    #comparisonBox {
        font-size: 1em; /* Medium font size for tablets */
    }
}

/* Large Devices (e.g., Desktops, Large Tablets) */
@media (min-width: 1025px) {
    #comparisonBox {
        font-size: 1.2em; /* Larger font size for desktops */
    }
}

/* Very Large Devices (e.g., Large Desktops) */
@media (min-width: 1440px) {
    #comparisonBox {
        font-size: 1.4em; /* Extra large font for very large screens */
    }
}

#comparisonBox.show {
    opacity: 1;
}

/* Start Button within statusContainer */
.statusContainer .button-group {
    margin: 0; /* Remove default margins */
}

/* Numbers List Scrollbar Styles */
#numbersList::-webkit-scrollbar {
    width: 1%;
}

#numbersList::-webkit-scrollbar-track {
    background: var(--color-primary-bg);
}

#numbersList::-webkit-scrollbar-thumb {
    background-color: var(--color-button-randomize-bg); /* Dark Blue-Gray Scrollbar Thumb */
    border-radius: 0px;
    border: 0px solid var(--color-primary-bg);
}

/* Main Pane */
#mainPane {
    flex-grow: 1;
    flex-shrink: 1;
    position: relative; 
    background-color: var(--color-primary-bg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
    height:80%;
}

/* Tree Layer */
#treeLayer {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden; /* Changed from visible to hidden */
    display: flex;
    flex-direction: column; /* Stack children vertically */
    margin: 0;
    justify-content: center;
    align-items: center; /* Center children horizontally */
    padding-top: 0; /* Adjusted for better alignment */
    cursor: grab;
    flex-grow: 1;
    transform-origin: center;
 
}

#treeLayer:active {
    cursor: grabbing;
}

/* Tree Container */
#treeContainer {
    width: 100%;
    height: 100%;
    transform-origin: top center; /* Changed from center center */
    /* Removed transition for instant scaling */
    /* transition: transform 0.1s ease-out; */
    overflow: hidden; /* Changed from visible to hidden */
    position: relative;
    display: flex;
    justify-content: center; 

}

/* Tree SVG */
#treeSVG {
    width: 100%;
    height: 100%;
    pointer-events: all;
    
}

/* SVG Edge Styles */
.svg-edge {
    stroke: var(--color-line); /* Lines Connecting Nodes */
    stroke-width: calc(4px * var(--scale-factor));
    pointer-events: none;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5)); /* Updated drop shadow */
}

/* SVG Node Styles */
.svg-node {
    fill: var(--color-node-bg); 
    /*fill opacity */
    stroke: var(--color-line-node); 
    stroke-width: calc(6px * var(--scale-factor));
    cursor: pointer;
    opacity: 1;
    filter: drop-shadow(3px 3px 3px rgba(0, 0, 0, 0.7)); /* Updated drop shadow */
}

.svg-node:hover {
    fill: var(--color-numbersList-bg); /* Hover State - Red*/

}


@keyframes snapIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* SVG Text Styles */
.svg-text {
    /* 2560x1600 */
    font-size: calc(1.5em * var(--scale-factor)); /* Use a CSS variable for scaling */
    fill: var(--color-node-text); 
    pointer-events: none;
    font-weight: 700;
    text-anchor: middle; 
    transform: translateY(0.35em); /* Adjust as needed */
    letter-spacing: 0.04em;
    stroke: none; /* Ensure no stroke is applied */


}

/* Zoom Icon Style */
#zoomIcon {
    height: 2em;
    margin-right: 1em;
    fill: var(--color-text-primary); /* Match the theme color */
}

/* Zoom Slider Style */
#zoomSlider {
    width: 100%;
    margin-right: 0.5em;

}

#zoomSliderContainer {
    position: absolute;
    box-sizing: border-box; 
    display: flex; 
    align-items: center; 
    cursor: pointer;

    top: 2%; 
    right: 2%; 
    padding: 0.4em;
    z-index: 1000; 
    background-color: rgba(0, 0, 0, 0.8); 
    border-radius:  0.4em;
    color: white; 
    width: 12%;
    height: 2em;
}

/* Slider Track */
#zoomSlider::-webkit-slider-runnable-track {
    background: var(--color-border);
    height: 0.15em;
}

/* Slider Thumb */
#zoomSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    background: var(--color-button-zoom-bg);
    width: 0.25em;
    height: 0.25em;
    border-radius: 50%;
    margin-top: -0.5em;
}

/* For Mozilla Firefox */
#zoomSlider::-moz-range-track {
    background: var(--color-border);
    height: 0.15em;
    border-radius:  0;
}

#zoomSlider::-moz-range-thumb {
    background: var(--color-button-zoom-bg);
    width: 1em;
    height: 1em;
    border-radius: 50%;
}

/* Prevent Select on Buttons */
button {
    user-select: none;
}

/* Left Group: Contains comparisonBox, Start Button, and Zoom Controls */
.leftGroup {
    display: flex;
    flex-direction: column;
    width:30%;
}

/* Body Styles */
body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--color-primary-bg);
    color: var(--color-text-primary);
    overflow: hidden;
    position: relative;
}

/* Container Styles */
#container {
    display: flex;
    flex-direction: column;
    height: 100%; /* Already set to 100% */
    width: 100%;
    position: relative;
    z-index: 300; /* Set a high z-index */

}

/* Content Pane */
#contentPane {
    display: flex;
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    transition: margin-left 0.3s ease;
}

#traversalsContainer,
#leftPane {
    position: absolute;
    visibility: hidden; /* Hide the containers initially */
    opacity: 0; /* Ensure full opacity */
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
    z-index: 5000; /* Ensure it stays above other elements */

    
    background-color: rgba(23, 23, 23, 0.1);
    filter: drop-shadow(3px 3px 3px rgba(0, 0, 0, 0.7)); /* Updated drop shadow */
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" opacity="0.8"><line x1="0" y1="0" x2="0" y2="10" stroke="%23212121" stroke-width="1" transform="rotate(45 5 5)"/></svg>');
    background-size: 0.5%; /* Match the pattern size */
    border-bottom-right-radius: 15px;
    border-bottom-left-radius: 15px;
    border-right: 1px solid var(--color-border);
    border-left: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(5px);

    transition: top 0.5s ease-out; /* Smooth transition */
}

#traversalsContainer.open {

    visibility: visible !important;
    opacity: 1 !important;
    max-height: calc(400px * var(--scale-factor)); 
    /* top:  calc(190px * var(--scale-factor)); */
    top:0;
}

#leftPane.open {
    visibility: visible; /* Show the pane */
    opacity: 1; /* Fade in */
    height: auto; /* Full height when open */
    padding: calc(20px * var(--scale-factor)); /* Restore padding when open */

    top:0;

}

#leftPane {
    left: 59%;
    width: 17%;   
    gap: 1em;
    margin: 0;
    top:0;
}

#traversalsContainer {
    position: absolute;
    display: flex;
    flex-direction: column;    
    flex-wrap: nowrap;        
    justify-content: flex-start; 
    align-items: flex-start;     
    overflow-y: auto;  

    left: 0.5%;
    width: 45%;
    padding: 1em;
    max-height: 0; 
    padding-top: 2.2%;
             
    gap:10px;
    /* Smooth Transition for Expansion */
    transition: max-height 0.5s ease-out, padding 0.5s ease-out;

}

.pane-handle,
.traversal-pane-handle {
    visibility: visible; 
    position: absolute; 
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;

    top:0;
    height: auto;
    line-height: 1;
    
    background-color: var(--gray-800);
    color: white;
    z-index: 10000; /* Ensure they are above other elements */
  
    padding: 5px;
    border-radius: 5px;
    opacity: 1; /* Ensure full opacity */
    font-size: 0.75vw;
    color: rgb(193, 193, 193);
    font-weight: 500;
    border-radius: 0 0 calc(10px * var(--scale-factor)) calc(10px * var(--scale-factor));
    box-shadow: inset 1px 1px 3px rgba(255, 255, 255, 0.3), 2px 2px 5px rgba(0, 0, 0, 0.5);
    border: 1px solid #3a3a3a;
    border-top: none;
    transition: background-color 0.3s ease, max-height 0.5s ease-out, padding 0.5s ease-out, opacity 0.5s ease-out;
}
.pane-handle {
    left: 65%; /* Adjust as needed */
}


.traversal-pane-handle {
    left: 12%; /* Adjust as needed */
}

.pane-handle:hover,
.traversal-pane-handle:hover {
    background-color: var(--gray-900); /* Slightly lighter on hover */
}



.rightColumn {
    flex: 1; 
    display: flex;
    flex-direction: column; 
    overflow: hidden; 
    position: relative; 
}

.traversalBox {
    display: flex;
    flex-direction: row; 
    align-items: center; 
    gap: 0px; 
    width: 100%; 
    margin-bottom: 0px; 
     justify-content: flex-start; 
    padding-bottom: calc(5px * var(--scale-factor));
}

.traversalList {
    
    border-radius: calc( 5px * var(--scale-factor));
    padding: 0px calc(20px * var(--scale-factor));
    overflow-y: auto;
    border: 0px solid var(--color-border);
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start; /* Align items to the top */
    justify-content: flex-start; 

    display: flex;
    gap: calc(3px * var(--scale-factor)); /* Space between items */
    width: 100%; /* Ensure it spans the full width of the container */


}

.button-style {
    padding: 1em;
    margin: 0px; /* Minimize margin */


    font-size: 0.75em;
    cursor: pointer;
    border: none;
    border-radius:  1em;
    transition: background-color 0.3s;
    height: 3em;
    background-color: var(--gray-700); /* Deep Purple */
    width: 8em;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box; /* Include padding and border in element's total size */
    line-height: normal; /* Ensure line height doesn't add extra space */
    color: var(--button-text-color); /* Light Gray Text */


}

.button-style:hover {
    background-color: var(--gray-800); /* Deep Purple */
    color: var(--button-text-color); /* Light Gray Text */
}

.button-style:hover:active {
    background-color: var(--gray-950);
    transform: translateY(1px);
    box-shadow: 0 1px 2px var(--button-shadow);
}


.button-style:disabled {
    background-color: #888; /* Gray background for disabled state */
    color: #ccc; /* Light gray text for disabled state */
    cursor: not-allowed; /* Change cursor to indicate disabled state */
    opacity: 0.6; /* Reduce opacity for a disabled look */
}

.subtree-highlight {
    fill: rgba(255, 215, 0, 0.3); /* Gold shading with transparency */
    stroke: rgba(255, 215, 0, 0.5); /* Gold stroke with transparency */
}

.node-greyed-out {
    fill: var(--color-node-greyed-out);
    stroke: var(--color-node-greyed-out);
    /* color: var(--color-node-text-greyed-out); */
    /*set font color red*/
    color: red;

    /* ochange font color */ 
}

.svg-node.node-focus {
    fill: var(--color-node-focus) !important;
    stroke: var(--color-line) !important;
    color: var(--color-node-text) !important;
}

/* 
.permanent-red text {
    fill: black !important;
    
} */

.hidden-edge {
    /* display: none;  Hide the edge */
    stroke: #A9A9A9; /* Dark Gray color */
    opacity: 0.5; /* Reduce opacity for a grayed-out effect */


}

.button-group {
    display: flex;
    justify-content: center;
    align-items: center;
}

#traversalsContainer button {
    cursor: pointer; /* Show pointer cursor for buttons */
}






/* Transition for node movement */
.svg-node,
.svg-text {
    transition: opacity 1s ease;
}



/* Highlights */
.child-highlight .svg-node-circle {
    stroke: blue;
}

.successor-highlight .svg-node-circle {
    stroke: green;
}

/* Child node highlight */
.child-highlight {
    stroke: blue;
}

/* CSS for predecessor highlight */
.predecessor-highlight .svg-node-circle {
    stroke: orange;
}

.svg-node.highlighted {
    fill: var(--color-node-bg-highlighted); /* Highlighted Node Color - Amber */
    color: var(--color-node-text-highlighted); /* Highlighted Text Color - Black */
    /*stroke: #FFEB3B; /* Highlighted Stroke Color - Yellow */
}

/* Highlighted node */
.highlighted {
    stroke: white;
}

/* Target node highlight */
.target-highlight {
    stroke: blue;
}

/* Fade-out effect */
.fade-out {
    opacity: 0;
    transition: opacity 0.5s ease-out;
    pointer-events: none; /* Prevent interactions with fading-out nodes */
}

/* Fade-in effect */
.fade-in {
    opacity: 0;
    animation: fadeIn 1s forwards;
}

/* Keyframes for fade-in */
@keyframes fadeIn {
    to {
        opacity: 1;
    }
}


/* Transition for numbersList items */
.number-item {
    transition: opacity 1s ease;
}

/* Fade-out for numbersList items */
.number-item.fade-out {
    opacity: 0;
    transition: opacity 0.5s ease-out;
}

.logoContainer {
    margin-left: calc(100px * var(--scale-factor));
    width: calc(800px * var(--scale-factor));
}

/* Fullscreen Container */
#fullscreenContainer {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

/* Fullscreen Button */
#fullscreenButton {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
}

/* Fullscreen Button Hover Effect */
#fullscreenButton:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* Fullscreen Icon SVG */
#fullscreenButton svg {
    width: 32px;
    height: 32px;
    color: white;
    transition: color 0.3s;
}

/* Ensure the SVG path uses the currentColor */
#fullscreenButton path {
    fill: currentColor;
}