:root {
    --primary-color: #007bff;
    --bg-color: #f4f6f9;
    --sidebar-bg: #fff;
    --text-color: #333;
    --border-color: #e0e0e0;
    --code-bg: #f5f5f5;
    --hover-bg: #f0f0f0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    min-height: 100vh;
    /* overflow removed to allow native scroll */
}

/* Login Page */
body.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.login-container {
    background: var(--sidebar-bg);
    padding: 2rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-align: center;
    width: 300px;
}

.login-container h1 {
    color: var(--primary-color);
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 15px;
}

input[type="text"], input[type="password"] {
    width: 100%;
    padding: 10px;
    background: var(--code-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 4px;
    box-sizing: border-box;
}

button {
    background: var(--primary-color);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    width: 100%;
}

button.secondary {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    margin-top: 10px;
}

button:hover {
    opacity: 0.9;
}

/* Main Layout */
.app-wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.sidebar {
    width: 300px; 
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    flex-shrink: 0;
}

.brand {
    padding: 20px;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
}

.nav-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.category-title {
    padding: 15px 20px 5px;
    font-size: 0.85rem;
    text-transform: uppercase;
    color: #666;
    font-weight: bold;
}

.nav-item {
    border-bottom: 1px solid var(--border-color);
}

.nav-item a {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 20px;
    color: var(--text-color);
    text-decoration: none;
    transition: background 0.2s;
}

.nav-item a i {
    margin-top: 4px; /* Align with text top */
    flex-shrink: 0;
    width: 16px; 
    text-align: center;
}

.nav-item a:hover, .nav-item a.active {
    background-color: var(--hover-bg);
    color: var(--primary-color);
    border-left: 3px solid var(--primary-color);
}

.main-content {
    flex: 1;
    padding: 40px;
    position: relative;
    background: white; 
}

/* Markdown Container Limit */
.markdown-body {
    max-width: 900px; 
    margin: 0 auto;
    padding-bottom: 50px;
}

.sidebar-footer {
    margin-top: auto;
    padding: 20px;
    border-top: 1px solid var(--border-color);
}


.sidebar-footer a {
    color: #666;
    text-decoration: none;
    font-size: 0.9em;
    display: block;
}

.sidebar-footer a:hover {
    color: var(--primary-color);
}

* {
    box-sizing: border-box;
}

/* Markdown Content Styles */
.markdown-body {
    line-height: 1.6;
    overflow-wrap: break-word;
    word-wrap: break-word;
    min-width: 0;
}

.markdown-body img {
    max-width: 100%;
    height: auto;
}

.markdown-body pre {
    max-width: 100%;
    white-space: pre-wrap;
    word-break: break-all;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    color: var(--text-color); /* Changed from primary for better readability in light mode, or keep primary? Let's use text-color for headers usually, or primary is fine. User said light theme. Let's stick to primary for brand feel but maybe darker. Actually, let's keep primary but ensure it's readable. */
    color: #333;
    margin-top: 1.5em;
}

.markdown-body a {
    color: var(--primary-color);
}

.markdown-body pre {
    background: var(--code-bg);
    padding: 15px;
    border-radius: 5px;
    border: 1px solid var(--border-color);
    overflow-x: auto;
}

.markdown-body code {
    font-family: monospace;
}

.markdown-body img {
    max-width: 100%;
    border-radius: 5px;
}

.markdown-body blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 15px;
    color: #aaa;
    margin: 0;
}

/* Admin Styles */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.admin-layout {
    display: flex;
    gap: 30px;
}

.admin-sidebar { width: 30%; }
.admin-editor { width: 70%; }

@media (max-width: 768px) {
    .admin-layout { flex-direction: column; }
    .admin-sidebar, .admin-editor { width: 100%; }
}

.editor-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 100%;
}

textarea#content-editor {
    width: 100%;
    min-height: 500px;
    background: var(--code-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 15px;
    font-family: monospace;
    resize: vertical;
}

.file-list-admin table {
    width: 100%;
    border-collapse: collapse;
}

.file-list-admin th, .file-list-admin td {
    text-align: left;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
}

.actions a {
    color: var(--primary-color);
    margin-right: 10px;
    text-decoration: none;
}

.btn-small {
    padding: 5px 10px;
    font-size: 0.8rem;
}

.alert {
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
}
.alert-success { background: rgba(3, 169, 244, 0.2); border: 1px solid var(--primary-color); color: var(--primary-color); }
.alert-error { background: rgba(255, 0, 0, 0.2); border: 1px solid red; color: red; }

