* {
    box-sizing: border-box;
}

:root {
    /* Core Variables - Default Dark Theme */
    --primary-color: #ff4d00;
    --primary-gradient-start: #d92d00;
    --primary-gradient-end: #ffcc00;
    --primary-hover: #ff7300;

    --bg-color: #050505;
    --sidebar-bg: #111111;
    --content-bg: #111111;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #2d2d2d;
    --header-bg: #111111;

    --header-height: 60px;
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-color: #ffffff;
    --sidebar-bg: #f8f9fa;
    --content-bg: #ffffff;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --header-bg: #f8f9fa;

    /* Adjust primary colors if needed for light mode, or keep vibrant */
    --primary-color: #ea580c;
    /* Slightly darker orange for better contrast on white */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    margin: 0;
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    height: 100vh;
    overflow-x: hidden;
}

/* Sidebar */
.sidebar {
    width: 350px;
    flex-shrink: 0;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px;
    padding-bottom: 80px;
    /* Extra space at bottom */
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.5);
    overflow-y: auto;
    overflow-x: hidden;
    transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

/* Custom Scrollbar for Sidebar */
.sidebar::-webkit-scrollbar {
    width: 5px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

.brand {
    font-size: 1.5rem;
    font-weight: 800;
    /* Gradient Text Effect */
    background: linear-gradient(135deg, var(--primary-gradient-start), var(--primary-gradient-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 30px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    text-shadow: 0px 0px 10px rgba(255, 77, 0, 0.3);
}

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

.nav-links li {
    margin-bottom: 10px;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    padding: 10px;
    display: block;
    border-radius: 6px;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.nav-links a:hover,
.nav-links a.active {
    background-color: rgba(255, 77, 0, 0.1);
    color: var(--primary-color);
    border-color: rgba(255, 77, 0, 0.2);
}

.user-menu {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.sidebar-separator {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-color) 50%, transparent);
    margin: 25px 0;
    opacity: 0.8;
}

/* Main Content */
.main-content {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background-color: var(--bg-color);
}

header {
    height: var(--header-height);
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 40px;
    justify-content: space-between;
}

.search-bar {
    position: relative;
    display: flex;
    align-items: center;
}

.search-bar input {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 8px 16px;
    padding-left: 35px;
    border-radius: 20px;
    width: 250px;
    outline: none;
    transition: var(--transition);
    font-size: 0.9rem;
}

.search-bar::before {
    content: '🔍';
    position: absolute;
    left: 12px;
    font-size: 0.9rem;
    opacity: 0.5;
}

.search-bar input:focus {
    border-color: var(--primary-color);
    width: 300px;
    box-shadow: 0 0 15px rgba(255, 77, 0, 0.1);
}

.search-item {
    transition: var(--transition);
}

.search-item:hover {
    transform: translateX(5px);
    border-color: var(--primary-color) !important;
}

.content-area {
    padding: 40px;
    margin: 0 auto;
    width: 100%;
    flex-grow: 1;
    /* Ensure it pushes footer down */
}

/* Footer Styles */
.main-footer {
    padding: 30px 40px;
    background-color: var(--sidebar-bg);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    width: 100%;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
}

.footer-content {
    margin: 0 auto;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.footer-content p {
    margin: 0;
    font-weight: 500;
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .main-footer {
        width: 100%;
    }
}

/* Typography for Wiki Content */
.wiki-content h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.wiki-content h2 {
    font-size: 1.8rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.wiki-content p {
    line-height: 1.7;
    margin-bottom: 1rem;
    color: var(--text-muted);
    word-break: break-word;
    overflow-wrap: break-word;
}

.wiki-content a {
    color: var(--primary-color);
    text-decoration: none;
}

.wiki-content a:hover {
    text-decoration: underline;
    text-shadow: 0 0 8px rgba(255, 77, 0, 0.4);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--primary-gradient-start), var(--primary-color));
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.btn:hover {
    filter: brightness(1.1);
    box-shadow: 0 0 15px rgba(255, 77, 0, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn-secondary:hover {
    background-color: var(--border-color);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.btn-danger:hover {
    box-shadow: 0 0 15px rgba(220, 38, 38, 0.4);
}

.w-full {
    width: 100%;
    text-align: center;
    box-sizing: border-box;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.9rem;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 10px;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 6px;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(255, 77, 0, 0.2);
}

textarea.form-control {
    min-height: 400px;
    resize: vertical;
}

.login-container {
    max-width: 400px;
    margin: 100px auto;
    background: var(--sidebar-bg);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
}

.alert-error {
    background: rgba(220, 38, 38, 0.2);
    border: 1px solid rgba(220, 38, 38, 0.5);
    color: #fca5a5;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 20px;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    body {
        flex-direction: column;
        overflow: auto;
        /* Allow body scroll on mobile if needed */
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        height: 100vh;
        width: 280px;
        z-index: 2000;
        transform: translateX(-100%);
        box-shadow: 10px 0 20px rgba(0, 0, 0, 0.4);
        padding-top: 60px;
        /* Custom scroll behavior for mobile */
        -webkit-overflow-scrolling: touch;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
        width: 100%;
        height: auto;
        overflow-y: visible;
        /* Let the body handle scrolling if flexed to column */
    }

    header {
        position: sticky;
        top: 0;
        z-index: 100;
        padding: 0 15px;
        background: var(--header-bg);
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    }

    .content-area {
        padding: 20px 15px;
    }

    .wiki-content h1 {
        font-size: 1.8rem;
    }

    .hamburger {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: var(--text-color);
        font-size: 1.8rem;
        cursor: pointer;
        padding: 5px;
        width: 40px;
        height: 40px;
        border-radius: 4px;
        transition: background 0.2s;
    }

    .hamburger:active {
        background: rgba(var(--primary-color), 0.1);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(4px);
        z-index: 1500;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }

    /* Form improvements on mobile */
    .form-actions {
        flex-direction: column;
        gap: 15px;
        align-items: stretch !important;
    }

    .btn {
        text-align: center;
    }
}

.hamburger {
    display: none;
}