/* Global Reset */
* {
    margin: 0;
    padding: 0;
    -webkit-box-sizing: border-box; /* Chrome 33 compatibility */
    box-sizing: border-box;
}

body {
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f0f2f5;
    position: relative;
    min-height: 100vh;
    -webkit-transition: padding-left 0.3s ease; /* Chrome 33 compatibility */
    transition: padding-left 0.3s ease;
}

.clearfix:after {
    content: "";
    display: table;
    clear: both;
}

/* Page Container */
.page-container {
    padding-top: 60px; /* Header height */
    /* margin-left will be handled by content-area */
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #fff;
    border-bottom: 1px solid #ddd;
    z-index: 1000;
    -webkit-box-shadow: 0 2px 5px rgba(0,0,0,0.1); /* Chrome 33 compatibility */
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    padding: 0 20px;
}

.header-content {
    display: -webkit-box; /* Chrome 33 compatibility */
    display: -webkit-flex; /* Chrome 33 compatibility */
    display: flex;
    -webkit-box-align: center; /* Chrome 33 compatibility */
    -webkit-align-items: center; /* Chrome 33 compatibility */
    align-items: center;
    -webkit-box-pack: justify; /* Chrome 33 compatibility */
    -webkit-justify-content: space-between; /* Chrome 33 compatibility */
    justify-content: space-between;
    height: 100%;
    width: 100%;
}

.header-left,
.header-center,
.header-right {
    display: -webkit-box; /* Chrome 33 compatibility */
    display: -webkit-flex; /* Chrome 33 compatibility */
    display: flex;
    -webkit-box-align: center; /* Chrome 33 compatibility */
    -webkit-align-items: center; /* Chrome 33 compatibility */
    align-items: center;
}

.header-left {
    -webkit-box-pack: start; /* Chrome 33 compatibility */
    -webkit-justify-content: flex-start; /* Chrome 33 compatibility */
    justify-content: flex-start;
    -webkit-flex-shrink: 0; /* Chrome 33 compatibility */
    flex-shrink: 0;
}

.header-center {
    -webkit-box-pack: center; /* Chrome 33 compatibility */
    -webkit-justify-content: center; /* Chrome 33 compatibility */
    justify-content: center;
    -webkit-box-flex: 1; /* Chrome 33 compatibility */
    -webkit-flex-grow: 1; /* Chrome 33 compatibility */
    flex-grow: 1;
}

.header-right {
    -webkit-box-pack: end; /* Chrome 33 compatibility */
    -webkit-justify-content: flex-end; /* Chrome 33 compatibility */
    justify-content: flex-end;
    -webkit-flex-shrink: 0; /* Chrome 33 compatibility */
    flex-shrink: 0;
    white-space: nowrap; /* Ensure buttons do not wrap */
}

.logo {
    font-size: 1.4rem;
    font-weight: bold;
    color: #2563eb;
    text-decoration: none;
    display: -webkit-box; /* Chrome 33 compatibility */
    display: -webkit-flex; /* Chrome 33 compatibility */
    display: flex;
    -webkit-box-align: center; /* Chrome 33 compatibility */
    -webkit-align-items: center; /* Chrome 33 compatibility */
    align-items: center;
    vertical-align: middle;
}

.logo img {
    max-height: 40px;
    width: auto;
    vertical-align: middle;
}

/* Header Navigation (from Wiki Page) */
.header-nav {
    display: inline-block;
    vertical-align: middle;
}

.header-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: -webkit-box; /* Chrome 33 compatibility */
    display: -webkit-flex; /* Chrome 33 compatibility */
    display: flex;
}

.header-nav li {
    margin: 0 15px;
}

.header-nav a {
    color: #333;
    text-decoration: none;
    font-weight: 500;
    -webkit-transition: color 0.2s ease; /* Chrome 33 compatibility */
    transition: color 0.2s ease;
}

.header-nav a:hover {
    color: #2563eb;
}

/* Search form styles */
.search-form {
    display: -webkit-box; /* Chrome 33 compatibility */
    display: -webkit-flex; /* Chrome 33 compatibility */
    display: flex;
    -webkit-box-align: center; /* Chrome 33 compatibility */
    -webkit-align-items: center; /* Chrome 33 compatibility */
    align-items: center;
}

.search-input {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    width: 180px;
    -webkit-transition: border-color 0.2s ease; /* Chrome 33 compatibility */
    transition: border-color 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: #2563eb;
}

.search-button {
    background: #2563eb;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 5px;
    -webkit-transition: background 0.2s ease; /* Chrome 33 compatibility */
    transition: background 0.2s ease;
}

.search-button:hover {
    background: #1d4ed8;
}

