/* ============================================================
   Wiki Frontend - Modern Design
   ============================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --sidebar-width: 280px;
    --sidebar-bg: #2d3748;
    --sidebar-text: #a0aec0;
    --sidebar-active: #fff;
    --sidebar-hover-bg: #4a5568;
    --content-max-width: 800px;
    --text-color: #2d3748;
    --text-muted: #718096;
    --link-color: #4a90d9;
    --border-color: #e2e8f0;
    --bg-color: #fff;
    --code-bg: #f7fafc;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-color);
    background: var(--bg-color);
}

a {
    color: var(--link-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ============================================================
   Mobile Header
   ============================================================ */

.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: var(--sidebar-bg);
    color: #fff;
    align-items: center;
    padding: 0 16px;
    z-index: 1001;
    gap: 12px;
}

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 1px;
    transition: transform 0.2s;
}

.mobile-title {
    font-size: 15px;
    font-weight: 600;
}

/* ============================================================
   Sidebar
   ============================================================ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    overflow-y: auto;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease;
}

.sidebar-header {
    padding: 20px 20px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

.sidebar-brand {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.sidebar-brand-icon {
    width: 24px;
    height: 24px;
    margin-right: 8px;
    margin-top: -3px;
    vertical-align: middle;
}

.sidebar-brand:hover {
    text-decoration: none;
    opacity: 0.9;
}

/* Suche */
.sidebar-search {
    padding: 12px 16px;
    flex-shrink: 0;
}

.sidebar-search input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    color: #fff;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: all 0.15s;
}

.sidebar-search input::placeholder {
    color: rgba(255,255,255,0.4);
}

.sidebar-search input:focus {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.25);
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0 20px;
}

.nav-list {
    list-style: none;
}

.nav-depth-0 > li {
    margin-bottom: 2px;
}

.nav-list li a {
    display: block;
    padding: 6px 20px;
    color: var(--sidebar-text);
    font-size: 14px;
    transition: all 0.1s;
    border-left: 3px solid transparent;
}

.nav-depth-1 li a { padding-left: 36px; }
.nav-depth-2 li a { padding-left: 52px; }
.nav-depth-3 li a { padding-left: 68px; }

.nav-list li a:hover {
    color: #fff;
    background: var(--sidebar-hover-bg);
    text-decoration: none;
}

.nav-list li.active > a,
.nav-list li.active > .nav-chapter > a {
    color: var(--sidebar-active);
    border-left-color: var(--link-color);
    background: rgba(74, 144, 217, 0.15);
    font-weight: 500;
}

/* Kapitel (mit Toggle) */
.nav-chapter {
    display: flex;
    align-items: center;
}

.nav-toggle {
    background: none;
    border: none;
    color: var(--sidebar-text);
    padding: 8px 6px 8px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: transform 0.15s;
}

.nav-toggle svg {
    transition: transform 0.2s;
}

.has-children.open > .nav-chapter > .nav-toggle svg,
.has-children.open > .nav-chapter .nav-toggle svg {
    transform: rotate(90deg);
}

.nav-chapter a {
    padding-left: 4px !important;
    flex: 1;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #cbd5e0 !important;
}

/* Kinder ausblenden wenn nicht offen */
.has-children > .nav-list {
    display: none;
}

.has-children.open > .nav-list {
    display: block;
}

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

/* ============================================================
   Content
   ============================================================ */

.content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.content-inner {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 40px 48px 80px;
}

/* ============================================================
   Breadcrumb
   ============================================================ */

