/* backend/static/css/modules/layout.css */

:root {
    --sidebar-width: 240px; /* Reduced from 280px for more content space */
}

/* --- CRITICAL GLOBAL LAYOUT FIXES --- */
/* Lock the body to prevent global scrolling FOR THE APP VIEW ONLY.
   Static pages (About, Terms, Landing) need to scroll normally.
   We achieve this by NOT putting overflow:hidden on html/body globally,
   but rather containing it within the .app-container. */
   
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    background-color: var(--color-background);
}

/* --- Main App Container --- */
/* This is the container for the logged-in app experience */
.app-container {
    display: flex;
    height: var(--visual-height, 100dvh); 
    width: 100%;
    flex-direction: column; /* Mobile first: Column */
    overflow: hidden !important; /* Locks scrolling to the inner wrapper */
    overscroll-behavior-y: none;
}

/* --- Sidebar (Desktop) --- */
.sidebar {
    display: none; /* Hidden on mobile */
    flex-direction: column;
    width: var(--sidebar-width);
    background-color: var(--color-surface);
    border-right: 1px solid var(--color-border);
    flex-shrink: 0;
    padding: 2rem 1.5rem;
    height: 100%; 
    z-index: 50;
    transition: background-color 0.3s ease;
}

.sidebar-header { 
    margin-bottom: 2.5rem; 
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-text { 
    font-size: 1.5rem; 
    font-weight: 800; 
    margin: 0; 
    letter-spacing: -0.02em;
    color: var(--color-primary-dark); 
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex-grow: 1;
}

.sidebar-footer {
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* --- Mobile Header --- */
.mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1rem;
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
    z-index: 50;
    height: 60px; /* Fixed height for consistency */
}

.mobile-logo-text {
    font-size: 1.25rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.02em;
    color: var(--color-primary-dark);
}

.mobile-streak-badge {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

.streak-count-mobile {
    color: var(--color-text);
    font-family: var(--font-sans);
    display: inline-block;
}

/* --- Main Content Area --- */
.main-content-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden !important; 
    height: 100%;
    min-height: 0;
    position: relative;
    z-index: 1;
}

.app-content-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto; 
    min-height: 0; 
    position: relative; 
    -webkit-overflow-scrolling: touch; 
}

/* --- Responsive Design: Desktop Layout --- */
@media (min-width: 769px) {
    .app-container {
        flex-direction: row;
    }

    .sidebar {
        display: flex;
    }
    
    .mobile-header {
        display: none;
    }
}

/* --- Global Polish --- */
* { -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
::selection {
    background-color: rgba(var(--color-primary-rgb), 0.2);
    color: var(--color-text);
}
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background-color: rgba(var(--color-text-rgb), 0.15);
    border-radius: 4px;
    border: 1px solid transparent; 
    background-clip: content-box;
    transition: background-color 0.2s;
}
::-webkit-scrollbar-thumb:hover {
    background-color: rgba(var(--color-text-rgb), 0.3);
}

/* --- GLOBAL FOCUS MODE (Hide Nav) --- */
/* Used by Tools and Spaces */
body.tool-open .mobile-header,
body.tool-open .tab-bar,
body.tool-open .sidebar {
    display: none !important;
}

/* --- GLOBAL CATEGORY THEMES --- */
/* Applies to sections with a title and a data-category attribute on the parent (e.g. Activity Sections) */
[data-category="mental"] .section-title::before { background-color: var(--color-category-mental); }
[data-category="physical"] .section-title::before { background-color: var(--color-category-physical); }
[data-category="emotional"] .section-title::before { background-color: var(--color-category-emotional); }
[data-category="spiritual"] .section-title::before { background-color: var(--color-category-spiritual); }
[data-category="social"] .section-title::before { background-color: var(--color-category-social); }
