/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #202122;
}

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: #fff;
    border-bottom: 1px solid #a2a9b1;
    display: flex;
    align-items: center;
    padding: 0;
    z-index: 100;
    justify-content: space-between; /* 添加这行来使标题和链接分开 */
}

.header-title {
    font-size: 1.5em;
    font-weight: 500;
    margin-left: 20px;
}

.header-links {
    display: flex;
    gap: 20px; /* 链接之间的间距 */
    align-items: center;
    margin-right: 20px;
}

.header-link {
    color: #3366cc;
    text-decoration: none;
    font-size: 14px;
}

.header-link:hover {
    text-decoration: underline;
}

.container {
    display: flex;
    margin-top: 50px;
    min-height: calc(100vh - 50px);
}

.sidebar {
    width: 260px;
    background: #f8f9fa;
    border-right: 1px solid #a2a9b1;
    padding: 20px;
    position: fixed;
    top: 50px;
    bottom: 0;
    overflow-y: auto;
    /* 添加平滑滚动效果 */
    scroll-behavior: smooth;
}

/* 默认隐藏滚动条 */
.sidebar::-webkit-scrollbar {
    width: 8px;
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: transparent;
    border-radius: 4px;
    transition: background-color 0.3s;
}

/* 鼠标悬停或滚动时显示滚动条 */
.sidebar:hover::-webkit-scrollbar-thumb,
.sidebar:active::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
}

/* 鼠标悬停在滚动条上时的样式 */
.sidebar::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.4);
}

.nav-section {
    margin: 8px 0;
}

.nav-section-title {
    display: flex;
    align-items: center;
    cursor: pointer;
    color: #202122;
    padding: 6px 0;
    font-weight: 500;
}

.nav-section-title:hover {
    background-color: #f0f0f0;
    border-radius: 3px;
}

.nav-toggle {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    position: relative;
}

.nav-toggle::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 6px;
    height: 6px;
    border-right: 2px solid #72777d;
    border-bottom: 2px solid #72777d;
    transform: translate(-75%, -50%) rotate(45deg);
    transition: transform 0.2s;
}

.nav-section.collapsed .nav-toggle::before {
    transform: translate(-75%, -75%) rotate(-45deg);
}

.nav-section.collapsed .nav-items {
    display: none;
}

.nav-items {
    margin-left: 24px;
}

.nav-link {
    color: #3366cc;
    text-decoration: none;
    display: block;
    padding: 4px 0;
    font-size: 14px;
}

.nav-link:hover {
    text-decoration: underline;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 40px;
    max-width: 1000px;
}

/* Markdown 内容样式 */
.markdown-body h1 {
    font-size: 1.8em;
    margin-bottom: 0.8em;
    padding-bottom: 0.3em;
    border-bottom: 1px solid #a2a9b1;
    color: #000;
    font-family: 'Linux Libertine','Georgia','Times',serif;
}

.markdown-body h2 {
    font-size: 1.5em;
    margin: 1em 0;
    padding-bottom: 0.2em;
    border-bottom: 1px solid #c8ccd1;
    color: #162441;
    font-family: 'Linux Libertine','Georgia','Times',serif;
}

/* 标题锚点链接样式 */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    position: relative;
    scroll-margin-top: 70px; /* 70px = 50px头部高度 + 20px额外间距 */
}

.markdown-body .header-link {
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.2s;
    text-decoration: none;
    color: #666;
    font-weight: normal;
}

.markdown-body h1:hover .header-link,
.markdown-body h2:hover .header-link,
.markdown-body h3:hover .header-link,
.markdown-body h4:hover .header-link,
.markdown-body h5:hover .header-link,
.markdown-body h6:hover .header-link {
    opacity: 1;
}

.markdown-body .header-link:hover {
    color: #3366cc;
    text-decoration: none;
}

.markdown-body p {
    margin: 1em 0;
    line-height: 1.6;
}

.markdown-body code {
    padding: 0.2em 0.4em;
    background-color: #f6f8fa;
    border-radius: 3px;
    font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
}

.markdown-body pre {
    margin: 1em 0;
    padding: 16px;
    overflow: auto;
    background-color: #f6f8fa;
    border-radius: 3px;
    font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
}

.markdown-body pre code {
    padding: 0;
    background-color: transparent;
}

/* Unordered lists style */
.markdown-section ul, .html-section ul {
    padding-left: 40px; /* Consistent with main content padding */
    margin: 1em 0;      /* Same margin as paragraphs */
}

/* Ordered lists style */
.markdown-section ol, .html-section ol {
    padding-left: 40px; /* Consistent with main content padding */
    margin: 1em 0;      /* Same margin as paragraphs */
}

/* 右侧边栏样式 */
.right-sidebar {
    width: 260px;
    background: #f8f9fa;
    border-left: 1px solid #a2a9b1;
    padding: 20px;
    position: fixed;
    top: 50px;
    right: -260px; /* Start hidden */
    bottom: 0;
    overflow-y: auto;
    transition: right 0.6s ease;
    z-index: 99;
}

.right-sidebar.active {
    right: 0;
}

/* 切换按钮样式 */
.sidebar-toggle {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    font-size: 16px;
    padding: 5px;
    z-index: 100;
}

.sidebar-toggle:hover {
    color: #333;
}

.sidebar-toggle svg {
    width: 16px;
    height: 16px;
}

/* 内容区域调整 */
.main-content.shifted {
    margin-right: 260px;
}