/* Mobile and desktop sidebar toggle buttons */
.mobile-menu-toggle, .desktop-sidebar-toggle {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #333;
    margin-right: 15px;
    vertical-align: middle;
}

.mobile-menu-toggle { display: none; }
.desktop-sidebar-toggle { display: inline-block; }


/* PmWiki Page Action Buttons (wikicmds) */
.wikicmds {
    display: -webkit-box; /* Chrome 33 compatibility */
    display: -webkit-flex; /* Chrome 33 compatibility */
    display: flex;
    -webkit-box-align: center; /* Chrome 33 compatibility */
    -webkit-align-items: center; /* Chrome 33 compatibility */
    align-items: center;
    list-style-type: none;
    margin: 0;
    padding: 0;
}

.wikicmds ul { /* PmWiki default ul */
    display: -webkit-box; /* Chrome 33 compatibility */
    display: -webkit-flex; /* Chrome 33 compatibility */
    display: flex;
    -webkit-box-align: center; /* Chrome 33 compatibility */
    -webkit-align-items: center; /* Chrome 33 compatibility */
    align-items: center;
    list-style-type: none;
    margin: 0;
    padding: 0;
}

.wikicmds li {
    margin-left: 8px; /* Spacing between buttons */
}
.wikicmds li:first-child {
    margin-left: 0;
}

.wikicmds a {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    vertical-align: middle;
    -webkit-transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease; /* Chrome 33 compatibility */
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    background: transparent;
    color: #333;
    white-space: nowrap; /* Prevent text inside buttons from wrapping */
}

.wikicmds a:hover {
    border-color: #2563eb;
    color: #2563eb;
    background: rgba(37, 99, 235, 0.08);
}

/* Specific styling for edit button */
.wikicmds a[href*="action=edit"] {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}
.wikicmds a[href*="action=edit"]:hover {
    background: #1d4ed8;
    color: white;
}


/* Main Layout */
.main-layout {
    /* Adjusted to accommodate 20px left offset of sidebar + 250px sidebar width + 10px gap + 950px content width + 20px right padding of main-layout */
    max-width: 1250px; /* 20 + 250 + 10 + 950 + 20 = 1250 */
    margin-left: auto;
    margin-right: auto;
    padding: 20px;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 60px;
    bottom: 0;
    left: 20px; /* Sidebar starts 20px from the left edge as per sample HTML */
    width: 250px; /* Set sidebar width to 250px as in your sample HTML */
    background: #fff;
    padding: 20px 0;
    -webkit-box-shadow: 0 2px 10px rgba(0,0,0,0.05); /* Chrome 33 compatibility */
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border-radius: 8px;
    overflow-y: auto;
    -webkit-transition: left 0.3s ease; /* Chrome 33 compatibility */
    transition: left 0.3s ease;
    z-index: 500;
}

.sidebar-section { /* For logical grouping within PmWiki SideBar */
    margin-bottom: 30px;
}

.sidebar-title { /* For titles within PmWiki SideBar */
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
    padding-left: 20px;
    padding-right: 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar ul { /* PmWiki SideBar default ul */
    list-style: none;
    padding-left: 0;
}

.sidebar li {
    margin-bottom: 4px;
}

.sidebar a {
    display: block;
    padding: 10px 20px;
    color: #666;
    text-decoration: none;
    border-left: 3px solid transparent;
    border-radius: 4px;
    -webkit-transition: background 0.2s ease, color 0.2s ease, border-left-color 0.2s ease; /* Chrome 33 compatibility */
    transition: background 0.2s ease, color 0.2s ease, border-left-color 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar a:hover,
.sidebar a.active {
    background: rgba(37, 99, 235, 0.08);
    color: #2563eb;
    border-left-color: #2563eb;
}

.sidebar i {
    margin-right: 10px;
    width: 18px;
    text-align: center;
    font-size: 1.1rem;
    vertical-align: middle;
}

/* Content Area */
.content-area {
    margin-left: 280px; /* Adjusted: sidebar's left offset (20px) + sidebar width (250px) + desired gap (10px) = 280px */
    width: 950px; /* Explicitly set content area width as requested */
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    -webkit-box-shadow: 0 2px 10px rgba(0,0,0,0.05); /* Chrome 33 compatibility */
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    overflow: hidden;
    -webkit-transition: margin-left 0.3s ease; /* Chrome 33 compatibility */
    transition: margin-left 0.3s ease;
}

.breadcrumb {
    margin-bottom: 15px;
    font-size: 0.9rem;
    color: #666;
}

.breadcrumb a {
    color: #2563eb;
    text-decoration: none;
    -webkit-transition: text-decoration 0.2s ease; /* Chrome 33 compatibility */
    transition: text-decoration 0.2s ease;
}

.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb i { margin: 0 8px; color: #999; }

.content-header {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #eee;
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    color: #333;
    margin: 0;
}

/* Wiki Content - Adjusted for PmWiki default output */
#wikitext {
    margin-bottom: 25px;
}

#wikitext h1, #wikitext h2, #wikitext h3, #wikitext h4, #wikitext h5, #wikitext h6 {
    color: #333;
    margin-bottom: 15px;
    margin-top: 25px;
    line-height: 1.3;
}

#wikitext h1 {
    font-size: 1.8rem;
    border-bottom: 2px solid #2563eb;
    padding-bottom: 8px;
}