/* Mobile Styles */
.mobile-header {
    display: none;
    background: var(--sidebar-bg);
    padding: 10px 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    justify-content: flex-start;
    gap: 15px;
    width: 100%;
}

#sidebar-toggle {
    width: auto;
    padding: 8px 12px;
    font-size: 0.9rem;
}

.brand-mobile {
    font-weight: bold;
    color: var(--primary-color);
}

/* ... existing unlock-popup ... replaced by new layout, keep if any left */


#unlock-popup {
    display: none;
    position: absolute;
    top: 30px;
    right: 0;
    background: #fff;
    border: 1px solid var(--border-color);
    padding: 5px;
    border-radius: 4px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    gap: 5px;
}

#unlock-popup input {
    border: 1px solid #ddd;
    padding: 5px;
    border-radius: 3px;
    font-size: 12px;
    width: 120px;
}

#unlock-popup button {
    background: var(--primary-color);
    border: none;
    color: white;
    padding: 5px 8px;
    border-radius: 3px;
    cursor: pointer;
    width: auto;
}

@media (max-width: 768px) {
    .app-wrapper {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: -310px; /* Hide off-canvas */
        top: 0;
        bottom: 0;
        z-index: 500; /* Higher z-index for mobile */
        transition: left 0.3s ease;
        width: 300px;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        overflow-y: auto; /* Enable scrolling for menu */
    }

    .sidebar.open {
        left: 0;
    }

    body.menu-open {
        overflow: hidden !important; /* Lock background scroll */
        height: 100vh;
    }

    #mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.7);
        z-index: 150;
        display: none;
    }

    #mobile-overlay.active {
        display: block;
    }

    .main-content {
        padding: 20px; /* Reset padding for mobile */
        width: 100%;
    }

    .mobile-header {
        display: flex;
    }
}

/* Project Access Top-Right in Main Content */
.main-content {
    position: relative; /* Ensure absolute children are relative to this */
}

#project-access-container {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 100;
    max-width: 300px;
    width: 100%;
}

@media (max-width: 768px) {
    #project-access-container {
        position: relative;
        top: 0;
        right: 0;
        margin-bottom: 20px;
        width: 100%;
        max-width: 100%;
    }
}

#project-input-wrapper {
    display: flex;
    width: 100%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border-radius: 20px;
}

#project-input-wrapper input {
    flex: 4; /* 80% */
    width: 0; /* allows shrinking */
    padding: 8px 15px;
    border-radius: 20px 0 0 20px;
    border: 1px solid #ddd;
    outline: none;
    font-size: 14px;
}

#project-input-wrapper button {
    flex: 1; /* 20% */
    width: 0;
    padding: 8px 0;
    border-radius: 0 20px 20px 0;
    background: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.project-display {
    display: flex; 
    align-items: center; 
    gap: 10px; 
    background: #fff; 
    padding: 8px 15px; 
    border-radius: 20px; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); 
    border: 1px solid #ddd;
    justify-content: space-between;
}
.code-label { font-weight: bold; color: var(--primary-color); font-size: 14px; }

.arrow-hint {
    position: absolute;
    top: 45px;
    right: 50px;
    color: var(--primary-color);
    font-size: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: bounce 1s infinite alternate;
}

.arrow-hint span {
    font-size: 12px;
    white-space: nowrap;
    margin-top: 2px;
}
/* Toast Notification */
.toast {
    visibility: hidden;
    min-width: 250px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 4px;
    padding: 16px;
    position: fixed;
    z-index: 9999;
    right: 30px;
    bottom: 30px;
    font-size: 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    transition: opacity 0.3s, bottom 0.3s;
}

.toast.show {
    visibility: visible;
    opacity: 1;
    bottom: 50px;
}

.toast.success { background-color: #28a745; }
.toast.error { background-color: #dc3545; }

/* Logout Button */
.logout-btn {
    color: #666; 
    cursor: pointer; 
    font-size: 16px; 
    margin-left: 10px;
    transition: color 0.2s;
    text-decoration: none;
}
.logout-btn:hover {
    color: #dc3545;
}
.logout-btn:hover::after {
    content: attr(title);
    position: absolute;
    top: 100%;
    right: 0;
    width: max-content;
    background: #333;
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    margin-top: 5px;
}
.project-display {
    position: relative; /* For tooltip positioning */
}

/* Inline Input Message */
.input-message {
    display: none;
    font-size: 12px;
    margin-top: 5px;
    text-align: right; 
    padding-right: 10px;
    font-weight: 500;
}
.input-message.error {
    color: #dc3545;
}
.input-message.success {
    color: #28a745;
}
.input-group-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end; /* Align input and message to right */
    width: 100%;
}
