/* VDM Content Theme - Sidebar Navigation Layout */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root,
[data-theme="dark"] {
    --bg: #0a0a0f;
    --sidebar-bg: #111118;
    --card-bg: #16161d;
    --border: #2a2a35;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --primary: #6366f1;
    --primary-light: #818cf8;
    --sidebar-width: 280px;
    --toc-width: 200px;
}

[data-theme="light"] {
    --bg: #ffffff;
    --sidebar-bg: #f8fafc;
    --card-bg: #f1f5f9;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --primary: #4f46e5;
    --primary-light: #6366f1;
}

[data-theme="solarized"] {
    --bg: #fdf6e3;
    --sidebar-bg: #eee8d5;
    --card-bg: #e8e2ce;
    --border: #d3cbb8;
    --text: #657b83;
    --text-muted: #93a1a1;
    --primary: #268bd2;
    --primary-light: #2aa198;
}

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1.5rem;
    z-index: 100;
}

.sidebar-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.logo-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.theme-switcher {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.theme-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
    padding: 0;
    outline: none;
}

.theme-dot:hover {
    transform: scale(1.2);
    border-color: var(--text-muted);
}

.theme-dot.active {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.4);
}

.theme-dot.dark {
    background: #1e1e2e;
    border: 2px solid #6366f1;
}

.theme-dot.light {
    background: #ffffff;
    border: 2px solid #6366f1;
}

.theme-dot.solarized {
    background: #fdf6e3;
    border: 2px solid #6366f1;
}

.logo-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Navigation */
.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
    padding-left: 0.75rem;
}

.nav-list {
    list-style: none;
}

.nav-item {
    margin-bottom: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    color: var(--text-muted);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.15s;
}

.nav-link:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--text);
}

.nav-link.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
}

.nav-icon {
    width: 18px;
    height: 18px;
    opacity: 0.7;
    flex-shrink: 0;
}

.nav-link:hover .nav-icon,
.nav-link.active .nav-icon {
    opacity: 1;
}

.nav-nested {
    list-style: none;
    padding-left: 2.25rem;
    margin-top: 0.25rem;
}

.nav-nested .nav-link {
    font-size: 0.85rem;
    padding: 0.4rem 0.75rem;
}

/* Main Content */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
}

