/* ============================= */
/* 🎨 Root Variables             */
/* ============================= */
:root {
    --font-stack: 'Inter', Arial, sans-serif;
    --container-width: 90%;
    --border-radius: 15px;

    --shadow-main: 0 4px 10px rgba(0, 0, 0, 0.3);
    --shadow-text: 1px 1px 2px rgba(0, 0, 0, 0.5);
    --z-index-header-footer: 1000;
    --z-index-main: 500;
    --z-index-footer-bot: 1000;


    /* The main content area's background image */
    --bubble-bg-light: url("../images/bg_lm.png"); 
    --bubble-bg-dark: url("../images/bg_dm.png");

    --scrollbar-track-light: #e0e0e0;
    --scrollbar-thumb-light: #88c9be;
    --scrollbar-track-dark: #2c2c2c;
    --scrollbar-thumb-dark: #546E7A;

    --color-primary-dark: rgb(27, 27, 29);
    --color-hover-dark: #455A64;
    --color-primary-light: #f5f5f5;
    --color-hover-light: #88c9be;

    /*  Color variables used in components */
    --color-dark-bg: var(--color-primary-dark);
    --color-light-bg: var(--color-primary-light);
    --color-text-light: #222;
    --color-text-dark: #eee;
}

/* ============================= */
/* 📐 Base Layout Setup          */
/* ============================= */
html, body {
    height: 100vh;
    margin: 0;
    overflow: hidden;
    font-family: var(--font-stack);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.layout {
    display: grid;
    
    grid-template-columns: 200px 1fr;
    grid-template-areas:
        "header-area header-area"
        "sidebar main-area"
        "footer-area footer-area"; 
    
    grid-template-rows: auto 1fr auto;
    height: 100vh;
    margin-left: 0; 
}

/* ============================= */
/* 🧩 Components                 */
/* ============================= */
header {
    grid-area: header-area; 
    padding: 1rem 2rem;
    /* box-shadow: var(--shadow-main); Removed for visual unity. Kept incase of undesired outcome*/
    z-index: var(--z-index-header-footer);
    border-radius: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

footer {
    grid-area: footer-area;
    
    padding: 1rem 2rem;
    /* box-shadow: var(--shadow-main); Removed for visual unity. Kept incase of undesired outcome*/
    z-index: var(--z-index-header-footer);
    border-radius: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.left-sidebar {
    grid-area: sidebar; 
    width: 100%; 
    height: 100%; 
    
    display: flex;
    flex-direction: column;
    /* box-shadow: var(--shadow-main); Removed for visual unity. Kept incase of undesired outcome*/
    z-index: var(--z-index-header-footer);
    /* border-right: 1px solid rgba(0, 0, 0, 0.1); Removed for visual unity. Kept incase of undesired outcome*/ 
    overflow: hidden;
}

.left-sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1rem;
    box-sizing: border-box;
    gap: 1rem; 
}

.sidebar-top {
    /* border-bottom: 1px solid rgba(255, 255, 255, 0.1); Removed for visual unity. Kept incase of undesired outcome*/
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 0.5rem 0;
}

.sidebar-bottom {
    flex-grow: 1;
    min-height: 0; 
    overflow-y: auto;
    padding-top: 1rem;
    /* border-top: 1px solid rgba(255, 255, 255, 0.1); Removed for visual unity. Kept incase of undesired outcome*/
    
    display: flex;
    flex-direction: column;
    gap: 1rem;

    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb-light) var(--scrollbar-track-light);
}

/* Navigation Links */
.nav-link {
    display: block;
    padding: 0.5rem 0.5rem;
    margin: 0.25rem 0;
    text-decoration: none;
    border-radius: 8px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.nav-link:hover {
    background-color: var(--color-hover-dark);
}

.nav-link.active {
    background-color: var(--color-hover-dark);
    font-weight: 700;
}

/* Card styles */
.card {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.app-button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.app-button:hover {
    background-color: #70b3a8;
}

.app-button:active {
    transform: scale(0.98);
}

/* ============================= */
/* 📦 Main Content Bubble        */
/* ============================= */
.content-bubble {
    grid-area: main-area; 
    padding: 2rem;
    padding-bottom: 2rem; 
    overflow-y: auto;
    min-height: 0;
    min-width: 100%;
    border-radius: var(--border-radius);
    z-index: var(--z-index-main);
    transition: background-color 0.3s ease, background-image 0.3s ease, box-shadow 0.3s ease;

    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(0, 0, 0, 0.1);
    background-blend-mode: overlay;
}

.content-inner {
    /* max-width: 900px; */
    width: 100%;
    margin: 0 auto;
}

/* --------------------------------- */
/* Scrollbar Styling (Webkit)        */
/* Used in both main content and     */
/* sidebar bottom container          */
/* --------------------------------- */

.content-bubble::-webkit-scrollbar, 
.sidebar-bottom::-webkit-scrollbar {
    width: 8px;
}

.content-bubble::-webkit-scrollbar-track, 
.sidebar-bottom::-webkit-scrollbar-track {
    background: var(--scrollbar-track-light);
}

.content-bubble::-webkit-scrollbar-thumb, 
.sidebar-bottom::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb-light);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: content-box;
}

.content-bubble::-webkit-scrollbar-thumb:hover, 
.sidebar-bottom::-webkit-scrollbar-thumb:hover {
    background-color: var(--color-hover-light);
}

/* ============================= */
/* 🌗 Color Scheme Adaptation    */
/* ============================= */
@media (prefers-color-scheme: light) {
    body {
        background-color: var(--color-primary-light);
        color: var(--color-text-light);
    }

    .content-bubble {
        background-image: var(--bubble-bg-light);
        background-color: rgba(255, 255, 255, 0.85);
    }
    
    header, footer, .left-sidebar, .sidebar-top, .sidebar-bottom {
        background-color: var(--color-primary-light);
        color: var(--color-text-light);
    }
    
    .nav-link {
        color: var(--color-text-light);
    }

  
    /* Depreceated.  Kept incase of reverting. 
    .left-sidebar {
        border-right: 1px solid rgba(0, 0, 0, 0.1);
    }
    */
    
    .card {
        background-color: #ffffff;
        border: 1px solid #ddd;
    }
    
    .app-button {
        background-color: var(--color-hover-light);
        color: var(--color-primary-dark);
    }
}

@media (prefers-color-scheme: dark) {
    body {
        background-color: var(--color-primary-dark);
        color: var(--color-text-dark);
    }
    
    .content-bubble {
        background-image: var(--bubble-bg-dark);
        background-position: center center;
        background-repeat: no-repeat;
        background-attachment: fixed;
        background-size: cover;
        background-color: rgba(18, 18, 18, 0.7);
        box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.05);
    }
    
    /* Dark mode scrollbar styling */
    .content-bubble, .sidebar-bottom {
        scrollbar-color: var(--scrollbar-thumb-dark) var(--scrollbar-track-dark);
    }

    .content-bubble::-webkit-scrollbar-track,
    .sidebar-bottom::-webkit-scrollbar-track {
        background: var(--scrollbar-track-dark);
    }

    .content-bubble::-webkit-scrollbar-thumb,
    .sidebar-bottom::-webkit-scrollbar-thumb {
        background-color: var(--scrollbar-thumb-dark);
    }

    .content-bubble::-webkit-scrollbar-thumb:hover,
    .sidebar-bottom::-webkit-scrollbar-thumb:hover {
        background-color: var(--color-hover-dark);
    }

    /* Deprecated. Kept in case of reverting
    .left-sidebar {
        /* border-right: 1px solid rgba(255, 255, 255, 0.05); 
    }
    */

    header, footer, .left-sidebar, .sidebar-top, .sidebar-bottom {
        background-color: var(--color-primary-dark);
    }
    
    .card {
        background-color: rgba(35, 35, 37, 0.8);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .app-button {
        background-color: var(--color-hover-dark);
        color: var(--color-text-dark);
    }
    
    .app-button:hover {
        background-color: #607d8b;
    }
}

/* ============================= */
/* 📱 Responsive Adjustments     */
/* ============================= */
@media (max-width: 768px) {
    .layout {
        /* Mobile Layout: Single column, sidebar hidden */
        grid-template-columns: 1fr;
        grid-template-areas:
            "header-area"
            "main-area"
            "footer-area"; 
        margin-left: 0;
    }

    .left-sidebar {
        display: none;
    }

    .content-bubble {
        border-radius: var(--border-radius);
        padding: 1rem;
        padding-bottom: 1rem; 
    }
    
    header, footer {
        padding: 1rem;
    }
}
