:root {
    --bg: #0f1116;
    --panel: #151823;
    --text: #eef0f6;
    --muted: #9aa3b2;
    --accent: #7c7bff;
    --accent-weak: #232641;
    --border: #202433;
    --radius: 14px;
    --shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #1e1e1e;
}

::-webkit-scrollbar-thumb {
    background-color: #444;
    border-radius: 10px;
    border: 1px solid #1e1e1e;
}

::-webkit-scrollbar-thumb:hover {
    background-color: #666;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: #444 #1e1e1e;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial;
    background: var(--bg);
    line-height: 1.6;
    color: var(--text);
    overflow-x: hidden;
}

/* Header Styles */
.header {
    display: flex;
    height: 56px;
    align-items: center;
    padding: 0 16px;
    background: linear-gradient(90deg, var(--accent), #8a6cff);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: var(--shadow);
}

.header-content {
    padding: 0 10rem;
    display: flex;
    align-items: center;
    width: 100%;
    justify-content: space-between;
}

.logo {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.nav-toggle {
    display: flex;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.nav-toggle span {
    width: 25px;
    height: 3px;
    background: white;
    margin: 3px 0;
    transition: 0.3s;
    border-radius: 2px;
}

/* Main Container */
.main-container {
    /* display: flex;
    min-height: calc(100vh - 140px);

    display: grid;
    grid-template-columns: 300px 1fr;
    height: calc(100vh - 56px);
     */

    display: flex;
    gap: 12px;
    padding: 12px;
    min-height: calc(100vh - 140px);
}

/* Sidebar Styles */
.sidebar {
    /* min-width: 13rem;
    width: 300px;
    background: white;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    transition: transform 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);

    height: calc(100vh - 80px);
    transform: translateX(0);

 */
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px;

    min-width: 13rem;
    width: 300px;
    border-right: 1px solid #485398;
    overflow-y: auto;
    transition: transform 0.3s ease;
    height: calc(100vh - 80px);
    transform: translateX(0);
}

.sidebar.active {
    transform: translateX(-100%);
    position: fixed;
}

/* .sidebar.active {
    transform: translateX(0);
} */

.sidebar-content {
    padding: 2rem 0;
}

.algorithm-category {
    margin-bottom: 2rem;
}

.algorithm-info {
    display: flex;
    gap: 1rem;
}

.category-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #555;
    padding: 0 0 0.5rem;
    border-bottom: 2px solid #667eea;
    margin-bottom: 1rem;


    font-size: .8rem;
    font-weight: 700;
    margin: 12px 8px 6px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.algorithm-list {
    list-style: none;
    padding: 0;
    margin: 0;
    margin-left: 1rem;
}

.algorithm-btn {
    width: 100%;
    /* padding: 0.75rem 1.5rem; */
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
    /* font-size: 0.95rem; */
    /* color: #666; */
    /* background: var(--accent); */
    /* color: white; */
    display: block;
    padding: 8px 10px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    font-size: .9rem;
}

.algorithm-btn:hover {
    background: linear-gradient(45deg, #728cff, #764ba2);
    color: white;
    font-weight: 500;
    padding-left: 2rem;
}

.algorithm-btn.active {
    background: linear-gradient(45deg, #728cff, #764ba2);
    color: white;
    font-weight: 500;
}

/* Main Content */
.main-content {
    flex: 1;
    /* padding: 0.5rem; */
    position: relative;
}

.canvas-container {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
    width: 100%;

    border-radius: 12px;
}

.canvas-header {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}

.algo-header {
    background: var(--panel);
    border: 1px solid #6a7299;
    border-radius: var(--radius);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.algo-header h1,
.algo-header h1 span {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
    margin: 0;
    font-size: 1.5rem;
}

.chip {
    font-size: 1rem;
    color: var(--muted);
    background: var(--accent-weak);
    padding: 4px 8px;
    border-radius: 999px;
}

#algorithmTitle:hover {
    color: #667eea;
}

.canvas-header #algorithmTitle span {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
}



.canvas-info {
    color: #666;
    font-size: 0.95rem;
}

#CanvasContainer {
    display: flex;
    justify-content: center;
    border: 2px dashed #b0b0b0;
    border-radius: 12px;
    width: 100% !important;
    height: calc(100vh - 13rem);
    position: relative;
}

#CanvasContainer canvas {
    display: block;
    width: 100% !important;
    height: auto !important;
    border-radius: 15px;
}


#visualizationCanvas {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    display: block;
    margin: 0 auto;
}

/* Controls Panel */
.controls-panel {
    position: fixed;
    right: 0;
    top: 30%;
    background: #1c1f2b;
    border-bottom-left-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    width: 230px;
    z-index: 100;
    transition: transform 0.3s ease;
    transform: translateX(0);

}

.controls-header {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #667eea96;
    color: white;
    position: absolute;
    height: 2.3rem;
    width: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    border-radius: 50% 0 0 50%;
    left: -24px;
    background: linear-gradient(240deg, #728cffc4, #764ba2ab);
}

.controls-header h4 {
    font-size: 1rem;
    font-weight: 600;
}

.controls-toggle {
    display: flex;
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    justify-content: center;
    align-items: center;
    transition: background 0.3s ease;
}

.controls-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.controls-content {
    padding: 0.8rem;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    max-height: calc(100vh - 15rem);
    overflow-y: auto;
}

.controls-panel.active {
    transform: translateX(100%);

}

.control-group {
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 12px;
    margin-bottom: 1.5rem;
}

.control-group.search {
    margin-bottom: 0.5rem;
}

.control-group.search div {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}


#inputField {
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 12px;
}

.control-group label {
    display: block;
    font-weight: 500;
    font-size: 0.9rem;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e0e0e0;
    outline: none;
    margin-bottom: 0.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.5rem;
}

#searchKey {
    display: none;
}