/* Top Bar */
.topbar {
    position: sticky;
    top: 0;
    background: var(--sidebar-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 50;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.breadcrumb a:hover {
    color: var(--text);
}

.breadcrumb-sep {
    opacity: 0.5;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.15s;
}

.search-box:hover {
    border-color: var(--primary);
}

.search-box kbd {
    background: var(--border);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: inherit;
}

/* Content Area */
.content {
    max-width: 1500px;
    padding: 2rem 3rem 4rem;
    margin-right: calc(var(--toc-width, 200px) + 4rem);
}

@media (max-width: 1400px) {
    .content {
        margin-right: 0;
    }
}

.content-header {
    margin-bottom: 2rem;
}

.content-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.content-description {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.content-meta {
    color: var(--text-muted);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.meta-sep {
    opacity: 0.5;
}

.tag {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.tag:hover {
    background: rgba(99, 102, 241, 0.25);
}

/* Content Body */
.content-body {
    line-height: 1.8;
    font-size: 1rem;
}

.content-body p {
    margin-bottom: 1.5em;
}

.content-body h2 {
    font-size: 1.5rem;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.content-body h3 {
    font-size: 1.2rem;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.content-body h4 {
    font-size: 1.1rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.content-body ul,
.content-body ol {
    padding-left: 1.5rem;
    margin-bottom: 1.5em;
}

.content-body li {
    margin-bottom: 0.5em;
}

.content-body code {
    background: var(--card-bg);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'Fira Code', 'SF Mono', Consolas, monospace;
}

.content-body pre {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
    margin-bottom: 1.5em;
}

.content-body pre code {
    background: none;
    padding: 0;
}

.content-body blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 1rem;
    margin: 1.5em 0;
    color: var(--text-muted);
    font-style: italic;
}

.content-body a {
    color: var(--primary-light);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.content-body a:hover {
    color: var(--primary);
}

.content-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1.5em 0;
}

.content-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
}

.content-body th,
.content-body td {
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    text-align: left;
}

.content-body th {
    background: var(--card-bg);
    font-weight: 600;
}

/* Right Sidebar - TOC */
.toc {
    position: fixed;
    right: 2rem;
    top: 6rem;
    width: var(--toc-width);
    font-size: 0.85rem;
}

.toc-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
}

/* Hugo generates #TableOfContents with nav > ul structure */
.toc nav > ul {
    list-style: none;
    border-left: 1px solid var(--border);
    padding-left: 0.5rem;
}

.toc nav ul {
    list-style: none;
}

.toc nav ul ul {
    padding-left: 1rem;
    margin-top: 0.25rem;
}

.toc nav li {
    margin-bottom: 0.5rem;
}

.toc nav a {
    color: var(--text-muted);
    transition: color 0.15s;
    display: block;
    line-height: 1.4;
}

.toc nav a:hover {
    color: var(--primary-light);
}

/* Page Navigation */
.page-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.page-nav-prev,
.page-nav-next {
    flex: 1;
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: border-color 0.15s;
}

.page-nav-prev:hover,
.page-nav-next:hover {
    border-color: var(--primary);
}

.page-nav-next {
    text-align: right;
}

.page-nav-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.page-nav-title {
    font-weight: 500;
    color: var(--primary-light);
}

/* Article List */
.article-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.article-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: all 0.2s;
}

.article-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.article-link {
    display: block;
    padding: 1.5rem;
}

.article-tag {
    display: inline-block;
    background: var(--primary);
    color: white;
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.article-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.article-excerpt {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.article-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Home Page */
.home-section {
    margin-bottom: 3rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.section-title a:hover {
    color: var(--primary-light);
}

.article-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.article-list-compact {
    display: flex;
    flex-direction: column;
}

.article-item-compact {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    transition: background 0.15s;
}

.article-item-compact:hover {
    background: var(--card-bg);
}

.article-item-compact:hover .article-arrow {
    transform: translateX(4px);
}

.article-arrow {
    color: var(--text-muted);
    transition: transform 0.15s;
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 200;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    align-items: center;
    justify-content: center;
}

/* Responsive */
@media (max-width: 1400px) {
    .toc {
        display: none;
    }
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main {
        margin-left: 0;
    }

    .menu-toggle {
        display: flex;
    }

    .content {
        padding: 1.5rem;
    }
}

@media (max-width: 640px) {
    .topbar {
        padding: 1rem;
    }

    .search-box kbd {
        display: none;
    }

    .content-title {
        font-size: 1.5rem;
    }

    .article-grid {
        grid-template-columns: 1fr;
    }

    .page-nav {
        flex-direction: column;
    }
}

/* Search Modal */
.search-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    padding: 10vh 1rem;
    backdrop-filter: blur(4px);
}

.search-modal.open {
    display: block;
}

.search-modal-content {
    max-width: 560px;
    margin: 0 auto;
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.search-input-icon {
    color: var(--text-muted);
    flex-shrink: 0;
}

#search-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-size: 1rem;
    color: var(--text);
}

#search-input::placeholder {
    color: var(--text-muted);
}

.search-input-wrapper kbd {
    background: var(--card-bg);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.search-results {
    max-height: 400px;
    overflow-y: auto;
}

.search-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--card-bg);
}

.search-result-title {
    font-weight: 500;
}

.search-result-section {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

.search-no-result {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
}

/* Print Styles */
@media print {
    .sidebar,
    .topbar,
    .toc,
    .menu-toggle,
    .page-nav {
        display: none;
    }

    .main {
        margin-left: 0;
    }

    .content {
        max-width: 100%;
        padding: 0;
    }
}
