body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #e0eafc, #cfdef3);
    margin: 0;
    padding: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    line-height: 1.6;
}

#container {
    width: 100%;
    max-width: 2000px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    overflow: visible;
    padding: 20px;
    text-align: center;
    transition: transform 0.3s ease;
}

#container:hover {
    transform: translateY(-5px);
}

#header {
    background: linear-gradient(90deg, #007BFF, #00C4FF);
    color: white;
    padding: 20px;
    border-radius: 12px 12px 0 0;
    position: relative;
}

#header h1 {
    margin: 0;
    font-size: 2em;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#header p {
    margin: 5px 0 0;
    font-size: 0.9em;
    opacity: 0.9;
}

#mainContent {
    padding: 20px;
}

.control-panel {
    display: flex;
    justify-content: center;
    padding: 10px;
}

.control-table {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    transition: all 0.3s ease;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.control-table:hover,
.control-table:focus-within {
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.2);
}

/* Styling for buttons */
.control-table input[type="button"] {
    background: linear-gradient(90deg, #007BFF, #00C4FF);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-table input[type="button"]:hover,
.control-table input[type="button"]:focus {
    background: linear-gradient(90deg, #0056b3, #0096cc);
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

/* Styling for text input */
.control-table input[type="text"] {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.9em;
    width: 80px;
    transition: all 0.3s ease;
}

.control-table input[type="text"]:focus {
    border-color: #007BFF;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.3);
    outline: none;
}

/* Styling for radio buttons and labels */
.control-table input[type="radio"] {
    margin: 0 5px 0 10px;
    accent-color: #007BFF;
}

.control-table label {
    font-size: 0.9em;
    color: #2c3e50;
    margin-right: 10px;
}

#canvas {
    display: block;
    margin: 15px auto;
    border: 2px solid #007BFF;
    border-radius: 5px;
    background: #fff;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    min-width: 800px;
    min-height: 400px;
    resize: both;
    overflow: auto;
}

#footer {
    background: linear-gradient(90deg, #2c3e50, #34495e);
    color: white;
    padding: 15px;
    border-radius: 0 0 12px 12px;
    font-size: 0.8em;
}

#footer a {
    color: #00C4FF;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

#footer a:hover,
#footer a:focus {
    color: white;
    text-decoration: underline;
}

/* Accessibility */
:focus {
    outline: 2px solid #007BFF;
    outline-offset: 2px;
}

/* Responsive Design */
@media (max-width: 768px) {
    #container {
        width: 90%;
        padding: 15px;
    }

    #header {
        padding: 15px;
    }

    #header h1 {
        font-size: 1.6em;
    }

    #header p {
        font-size: 0.85em;
    }

    #canvas {
        width: 100%;
        height: 320px;
    }

    .control-table {
        padding: 8px;
        gap: 8px;
    }

    .control-table input[type="button"],
    .control-table input[type="text"] {
        padding: 6px 12px;
        font-size: 0.85em;
    }

    .control-table input[type="text"] {
        width: 60px;
    }

    .control-table label {
        font-size: 0.85em;
    }
}

@media (max-width: 480px) {
    #container {
        width: 95%;
        padding: 10px;
    }

    #header {
        padding: 10px;
    }

    #header h1 {
        font-size: 1.2em;
    }

    #header p {
        font-size: 0.75em;
    }

    #canvas {
        height: 240px;
    }

    .control-panel {
        padding: 8px;
    }

    .control-table {
        padding: 6px;
        gap: 6px;
        flex-direction: column;
    }

    .control-table input[type="button"],
    .control-table input[type="text"] {
        padding: 5px 10px;
        font-size: 0.8em;
    }

    .control-table input[type="text"] {
        width: 50px;
    }

    .control-table label {
        font-size: 0.8em;
    }

    #footer {
        padding: 10px;
        font-size: 0.7em;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    body {
        background: #fff;
    }

    #container {
        background: #fff;
    }

    #header {
        background: #007BFF;
    }

    #footer {
        background: #000;
    }

    .control-table {
        background: #e9ecef;
        border: 2px solid #000;
    }

    .control-table input[type="button"] {
        background: #007BFF;
    }
}

/* Additional Visualization Styles */

/* Canvas Overlay Styles */
.HighlightCircle {
    animation: pulse 1.5s infinite alternate;
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }

    100% {
        opacity: 1;
    }
}

