/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    padding-bottom: 60px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* 顶部导航栏 */
.top-nav {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-nav .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.back-btn {
    color: #1890ff;
    text-decoration: none;
    font-size: 16px;
    display: flex;
    align-items: center;
    min-width: 60px;
}

.back-btn:hover {
    color: #40a9ff;
}

.page-title {
    font-size: 18px;
    font-weight: 500;
    color: #333;
    flex: 1;
    text-align: center;
}

.logo {
    font-size: 20px;
    font-weight: bold;
    color: #1890ff;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info span {
    color: #666;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.btn-primary {
    background: #1890ff;
    color: #fff;
}

.btn-primary:hover {
    background: #40a9ff;
}

.btn-secondary {
    background: #fff;
    color: #333;
    border: 1px solid #d9d9d9;
}

.btn-secondary:hover {
    color: #1890ff;
    border-color: #1890ff;
}

.btn-danger {
    background: #ff4d4f;
    color: #fff;
}

.btn-danger:hover {
    background: #ff7875;
}

/* 搜索框 */
.search-box {
    background: #fff;
    padding: 20px;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.search-input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 14px;
}

.search-input:focus {
    outline: none;
    border-color: #1890ff;
    box-shadow: 0 0 0 2px rgba(24,144,255,0.2);
}

/* 分类列表 */
.category-list {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
}

.category-item {
    border-bottom: 1px solid #f0f0f0;
}

.category-item:last-child {
    border-bottom: none;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    cursor: pointer;
    transition: background 0.3s;
}

.category-header:hover {
    background: #fafafa;
}

.category-name {
    font-size: 16px;
    font-weight: 500;
    color: #333;
}

.category-count {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #999;
}

.category-count .count {
    background: #e6f7ff;
    color: #1890ff;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
}

.category-arrow {
    transition: transform 0.3s;
}

.category-arrow.active {
    transform: rotate(180deg);
}

.question-list {
    display: none;
    background: #fafafa;
    padding: 10px 20px;
}

.question-list.active {
    display: block;
}

.question-item {
    padding: 12px 15px;
    background: #fff;
    margin-bottom: 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    border-left: 3px solid transparent;
}

.question-item:hover {
    border-left-color: #1890ff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.question-title {
    font-size: 14px;
    color: #333;
    margin-bottom: 8px;
    line-height: 1.5;
}

.question-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: #999;
}

.category-tag {
    background: #e6f7ff;
    color: #1890ff;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
}

/* 题目详情 */
.question-detail {
    background: #fff;
    padding: 30px;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.question-title {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.question-content {
    font-size: 16px;
    line-height: 1.8;
    color: #666;
    margin-bottom: 30px;
    white-space: pre-wrap;
}

.answer-section {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 4px;
    border-left: 4px solid #52c41a;
}

.answer-title {
    font-size: 18px;
    font-weight: bold;
    color: #52c41a;
    margin-bottom: 15px;
}

.answer-content {
    font-size: 15px;
    line-height: 1.8;
    color: #666;
    white-space: pre-wrap;
}

.question-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #f0f0f0;
}

.nav-buttons {
    display: flex;
    gap: 10px;
}

/* 动画 */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* 底部导航 */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    z-index: 100;
}

.bottom-nav-list {
    display: flex;
    justify-content: space-around;
    list-style: none;
}

.bottom-nav-item {
    flex: 1;
    text-align: center;
}

.bottom-nav-link {
    display: block;
    padding: 6px;
    color: #666;
    text-decoration: none;
    transition: color 0.3s;
}

.bottom-nav-link.active {
    color: #1890ff;
}

.bottom-nav-icon {
    font-size: 18px;
    margin-bottom: 2px;
}

.bottom-nav-text {
    font-size: 10px;
}

/* 我的页面 */
.profile-card {
    background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
    color: #fff;
    padding: 30px;
    border-radius: 8px;
    margin: 20px 0;
}

.profile-username {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 10px;
}

.profile-info {
    font-size: 14px;
    opacity: 0.9;
}

.menu-list {
    background: #fff;
    border-radius: 8px;
    margin: 20px 0;
    overflow: hidden;
}

.menu-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.3s;
    text-decoration: none;
    color: #333;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item:hover {
    background: #fafafa;
}

.menu-item-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.menu-item-icon {
    font-size: 20px;
    color: #1890ff;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: 8px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 20px;
}

.modal-body {
    margin-bottom: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 14px;
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: #1890ff;
    box-shadow: 0 0 0 2px rgba(24,144,255,0.2);
}

