html, body {
    height: 100%;
}

/* This assumes your main content wrapper in app_base.html is .page-container */
.page-container {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    width: 100%;
}

/*
=========================================
    GLOBAL STYLES & VARIABLES
=========================================
*/
:root {
    --primary-color: #4a69bd;
    --primary-hover-color: #3c5699;
    --background-color: #f4f7f9;
    --container-bg-color: #ffffff;
    --text-color: #333333;
    --text-light-color: #666666;
    --border-color: #dddddd;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --font-family: 'Roboto', sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

h1, h2, h3 {
    margin-bottom: 0.5em;
    font-weight: 500;
}

/*
=========================================
    DARK MODE STYLES (Auto-detect)
=========================================
*/
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #5a82e0;
        --primary-hover-color: #789ff0;
        --background-color: #121212;
        --container-bg-color: #1e1e1e;
        --text-color: #e1e1e1;
        --text-light-color: #a8a8a8;
        --border-color: #444444;
        --shadow-color: rgba(0, 0, 0, 0.5);
    }
}
/*
=========================================
    SHARED APP HEADER STYLES
=========================================
*/
.app-header {
    background-color: var(--container-bg-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    /* justify-content is no longer needed */
}

.app-header-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.app-header-icon {
    font-size: 1.75rem;
    color: var(--primary-color);
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

/* This is the container for the buttons on the right */
.app-header-actions {
    display: flex; /* This makes the buttons side-by-side */
    align-items: center;
    gap: 1rem; /* Creates space between the buttons */
}

.btn-back-to-hub, .btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: 0.3rem;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.2s ease;
}

.btn-back-to-hub {
    /* New background color for better contrast */
    background-color: var(--text-light-color); /* This is often a lighter grey */
    color: white; /* Keep text white for good contrast with the new background */
}
.btn-back-to-hub:hover {
    background-color: #5a6268; /* A slightly darker grey for hover state */
}

.btn-logout {
    background-color: var(--primary-color);
    color: white;
    font-family: inherit;
}
.btn-logout:hover { background-color: var(--primary-hover-color); }


/*
=========================================
    SIDEBAR NAVIGATION STYLES
=========================================
*/
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    width: 250px;
    background-color: var(--container-bg-color);
    border-right: 1px solid var(--border-color);
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
}

.sidebar.is-open {
    transform: translateX(0);
}

.sidebar-header {
    padding: 1rem 1.5rem;
    font-size: 1.2rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-links {
    flex-grow: 1; /* The key: tells this container to fill all empty vertical space */
    overflow-y: auto; /* Adds a scrollbar if the links overflow */
}

/* General style for regular navigation links in the sidebar */
.sidebar-links a {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    text-decoration: none;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
}

.sidebar-links a:hover {
    background-color: var(--background-color);
}

.sidebar-links a i {
    width: 20px;
}

/* Specific styles for the actions at the bottom */
.sidebar-actions {
    margin-top: auto;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Base styles for BOTH buttons in the action area */
.sidebar-actions .btn-back-to-hub,
.sidebar-actions .btn-logout {
    display: flex;
    width: 100%;
    justify-content: center;
    margin-bottom: 0.5rem;
    border-bottom: none; /* Override the generic link style */
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 0.3rem;
    white-space: nowrap;
    transition: background-color 0.2s ease;
}

/* Highly specific color rule for the "Back to Hub" button */
.sidebar-actions a.btn-back-to-hub {
    background-color: #6c757d;
    color: white;
}
.sidebar-actions a.btn-back-to-hub:hover {
    background-color: #5a6268;
}

/* Highly specific color rule for the "Logout" button */
.sidebar-actions button.btn-logout {
    background-color: var(--primary-color);
    color: white;
}
.sidebar-actions button.btn-logout:hover {
    background-color: var(--primary-hover-color);
}


/* Dark overlay for when the menu is open */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.sidebar-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* Hamburger button */
.hamburger-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-color);
    padding: 0 0.5rem;
}