#wikitext h2 { font-size: 1.5rem; color: #2563eb; }
#wikitext h3 { font-size: 1.3rem; }
#wikitext p { margin-bottom: 15px; line-height: 1.7; }

#wikitext ul, #wikitext ol {
    margin-left: 25px;
    margin-bottom: 15px;
    list-style-position: outside;
}

#wikitext li { margin-bottom: 8px; }

#wikitext code {
    background: #f1f3f4;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: "Consolas", "Monaco", "Courier New", monospace;
    font-size: 0.9rem;
}

#wikitext pre {
    background: #f1f3f4;
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
    margin-bottom: 15px;
    border-left: 4px solid #2563eb;
    font-family: "Consolas", "Monaco", "Courier New", monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

#wikitext blockquote {
    border-left: 4px solid #f59e0b;
    padding-left: 15px;
    margin: 15px 0;
    font-style: italic;
    color: #666;
    background: #fffbe0;
    padding: 10px 15px;
    border-radius: 4px;
}

#wikitext a { color: #2563eb; text-decoration: none; }
#wikitext a:hover { text-decoration: underline; }
#wikitext a.createlink { color: #dd1111; }


/* Footer */
.footer {
    background: #f8f9fa;
    border-top: 1px solid #ddd;
    padding: 30px 0;
    margin-top: 40px;
}

.footer-content {
    max-width: 1200px; /* Keeping default for footer content alignment */
    margin: 0 auto;
    padding: 0 20px;
}

.footer-section {
    width: 25%;
    float: left;
    margin-bottom: 20px;
}

.footer-section h4 { margin-bottom: 12px; color: #333; }
.footer-section a { color: #666; text-decoration: none; display: block; margin-bottom: 6px; }
.footer-section a:hover { color: #2563eb; }

.footer-bottom {
    text-align: center;
    padding-top: 15px;
    border-top: 1px solid #ddd;
    color: #666;
    font-size: 0.9rem;
}

/* Sidebar Collapsed State */
body.sidebar-collapsed .sidebar {
    left: -270px; /* Sidebar width (250px) + left offset (20px) */
}

body.sidebar-collapsed .content-area {
    margin-left: 20px; /* Matches the main-layout padding */
    /* When collapsed, content area should stretch to fill available space */
    width: auto; /* Allow width to be auto when sidebar is collapsed */
}


/* Responsive Design */
@media (max-width: 768px) {
    .header-content { display: block; padding: 0 10px; height: auto; }
    .header-left, .header-center, .header-right { display: block; width: auto; text-align: left; height: auto; padding: 0; }
    .header-left { float: left; margin-top: 15px; width: auto; }
    .header-right { float: right; margin-top: 10px; width: auto; white-space: normal; }
    .header-center { display: none; }

    .mobile-menu-toggle { display: inline-block; float: left; margin-top: 18px; margin-right: 10px; }
    .desktop-sidebar-toggle { display: none; }

    .sidebar {
        position: fixed;
        left: -270px; /* Sidebar width (250px) + left offset (20px) */
        top: 60px;
        width: 250px; /* Consistent width */
        height: calc(100vh - 60px);
        z-index: 999;
        background: #f8f9fa;
        border-right: 1px solid #ddd;
        -webkit-transition: left 0.3s ease; /* Chrome 33 compatibility */
        transition: left 0.3s ease;
        margin-left: 0; /* No margin-left on mobile */
        -webkit-box-shadow: 0 2px 10px rgba(0,0,0,0.2); /* Chrome 33 compatibility */
        box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    }

    .sidebar.active {
        left: 0;
    }

    .main-layout { margin-left: 0; padding: 15px; }
    .content-area { margin-left: 0; padding: 15px; width: auto; /* Mobile content area takes full width */ }
    .page-title { font-size: 1.5rem; }
    .footer-section { float: none; width: 100%; }
}

@media (max-width: 480px) {
    .header-content {
        padding: 0 5px;
    }

    .search-input {
        width: 100px;
    }

    .content-area {
        padding: 10px;
    }

    .wiki-content { /* Renamed from #wikitext for consistency with original HTML */
        padding: 15px;
    }

    .page-title {
        font-size: 1.3rem;
    }
}