.breadcrumb {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.breadcrumb a {
    color: var(--text-muted);
}

.breadcrumb a:hover {
    color: var(--link-color);
}

.breadcrumb-sep {
    margin: 0 6px;
    color: #cbd5e0;
}

.breadcrumb-current {
    color: var(--text-color);
}

/* ============================================================
   Page Content (Typografie)
   ============================================================ */

.page-title {
    font-size: 2em;
    font-weight: 700;
    margin-bottom: 24px;
    line-height: 1.3;
    color: var(--text-color);
    letter-spacing: -0.5px;
}

.page-content {
    line-height: 1.8;
}

.page-content h2 {
    font-size: 1.5em;
    margin: 2em 0 0.5em;
    padding-bottom: 0.3em;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

.page-content h3 {
    font-size: 1.25em;
    margin: 1.5em 0 0.5em;
    color: var(--text-color);
}

.page-content h4 {
    font-size: 1.1em;
    margin: 1.2em 0 0.4em;
    color: var(--text-color);
}

.page-content p {
    margin-bottom: 1em;
}

.page-content ul,
.page-content ol {
    margin: 0.5em 0 1em 1.5em;
}

.page-content li {
    margin-bottom: 0.3em;
}

.page-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 1em 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.page-content a {
    color: var(--link-color);
    border-bottom: 1px solid transparent;
}

.page-content a:hover {
    border-bottom-color: var(--link-color);
    text-decoration: none;
}

/* Code */
.page-content code {
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.88em;
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 3px;
    color: #e53e3e;
}

.page-content pre {
    background: var(--code-bg);
    padding: 16px 20px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1em 0;
    border: 1px solid var(--border-color);
}

.page-content pre code {
    background: none;
    padding: 0;
    color: var(--text-color);
    font-size: 0.85em;
    line-height: 1.6;
}

/* Tabellen */
.page-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
}

.page-content th,
.page-content td {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.page-content th {
    background: var(--code-bg);
    font-weight: 600;
    font-size: 0.9em;
}

.page-content tr:hover {
    background: #fafbfc;
}

/* Trennlinie */
.page-content hr {
    border: none;
    border-top: 2px solid var(--border-color);
    margin: 2em 0;
}

/* Blockquote */
.page-content blockquote {
    border-left: 4px solid var(--link-color);
    padding: 8px 16px;
    margin: 1em 0;
    background: #ebf4ff;
    color: #2a4365;
    border-radius: 0 4px 4px 0;
}

/* ============================================================
   Child Pages (Kapitel-Übersicht)
   ============================================================ */

.child-pages {
    margin-top: 2em;
    padding-top: 1.5em;
    border-top: 1px solid var(--border-color);
}

.child-pages h2 {
    font-size: 1.2em;
    margin-bottom: 0.5em;
}

.child-pages ul {
    list-style: none;
    padding: 0;
}

.child-pages li {
    margin-bottom: 4px;
}

.child-pages li a {
    display: block;
    padding: 8px 12px;
    border-radius: 4px;
    transition: background 0.1s;
}

.child-pages li a:hover {
    background: var(--code-bg);
    text-decoration: none;
}

/* ============================================================
   Page Navigation (Vor/Zurück)
   ============================================================ */

.page-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 3em;
    padding-top: 1.5em;
    border-top: 1px solid var(--border-color);
    gap: 16px;
}

.page-nav-link {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    max-width: 48%;
    transition: all 0.15s;
}

.page-nav-link:hover {
    border-color: var(--link-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    text-decoration: none;
}

.page-nav-prev {
    align-items: flex-start;
}

.page-nav-next {
    align-items: flex-end;
    margin-left: auto;
}

.page-nav-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.page-nav-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--link-color);
}

/* ============================================================
   Home Page
   ============================================================ */

.home-page h1 {
    font-size: 2.2em;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.home-description {
    font-size: 1.1em;
    color: var(--text-muted);
    margin-bottom: 2em;
}

.home-chapters h2 {
    font-size: 1.3em;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.chapter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.chapter-card {
    display: block;
    padding: 16px 20px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: all 0.15s;
    color: var(--text-color);
}

.chapter-card:hover {
    border-color: var(--link-color);
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    text-decoration: none;
}

.chapter-card h3 {
    font-size: 1em;
    margin-bottom: 4px;
    color: var(--text-color);
}

.chapter-count {
    font-size: 12px;
    color: var(--text-muted);
}

.home-empty {
    color: var(--text-muted);
    font-size: 1.1em;
}

/* ============================================================
   Search
   ============================================================ */

.search-info {
    color: var(--text-muted);
    margin-bottom: 20px;
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-result {
    display: block;
    padding: 14px 18px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    transition: all 0.15s;
    color: var(--text-color);
}

.search-result:hover {
    border-color: var(--link-color);
    text-decoration: none;
}

.search-result h3 {
    font-size: 1em;
    margin-bottom: 4px;
    color: var(--link-color);
}

.search-result p {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

/* ============================================================
   404
   ============================================================ */

.not-found {
    text-align: center;
    padding: 60px 20px;
}

.not-found h1 {
    font-size: 2em;
    margin-bottom: 8px;
}

.not-found p {
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* ============================================================
   Theme Switcher (Frontend)
   ============================================================ */

.theme-switcher {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    gap: 4px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 4px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.theme-switcher button {
    padding: 6px 14px;
    border: none;
    border-radius: 7px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    background: transparent;
    color: #71717a;
    transition: all 0.15s;
}

.theme-switcher button:hover {
    background: #f4f4f5;
}

.theme-switcher button.active {
    background: var(--link-color, #4a90d9);
    color: #fff;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }

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

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

    .content {
        margin-left: 0;
        padding-top: 50px;
    }

    .content-inner {
        padding: 24px 20px 60px;
    }

    .page-title {
        font-size: 1.6em;
    }

    .page-nav {
        flex-direction: column;
    }

    .page-nav-link {
        max-width: 100%;
    }

    .chapter-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .content-inner {
        padding: 16px 14px 40px;
    }
}