/* 登录/注册页面 */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-box {
    background: #fff;
    border-radius: 8px;
    padding: 40px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.auth-title {
    font-size: 28px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 30px;
    color: #333;
}

.auth-form .form-group {
    margin-bottom: 20px;
}

.auth-form .btn {
    width: 100%;
    padding: 12px;
    font-size: 16px;
}

.auth-links {
    text-align: center;
    margin-top: 20px;
}

.auth-links a {
    color: #1890ff;
    text-decoration: none;
}

.auth-links a:hover {
    text-decoration: underline;
}

/* 管理后台样式 */
.admin-container {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 250px;
    background: #001529;
    color: #fff;
    padding: 20px 0;
}

.admin-logo {
    padding: 0 20px 20px;
    font-size: 20px;
    font-weight: bold;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 20px;
}

.admin-menu {
    list-style: none;
}

.admin-menu-item {
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.3s;
}

.admin-menu-item:hover,
.admin-menu-item.active {
    background: #1890ff;
}

.admin-main {
    flex: 1;
    padding: 20px;
    background: #f0f2f5;
}

.admin-header {
    background: #fff;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-content {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

.table th {
    background: #fafafa;
    font-weight: 500;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

/* 响应式 */
@media (max-width: 768px) {
    .admin-container {
        flex-direction: column;
    }
    
    .admin-sidebar {
        width: 100%;
    }
    
    .question-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .nav-buttons {
        width: 100%;
        justify-content: space-between;
    }
}

/* ==================== Markdown 样式优化 ==================== */

/* Markdown 内容区域 */
.markdown-body {
    box-sizing: border-box;
    min-width: 200px;
    max-width: 980px;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    word-wrap: break-word;
}

/* 重置 white-space */
.markdown-body .question-content,
.markdown-body .answer-content {
    white-space: normal;
}

/* 标题样式 */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
}

.markdown-body h1 {
    font-size: 2em;
    border-bottom: 1px solid #e1e4e8;
    padding-bottom: 0.3em;
}

.markdown-body h2 {
    font-size: 1.5em;
    border-bottom: 1px solid #e1e4e8;
    padding-bottom: 0.3em;
}

.markdown-body h3 {
    font-size: 1.25em;
}

.markdown-body h4 {
    font-size: 1em;
}

.markdown-body h5 {
    font-size: 0.875em;
}

.markdown-body h6 {
    font-size: 0.85em;
    color: #6a737d;
}

/* 段落样式 */
.markdown-body p {
    margin-top: 0;
    margin-bottom: 16px;
}

/* 列表样式 */
.markdown-body ul,
.markdown-body ol {
    margin-top: 0;
    margin-bottom: 16px;
    padding-left: 2em;
}

.markdown-body ul ul,
.markdown-body ul ol,
.markdown-body ol ol,
.markdown-body ol ul {
    margin-top: 0;
    margin-bottom: 0;
}

.markdown-body li {
    word-wrap: break-all;
}

.markdown-body li + li {
    margin-top: 0.25em;
}

/* 代码样式 */
.markdown-body code {
    padding: 0.2em 0.4em;
    margin: 0;
    font-size: 85%;
    background-color: rgba(27, 31, 35, 0.05);
    border-radius: 3px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.markdown-body pre {
    padding: 16px;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    background-color: #f6f8fa;
    border-radius: 6px;
    margin-bottom: 16px;
}

.markdown-body pre code {
    display: inline;
    max-width: auto;
    padding: 0;
    margin: 0;
    overflow: visible;
    line-height: inherit;
    word-wrap: normal;
    background-color: transparent;
    border: 0;
}

/* 引用样式 */
.markdown-body blockquote {
    padding: 0 1em;
    color: #6a737d;
    border-left: 0.25em solid #dfe2e5;
    margin-bottom: 16px;
}

.markdown-body blockquote > :first-child {
    margin-top: 0;
}

.markdown-body blockquote > :last-child {
    margin-bottom: 0;
}

/* 表格样式 */
.markdown-body table {
    border-spacing: 0;
    border-collapse: collapse;
    margin-bottom: 16px;
    width: 100%;
    overflow: auto;
}

.markdown-body table th,
.markdown-body table td {
    padding: 6px 13px;
    border: 1px solid #dfe2e5;
}

.markdown-body table th {
    font-weight: 600;
    background-color: #f6f8fa;
}

.markdown-body table tr {
    background-color: #fff;
    border-top: 1px solid #c6cbd1;
}

.markdown-body table tr:nth-child(2n) {
    background-color: #f6f8fa;
}

/* 链接样式 */
.markdown-body a {
    color: #0366d6;
    text-decoration: none;
}

.markdown-body a:hover {
    text-decoration: underline;
}

/* 图片样式 */
.markdown-body img {
    max-width: 100%;
    box-sizing: content-box;
    background-color: #fff;
    border-radius: 4px;
}

/* 水平线 */
.markdown-body hr {
    height: 0.25em;
    padding: 0;
    margin: 24px 0;
    background-color: #e1e4e8;
    border: 0;
}

/* 强调样式 */
.markdown-body strong {
    font-weight: 600;
}

/* 斜体样式 */
.markdown-body em {
    font-style: italic;
}

/* 删除线 */
.markdown-body del {
    text-decoration: line-through;
}

/* EasyMDE 编辑器样式优化 */
.EasyMDEContainer {
    margin-bottom: 0;
}

.EasyMDEContainer .CodeMirror {
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 14px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.EasyMDEContainer .CodeMirror:focus-within {
    border-color: #1890ff;
    box-shadow: 0 0 0 2px rgba(24,144,255,0.2);
}

.EasyMDEContainer .editor-toolbar {
    border: 1px solid #d9d9d9;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    background-color: #fafafa;
}

.EasyMDEContainer .CodeMirror {
    border-radius: 0 0 4px 4px;
}

/* 模态框中的 Markdown 编辑器 */
.modal-content .EasyMDEContainer {
    margin-bottom: 0;
}

.modal-content .CodeMirror {
    max-height: 300px;
}

/* 题目详情页 Markdown 内容样式 */
.question-detail .markdown-body {
    font-size: 16px;
    line-height: 1.8;
}

.question-section {
    margin-bottom: 30px;
}

.question-section h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #333;
}

/* 答案区域 Markdown 样式 */
.answer-section .markdown-body {
    background: transparent;
    font-size: 15px;
}