/* Add right sidebar trigger */
.right-sidebar-trigger {
    position: fixed;
    top: 50px;
    right: 0;
    width: 30px;
    height: calc(100vh - 50px);
    z-index: 98;
}

/* Show sidebar on hover */
.right-sidebar-trigger:hover + .right-sidebar:not(:empty),
.right-sidebar:not(:empty):hover,
.right-sidebar.active:not(:empty),
.right-sidebar.locked:not(:empty) {
    right: 0;
}

/* Adjust main content when sidebar is locked */
.right-sidebar.locked ~ .main-content {
    margin-right: 260px;
}

/* Lock button styles */
.right-lock-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    font-size: 16px;
    padding: 5px;
    z-index: 100;
}

.right-lock-button:hover {
    color: #333;
}

/* 表格样式 */
.markdown-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
}

/* Add margin to unordered lists similar to paragraphs */
.markdown-body ul {
    margin: 1em 0;  /* Same margin as paragraphs */
    padding-left: 40px;
}

/* Ordered lists style */
.markdown-body ol {
    padding-left: 0; /* Remove default padding */
    margin: 1em 0 1em 16px; /* Keep vertical margins, add left margin to match paragraph indentation */
    list-style-position: outside; /* Keep numbers outside of content flow */
}

.markdown-body th,
.markdown-body td {
    border: 1px solid #d0d7de;
    padding: 8px 12px;
}

.markdown-body th {
    background-color: #f6f8fa;
    font-weight: 600;
}

.markdown-body tr:nth-child(even) {
    background-color: #f8f9fa;
}

.markdown-body tr:hover {
    background-color: #f1f2f3;
}

/* head的可折叠功能 */
.header-dropdown {
    position: relative;
    display: inline-block;
}

.header-dropdown-content {
    display: none;
    position: absolute;
    background-color: #fff;
    min-width: 80px;  /* 增加最小宽度 */
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    z-index: 1000;
    border: 1px solid #a2a9b1;
    border-radius: 3px;
    top: 100%;
    /* 修改定位方式，使下拉框居中 */
    left: 50%;
    transform: translateX(-50%);
}

.header-dropdown:hover .header-dropdown-content {
    display: block;
}

.header-dropdown-btn {
    color: #3366cc;
    text-decoration: none;
    font-size: 14px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
    display: inline;  /* 确保按钮和链接表现一致 */
    /* 添加文本居中对齐 */
    text-align: center;
    width: 100%;
}

.header-dropdown-content a {
    color: #3366cc;
    text-decoration: none;
    padding: 4px 8px;
    display: block;
    font-size: 14px;
    white-space: nowrap;
    /* 添加文本居中对齐 */
    text-align: center;
}

.header-dropdown-content a:hover {
    background-color: #f8f9fa;
    text-decoration: underline;
}

/* Documentation version selector */
.version-switcher {
    margin-left: 8px;
}

.version-switcher::after {
    content: "";
    position: absolute;
    top: 100%;
    right: 0;
    width: 100px;
    height: 5px;
    z-index: 999;
}

.version-button {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: 6px;
    min-width: 100px;
    height: 22px;
    padding: 0 6px;
    color: #202122;
    background: #fff;
    border: 1px solid #a2a9b1;
    border-radius: 5px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    font-family: inherit;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.version-label {
    color: #54595d;
    font-weight: 400;
    text-align: left;
}

.version-caret {
    color: #72777d;
    font-size: 11px;
}

.version-button:hover,
.version-switcher:hover .version-button {
    background: #f8f9fa;
    border-color: #72777d;
}

.version-menu {
    right: 0;
    left: auto;
    width: 100px;
    min-width: 100px;
    margin-top: 4px;
    padding: 5px 0;
    overflow: hidden;
    border-radius: 5px;
    transform: none;
}

.version-menu a.version-option {
    display: block;
    padding: 6px 10px;
    color: #202122;
    text-align: left;
}

.version-menu .version-option strong {
    display: inline-block;
    min-width: 24px;
}

.version-menu .version-option span {
    color: #72777d;
    font-size: 12px;
}

.version-menu .version-option.active {
    background: #f1f4f8;
    box-shadow: inset 3px 0 #3366cc;
}

.version-menu .version-option:hover {
    background: #eaecf0;
    text-decoration: none;
}

.footnote {
    color: #3366cc;
    position: relative;
    cursor: help;
}

.footnote:hover::after {
    content: attr(data-note);
    position: absolute;
    bottom: 100%;
    left: 0;
    background: #333;
    color: white;
    padding: 8px 10px;
    border-radius: 4px;
    white-space: normal;
    max-width: 300px;
    min-width: 200px;
    font-size: 0.9em;
    line-height: 1.4;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    z-index: 1000;
    word-wrap: break-word;
}

/* 当脚注靠近右边缘时，让提示框向左显示 */
.footnote:hover::after {
    left: 50%;
    transform: translateX(-50%);
}

/* 添加小三角形指向脚注 */
.footnote:hover::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #333;
    z-index: 1001;
}

/* Footer styles */
footer {
    font-size: small;
    border-top: 1px solid #c0c0c0;
    padding-top: 0.1em;
    margin-top: 0.1em;
    color: #c0c0c0;
    margin-left: 230px; /* 与侧边栏宽度相同 */
}

footer a {
    color: #80a0b0;
}

.footer-text {
    padding-left: 40px; /* 与 main-content 的 padding 相同 */
    padding-bottom: -10px;
}