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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    /* line-height: 1.5; */
    color: #333;
    background-color: #f9f9f9;
    /* font-size: 14px; */
}

a {
    text-decoration: none;
    color: inherit;
}

/* 导航栏样式 */
.navbar {
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c3e50;
}

.nav-menu {
    display: flex;
    list-style: none;
    align-items: center; /* 确保菜单项在导航高度内垂直居中 */
}

/* 使链接与下拉切换在行内垂直居中并有相同内边距 */
.nav-menu .nav-item {
    display: flex; /* 使每一项内容（包括 dropdown-toggle）垂直居中 */
    align-items: center;
}

.nav-menu a,
.nav-menu .dropdown-toggle {
    display: inline-flex;
    align-items: center;
    padding: 6px 8px;
    line-height: 1; /* 明确行高，避免不同元素基线差异 */
}

.nav-item {
    margin-left: 30px;
}

.nav-link {
    font-weight: 500;
    transition: color 0.3s;
}

.nav-link:hover {
    color: #3498db;
}

.hamburger {
    display: none;
    cursor: pointer;
    font-size: 1.5rem;
}

/* 主要内容区域 */
.container {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
    display: flex; /* 使用 flex 布局 */
    align-items: flex-start;
    justify-content: space-between;
    gap: 40px;
}

/* 文章样式 */
.article {
    background-color: #fff;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    max-width: 820px;
}

.article-title {
    font-size: 2rem;
    margin-bottom: 15px;
    color: #2c3e50;
}

.article-meta {
    color: #7f8c8d;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.article-content {
    /* font-size: 1rem; */
    line-height: 1.8;
}

.article-content p {
    /* margin-bottom: 20px; */
    margin: 10px 0px;
}

.article-content h2 {
    margin: 30px 0 15px;
    color: #2c3e50;
}

.article-content blockquote {
    border-left: 4px solid #3498db;
    padding-left: 20px;
    margin: 20px 0;
    font-style: italic;
    color: #555;
}

/* 侧边栏样式 */
.sidebar {
    background-color: #fff;
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    height: fit-content;
}

/* 使用 flex 布局时的具体列行为 */
.article {
    flex: 1 1 auto; /* 占据剩余空间，允许缩放 */
    min-width: 0; /* 解决子元素溢出的问题 */
}

.sidebar {
    flex: 0 0 300px; /* 固定侧栏宽度为 300px */
}

.sidebar-title {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: #2c3e50;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.sidebar-widget {
    margin-bottom: 30px;
}

.categories-list, .recent-posts {
    list-style: none;
}