#searchKey.active {
    display: flex;
}

#subType {
    display: none;
}

#subType.active {
    display: grid;
}

.array-input {
    font-size: 0.85rem;
    transition: border-color 0.3s ease;
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 2px solid #505566;
    background: transparent;
    color: inherit;
    margin-bottom: 8px;
}

.array-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.array-input.error {
    border-color: #f44336;
    background: #fff5f5;
}


.apply-btn,
.generate-btn {
    color: white;
    padding: 0.5rem 1rem;
    white-space: nowrap;
    min-width: 60px;
    background: linear-gradient(320deg, #728cff, #764ba2);
}

/* .generate-btn {
    margin-top: 0.5rem;
} */

.disabled {
   background: #2a2c34;
    color: #5d5d5d;
    border: 2px solid #515151;
    cursor: not-allowed !important;
}

.disabled-btn {
        background: #2a2c34 !important;
    cursor: not-allowed !important;

}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.control-group span {
    font-size: 0.85rem;
    color: #667eea;
    font-weight: 500;
}

.control-buttons {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 1.5rem;

    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 12px;
}

.control-buttons.tree {
    display: grid;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

#searchKey.tree {
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 12
}

.controlBtnGrp {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex-direction: row;
    justify-content: space-between;
}

.control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: 0;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    background: var(--accent);
    color: white;
    flex-grow: 1;
}

.control-buttons.tree .control-btn {
    padding: 0.5rem;
}

.play-btn {
    background: #4CAF50;
    color: white;
}

.pause-btn {
    background: #FF9800;
    color: white;
}

.reset-btn {
    background: #f44336;
    color: white;
}

.deleteAll-btn {
    background: #ff0000;
    color: white;
}

.step-btn {
    background: #2196F3;
    color: white;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

/* Footer */
.footer {
    background: #333;
    color: white;
    padding: 1.5rem 0;
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-links {
    display: flex;
    gap: 2rem;
}

.footer-links a {
    color: #ccc;
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: #667eea;
}


.displayBlock {
    display: block !important;
}

.displayNone {
    display: none !important;
}

.displayGrid {
    display: grid !important;
}

.displayFlex {
    display: flex !important;
}

.stack-button {
    background: none;
    border: none;
    cursor: pointer;
}

.stack-icon .layer {
    fill: white;
    stroke: black;
    stroke-width: 2;
    transform: translateY(0);
    transition: transform 0.3s ease;
}

.stack-button .layer.top {
    transform: translateY(-6px);
}

.stack-button .layer.middle {
    transform: translateY(0);
}

.stack-button .layer.bottom {
    transform: translateY(6px);
}

/* .toggle-steps-btn.hide .layer.top    { transform: translateY(-6px); }
.toggle-steps-btn.hide .layer.middle { transform: translateY(0); }
.toggle-steps-btn.hide .layer.bottom { transform: translateY(6px); } */

.toggle-steps-btn.active .layer.top {
    transform: translateY(0);
}

.toggle-steps-btn.active .layer.middle {
    transform: translateY(0);
}

.toggle-steps-btn.active .layer.bottom {
    transform: translateY(0);
}

/* .toggle-steps-btn:hover .layer {
    transform: translateY(0);
} */




@media (max-width: 1000px) {

    .header-content {
        padding: 0 2rem;
    }

    .main-container {
        grid-template-columns: 1fr !important;
    }

    .sidebar {
        transform: translateX(-100%);
        position: fixed;
        top: 80px;
        left: 0;
        z-index: 999;
    }

    .sidebar.active {
        transform: translateX(0);
    }

}

/* Responsive Design */
@media (max-width: 768px) {
    /* .nav-toggle {
        display: flex;
    } */


    .control-buttons {
        flex-direction: column;
    }

    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    #visualizationCanvas {
        width: 100%;
        height: 300px;
    }
}

@media (max-width: 480px) {
    .header-content {
        padding: 0 1rem;
    }

    .logo {
        font-size: 1.4rem;
    }


    .sidebar {
        width: 280px;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}