/* ==========================================================================
   Base Reset & Variables
   ========================================================================== */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
    font-family: sans-serif; 
}

:root { 
    --primary: #1a365d; 
    --secondary: #2b6cb0; 
    --bg: #f7fafc; 
    --text: #2d3748; 
}

body { 
    display: flex; 
    flex-direction: column; 
    height: 100vh; 
    background: var(--bg); 
    color: var(--text); 
}

/* ==========================================================================
   Universal Header
   ========================================================================== */
.app-header {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    background: var(--primary); 
    color: white; 
    padding: 0 20px; 
    height: 60px;
}

.brand-group { 
    display: flex; 
    align-items: center; 
    gap: 15px; 
}

.brand-logo { 
    font-size: 1.5rem; 
    font-weight: bold; 
    text-decoration: none; 
    color: white; 
}

.mobile-toggle { 
    display: none; 
    background: none; 
    border: none; 
    color: white; 
    font-size: 1.5rem; 
    cursor: pointer; 
}

.session-group a { 
    color: white; 
    text-decoration: none; 
    font-weight: bold; 
}

/* ==========================================================================
   Layout Wrapper & Navigation
   ========================================================================== */
.app-body { 
    display: flex; 
    flex: 1; 
    overflow: hidden; 
}

.app-nav {
    width: 250px; 
    background: white; 
    border-right: 1px solid #e2e8f0;
    display: flex; 
    flex-direction: column; 
    padding: 20px 0; 
    transition: transform 0.3s ease;
}

.app-nav a { 
    padding: 15px 20px; 
    text-decoration: none; 
    color: var(--text); 
    display: block; 
    border-bottom: 1px solid #edf2f7; 
}

.app-nav a:hover { 
    background: var(--bg); 
    color: var(--secondary); 
}

.app-content { 
    flex: 1; 
    padding: 20px; 
    overflow-y: auto; 
}

/* ==========================================================================
   Auth Modal & Forms
   ========================================================================== */
.modal-overlay {
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: rgba(0, 0, 0, 0.5); 
    z-index: 1000; 
    justify-content: center; 
    align-items: center;
}

.modal-overlay.active { 
    display: flex; 
}

.modal-content {
    background: white; 
    padding: 30px; 
    border-radius: 8px; 
    width: 90%; 
    max-width: 400px;
    position: relative; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.close-modal {
    position: absolute; 
    top: 15px; 
    right: 20px; 
    font-size: 1.5rem; 
    cursor: pointer; 
    color: #718096; 
    line-height: 1;
}

.modal-content h2 { 
    margin-bottom: 20px; 
    color: var(--primary); 
    text-align: center; 
}

.modal-form input {
    width: 100%; 
    padding: 12px; 
    margin-bottom: 15px; 
    border: 1px solid #cbd5e0; 
    border-radius: 4px; 
    font-size: 1rem;
}

/* Buttons */
.btn-primary, .btn-login {
    width: 100%; 
    padding: 12px; 
    background: var(--secondary); 
    color: white;
    border: none; 
    border-radius: 4px; 
    font-size: 1rem; 
    cursor: pointer; 
    font-weight: bold;
}

.btn-login { 
    width: auto; 
    padding: 8px 16px; 
    background: transparent; 
    border: 1px solid white; 
}

.btn-primary:hover, .btn-login:hover { 
    opacity: 0.9; 
}

/* Modal Links & Flow Control */
.modal-links { 
    display: flex; 
    justify-content: space-between; 
    margin-top: 15px; 
    font-size: 0.9rem; 
}

.modal-links a { 
    color: var(--secondary); 
    text-decoration: none; 
    cursor: pointer; 
}

.modal-links a:hover { 
    text-decoration: underline; 
}

.auth-flow { 
    display: none; 
}

.auth-flow.active { 
    display: block; 
}

/* ==========================================================================
   Mobile Responsive Adjustments
   ========================================================================== */
@media (max-width: 768px) {
    .mobile-toggle { 
        display: block; 
    }
    
    .app-nav {
        position: absolute; 
        height: calc(100vh - 60px); 
        z-index: 100;
        transform: translateX(-100%); /* Hidden by default on mobile */
    }
    
    .app-nav.mobile-open { 
        transform: translateX(0); 
    }
}

/* ==========================================================================
   Collapsible Navigation Submenus
   ========================================================================== */
.nav-group-toggle {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.nav-group-toggle::after {
    content: '▼';
    font-size: 0.75rem;
    transition: transform 0.3s ease;
    color: #a0aec0;
}

.nav-group-toggle.open::after {
    transform: rotate(180deg);
}

.nav-submenu {
    display: none;
    background-color: #f7fafc;
    border-bottom: 1px solid #edf2f7;
}

.nav-submenu.open {
    display: block;
}

.nav-submenu a {
    padding: 12px 20px 12px 40px; /* Extra left padding for indentation */
    font-size: 0.95rem;
    border-bottom: none;
    color: #4a5568;
}

.nav-submenu a:hover {
    color: var(--secondary);
    background-color: #edf2f7;
}