/* Animation controls */
#GeneralAnimationControls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

#GeneralAnimationControls button {
    background: var(--primary-light);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    min-width: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#GeneralAnimationControls button:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#GeneralAnimationControls button:active {
    transform: translateY(0);
}

/* Specific control buttons styling */
#GeneralAnimationControls button[value="<<"] {
    background-color: #4f46e5;
}

#GeneralAnimationControls button[value=">>"] {
    background-color: #4f46e5;
}

#GeneralAnimationControls button[value=">"] {
    background-color: #10b981;
}

#GeneralAnimationControls button[value="<"] {
    background-color: #f97316;
}

#GeneralAnimationControls button.playPauseButton {
    background-color: #ec4899;
}

/* Custom styling for the tree nodes */
.AnimatedCircle {
    transition: all 0.3s ease-in-out;
}

/* Make the tree edges more visible */
.Line {
    stroke-width: 2px;
}

/* Custom label styling */
.AnimatedLabel {
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
}

/* Custom styling for highlighting */
.HighlightCircle {
    opacity: 0.7;
}

/* Status display */
#statusMessage {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    text-align: center;
    box-shadow: var(--shadow-sm);
    font-weight: 500;
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Tree element connections */
.connection-line {
    stroke: var(--primary-color);
    stroke-width: 2px;
}

/* Tooltips and help texts */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.tooltip.show {
    opacity: 1;
}

/* Algorithm information box */
.algo-info {
    margin: 2rem auto;
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    font-size: 1rem;
    line-height: 1.6;
    color: #334155;
    border: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    max-width: 900px;
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
}

.algo-info::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(90deg, #007BFF, #00C4FF);
}

.algo-info:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.12);
}

.algo-info h3 {
    color: #1e40af;
    margin-top: 0;
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    position: relative;
    display: inline-block;
}

.algo-info h3::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 40px;
    height: 3px;
    background: linear-gradient(90deg, #007BFF, #00C4FF);
}

.algo-info p {
    margin-bottom: 1.2rem;
    font-size: 1.05rem;
}

.algo-info p:first-of-type {
    font-size: 1.1rem;
    color: #1e293b;
    font-weight: 500;
}

.algo-info ul {
    padding-left: 1.5rem;
    margin-bottom: 1.5rem;
}

.algo-info li {
    margin-bottom: 0.7rem;
    position: relative;
    padding-left: 0.5rem;
}

.algo-info li::marker {
    color: #3b82f6;
    font-size: 1.1em;
}

.algo-info strong {
    color: #1e40af;
    font-weight: 600;
}

.algo-info p:last-child {
    background: #f0f9ff;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #3b82f6;
    font-weight: 500;
    margin-top: 1.5rem;
    color: #0c4a6e;
}

.algo-info code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
    color: #0369a1;
}

/* Responsive design for algorithm info */
@media (max-width: 768px) {
    .algo-info {
        padding: 1.5rem;
        margin: 1.5rem auto;
    }

    .algo-info h3 {
        font-size: 1.5rem;
    }

    .algo-info p {
        font-size: 1rem;
    }

    .algo-info p:first-of-type {
        font-size: 1.05rem;
    }
}

@media (max-width: 480px) {
    .algo-info {
        padding: 1.2rem;
        margin: 1.2rem auto;
    }

    .algo-info h3 {
        font-size: 1.3rem;
    }

    .algo-info h3::after {
        width: 30px;
    }

    .algo-info p {
        font-size: 0.95rem;
    }

    .algo-info p:first-of-type {
        font-size: 1rem;
    }

    .algo-info ul {
        padding-left: 1.2rem;
    }
}

/* Custom focus styles for accessibility */
:focus {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

/* Keyboard navigation indicator */
body:not(.using-mouse) :focus {
    outline: 3px solid var(--primary-light);
    outline-offset: 3px;
}

/* Add smooth animations for tree operations */
@keyframes nodeInsert {
    from {
        transform: scale(0);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes nodeDelete {
    from {
        transform: scale(1);
        opacity: 1;
    }

    to {
        transform: scale(0);
        opacity: 0;
    }
}

@keyframes nodeHighlight {
    0% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.3);
    }

    100% {
        filter: brightness(1);
    }
}