/* Core App Layout */
body {
    margin: 0;
    overflow: hidden !important; /* STRICTLY PREVENTS PAGE SCROLLING */
    height: 100vh;
    width: 100vw;
}

:root {
    /* Dynamic Grid Variables */
    --current-sidebar: var(--sidebar-width);
    --current-right: var(--right-panel-width);
}

/* Toggle Classes controlled by JS */
body.hide-sidebar { --current-sidebar: 0px; }
body.hide-right { --current-right: 0px; }

.app-layout {
    display: grid;
    grid-template-columns: var(--current-sidebar) 1fr var(--current-right);
    height: calc(100vh - var(--player-height));
    transition: grid-template-columns 0.4s cubic-bezier(0.4, 0, 0.2, 1); /* Smooth sliding */
    gap: 8px;
    padding: 8px;
    box-sizing: border-box;
}

/* Panel Base Styles */
.sidebar, .main-wrapper, .right-panel {
    background-color: var(--bg-panel);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Hides content when width becomes 0 */
    white-space: nowrap; /* Prevents text wrapping during animation */
}

/* Fix Sidebar Padding when hidden */
.sidebar { padding: 20px 12px; transition: padding 0.4s; }
body.hide-sidebar .sidebar { padding: 20px 0px; border: none; }

.right-panel { padding: 20px; border: 1px solid rgba(255,255,255,0.05); transition: padding 0.4s; }
body.hide-right .right-panel { padding: 20px 0px; border: none; }

.main-wrapper {
    background: linear-gradient(180deg, #1A0B2E 0%, var(--bg-panel) 40%);
    position: relative;
    min-width: 400px; /* Prevents center from crushing */
}

/* THIS IS WHAT SCROLLS */
.content-scrollable {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    padding-top: 80px; 
    height: 100%;
}

.content-scrollable::-webkit-scrollbar { width: 8px; }
.content-scrollable::-webkit-scrollbar-track { background: transparent; }
.content-scrollable::-webkit-scrollbar-thumb { background: rgba(176, 38, 255, 0.2); border-radius: 4px; }
.content-scrollable::-webkit-scrollbar-thumb:hover { background: rgba(176, 38, 255, 0.5); }

.topbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: var(--topbar-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    background: rgba(18, 8, 28, 0.9);
    backdrop-filter: blur(15px);
    z-index: 100;
}

.hover-icon { cursor: pointer; color: var(--text-subdued); transition: 0.2s; }
.hover-icon:hover { color: var(--text-bright); }

/* --- STRICT RIGHT PANEL HIDE LOGIC --- */
body {
    --current-right: 320px; /* Default width */
    transition: all 0.3s ease;
}

body.hide-right {
    --current-right: 0px !important;
}

/* When hidden, completely destroy the padding, border, and opacity */
body.hide-right .right-panel {
    padding: 0 !important;
    border: none !important;
    width: 0px !important;
    min-width: 0px !important;
    opacity: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
}

/* Ensure the grid actually uses the variable */
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width, 280px) 1fr var(--current-right);
    transition: grid-template-columns 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
















/* =========================================
   HEAVY RESPONSIVENESS: LAYOUT & SIDEBAR
   ========================================= */

@media (max-width: 1100px) {
    /* Tablet: Force hide right panel to save space */
    body { --current-right: 0px !important; }
    .right-panel { display: none !important; }
}

@media (max-width: 768px) {
    /* Mobile: Full width main content */
    body { --current-sidebar: 0px !important; }
    .app-layout { grid-template-columns: 1fr; padding: 0; gap: 0; }
    .main-wrapper { border-radius: 0; }
    
    /* Transform Sidebar into an off-canvas mobile drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: -300px; /* Hidden off-screen by default */
        width: 280px;
        height: calc(100vh - var(--player-height, 96px));
        z-index: 9999;
        border-radius: 0 16px 0 0;
        box-shadow: 10px 0 30px rgba(0,0,0,0);
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* When the javascript adds this class, slide it in! */
    body.show-mobile-sidebar .sidebar {
        left: 0;
        box-shadow: 10px 0 50px rgba(0,0,0,0.8);
    }
}