.categories-list li, .recent-posts li {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.categories-list a:hover, .recent-posts a:hover {
    color: #3498db;
}

/* 页脚样式 */
.footer {
    background-color: #2c3e50;
    color: #fff;
    text-align: center;
    padding: 30px 0;
    margin-top: 50px;
}

pre {
  background: #f1f1f1;
  padding: 10px;
  border-radius: 5px;
  max-width: 100%;
  overflow-x: auto;
  margin: 10px 0px;
}

code {
    font-family: 'Hack', 'DejaVu Sans Mono', 'Monospace';
}

pre code {
    font-size: 0.9rem;
}

.article-content :not(pre, div) > code {
    font-family: 'Hack', 'DejaVu Sans Mono', 'Monospace';
    font-size: 0.9rem;
    background-color: #f1f1f1;
    padding: 0 5px;
    margin: 0 3px;
    border-radius: 3px;
}

.article-content ul, .article-content ol {
    list-style-type: disc;
    padding-left: 10px;
}

.article-content li {
    margin-bottom: 8px;
    margin-left: 20px;
}

/* 更严格的移动端优化 */
@media screen and (max-width: 768px) {
  pre {
    font-size: 14px; /* 固定字体大小 */
    line-height: 1.4;
    overflow-x: scroll; /* 强制显示滚动条而不是auto */
    -webkit-overflow-scrolling: touch;
  }

  pre code {
    font-size: inherit;
    white-space: inherit;
  }
}

/* 响应式设计 */
@media screen and (max-width: 768px) {
    .nav-menu {
        position: fixed;
        left: -100%;
        top: 70px;
        flex-direction: column;
        background-color: #fff;
        width: 100%;
        text-align: center;
        transition: 0.3s;
        box-shadow: 0 10px 10px rgba(0,0,0,0.1);
        padding: 20px 0;
    }
    
    .nav-menu.active {
        left: 0;
    }
    
    .nav-item {
        margin: 15px 0;
    }
    
    .hamburger {
        display: block;
    }
    
    .container {
        display: flex;
        flex-direction: column; /* 移动端单列 */
        gap: 20px;
        align-items: stretch;
    }

    .article {
        padding: 15px;
    }
    
    .article-title {
        font-size: 1.7rem;
    }

    pre {
        padding: 12px;
        font-size: 13px;
        margin: 15px -10px; /* 在小屏幕上稍微溢出容器 */
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    /* 确保代码块在移动设备上完全可滚动 */
    pre::-webkit-scrollbar {
        height: 8px;
    }
    
    pre::-webkit-scrollbar-thumb {
        background: #ccc;
        border-radius: 4px;
    }

    .container {
        padding: 0px 10px;
    }
    /* 在小屏幕上让侧边栏占满宽度并位于文章下方 */
    .sidebar {
        flex: 0 0 auto;
        width: 100%;
    }
    .article-item {
        flex-direction: column;
    }
}

.article-item {
    list-style: none;
    padding: 10px 0px;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
}

/* 悬停效果 */
.article-item:hover {
    background: #fafafa;
}

/* 评论区域新样式 */
.article-comments {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid #eee; /* 用细线分隔文章和评论 */
}

/* 评论表单优化 */
.comment-form {
    margin-top: 1.5rem;
}
.comment-form textarea {
    width: 100%;
    min-height: 120px;
}

/* 评论区域样式 */
.comments {
    margin-top: 2rem;
}

.comment {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
}

.comment-author {
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.comment-text {
    color: #666;
}

.comment-form textarea {
    width: 100%;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-height: 100px;
}

.comment-form button {
    background: #333;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.3s;
}

.comment-form button:hover {
    background: #555;
}

/* img {
    display: block;
    margin: 0 auto;
    box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.3); 
} */
/* 图片响应式处理 */
img {
    max-width: 100%; /* 关键：图片最大宽度不超过容器 */
    height: auto; /* 保持宽高比 */
    display: block; /* 避免底部间隙 */
}

/* 特殊情况处理 */
.article-content img {
    border-radius: 6px; /* 可选：添加圆角 */
    /* box-shadow: 0 2px 8px rgba(0,0,0,0.1);  */
    box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.3); 
    margin: 30px auto; /* 添加上下边距 */
}

quote {
    display: block;
    margin: 1.5em 0;
    padding: 1em 1.5em;
    background-color: #f8f9fa;
    border-left: 4px solid #4a6ea9;
    color: #333;
    font-style: italic;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    border-radius: 0 3px 3px 0;
}

quote::before {
    content: '"';
    font-size: 3em;
    color: #4a6ea9;
    opacity: 0.2;
    position: absolute;
    top: 10px;
    left: 10px;
    font-family: serif;
}

quote::after {
    content: '';
    display: table;
    clear: both;
}


/* 表单组样式 */
.form-group {
    margin-bottom: 25px;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #2c3e50;
    font-size: 0.95rem;
}

/* 输入框基础样式 */
input, textarea, select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
    background-color: #fff;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    background-color: #f8fafc;
}

/* 输入框占位符样式 */
input::placeholder, textarea::placeholder {
    color: #a0aec0;
    font-size: 0.95rem;
}

/* 文本区域特殊样式 */
textarea {
    resize: vertical;
    min-height: 200px;
    line-height: 1.6;
}

/* 选择框样式 */
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 12px;
    padding-right: 40px;
    cursor: pointer;
}

/* 复选框组样式 */
.checkbox-group {
    display: flex;
    gap: 30px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-item input[type="checkbox"] {
    width: auto;
    margin: 0;
    transform: scale(1.2);
}

.checkbox-item label {
    margin: 0;
    font-weight: normal;
    cursor: pointer;
    color: #4a5568;
}

/* 提交按钮样式 */
button[type="submit"] {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

button[type="submit"]:hover {
    background: linear-gradient(135deg, #2980b9, #2471a3);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

button[type="submit"]:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(52, 152, 219, 0.3);
}

/* 表单验证状态 */
input:invalid, textarea:invalid {
    border-color: #e74c3c;
}

input:valid, textarea:valid {
    border-color: #27ae60;
}

/* 响应式设计 */
@media screen and (max-width: 768px) {
    .checkbox-group {
        flex-direction: column;
        gap: 15px;
    }
    
    input, textarea, select {
        padding: 14px 16px;
        font-size: 16px; /* 防止iOS缩放 */
    }
    
    button[type="submit"] {
        padding: 16px 20px;
    }
}

/* 加载状态 */
button[type="submit"]:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 表单动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-group {
    animation: fadeIn 0.5s ease-out;
    animation-fill-mode: both;
}

.form-group:nth-child(1) { animation-delay: 0.1s; }
.form-group:nth-child(2) { animation-delay: 0.2s; }
.form-group:nth-child(3) { animation-delay: 0.3s; }
.form-group:nth-child(4) { animation-delay: 0.4s; }
.checkbox-group { animation-delay: 0.5s; }
button[type="submit"] { animation-delay: 0.6s; }

/* 表格轻度美化样式 */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 25px 0;
    font-size: 0.95rem;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    background-color: #fff;
}

table th,
table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #e1e8ed;
}

table th {
    background-color: #f8fafc;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
}

table tr:last-child td {
    border-bottom: none;
}

/* 斑马纹效果 */
/* table tr:nth-child(even) {
    background-color: #f9f9f9;
} */

/* 悬停效果 */
table tr:hover {
    background-color: #f0f7ff;
    transition: background-color 0.2s ease;
}

/* 表格标题样式 */
table caption {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 15px;
    text-align: left;
}

/* 响应式表格 */
@media screen and (max-width: 768px) {
    table {
        font-size: 0.9rem;
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    table th,
    table td {
        padding: 10px 12px;
    }
}
