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

:root {
    --sidebar-width: 240px;
}

/* --- 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: var(--color-surface);
    border-right: 1px solid rgba(var(--color-border-rgb), 0.6);
    flex-shrink: 0;
    padding: 1.75rem 1.25rem;
    height: 100%; 
    z-index: 50;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* Subtle top-to-bottom gradient wash on the sidebar */
.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: linear-gradient(180deg, 
        rgba(var(--color-primary-rgb), 0.03) 0%, 
        transparent 100%
    );
    pointer-events: none;
    z-index: 0;
}

.sidebar > * {
    position: relative;
    z-index: 1;
}

.sidebar-header { 
    margin-bottom: 2rem; 
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(var(--color-border-rgb), 0.4);
}

.logo-text { 
    font-size: 1.4rem; 
    font-weight: 800; 
    margin: 0; 
    letter-spacing: -0.03em;
    color: var(--color-primary-dark);
    background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 0.25rem;
    /* Fade scrollbar region */
    mask-image: linear-gradient(to bottom, black calc(100% - 8px), transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 8px), transparent 100%);
}

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

/* --- Mobile Header --- */
.mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(var(--color-surface-rgb), 0.95);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid rgba(var(--color-border-rgb), 0.4);
    flex-shrink: 0;
    z-index: 50;
    height: 56px;
}

.mobile-logo-text {
    font-size: 1.2rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.02em;
    color: var(--color-primary-dark);
    background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.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;
    /* Smooth scrolling with momentum */
    scroll-behavior: smooth;
}

/* --- 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);
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 5px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background-color: rgba(var(--color-text-rgb), 0.12);
    border-radius: 100px;
    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.25);
}

/* --- 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); }

/* --- Global Animations --- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
