/* ========== CSS变量定义 ========== */
:root {
    --border-width: 1px;
    --border-color: #333;
    --bg-color: #121212;
    --text-light: #b0b0b0;
    --text: #e0e0e0;
    --text-muted: #888888;
    --primary: #4a8bfc;
}

/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

html, body {
    height: 100%;
    min-width: 320px;
}

body {
    zoom: 80%;
    background-color: #121212;
    color: #e0e0e0;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    -webkit-text-size-adjust: 100%;    
    font-size: 16px; 
}

html {
    font-size: 16px;
}

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

.container, .nav-container, .footer-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 导航栏样式 */
nav {
    background-color: #0a0a0a;
    padding: 16px 0 16px 0;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    width: 100%;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    height: 66px;
    border-bottom: 1px solid #333;
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.nav-brand {
    font-size: clamp(18px, 4.5vw, 22px);
    font-weight: normal;
    color: #ffffff;
    margin-right: 20px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
}

.nav-brand span:first-child {
    letter-spacing: 0.5px;
}

.nav-brand span:last-child {
    font-size: 0.95em;
    margin-left: 2px;
}

.nav-links {
    display: flex;
    list-style: none;
    align-items: center;
    flex-grow: 1;
    flex-wrap: wrap;
}

.nav-links li {
    margin-right: 15px;
    position: relative;
}

.nav-links a {
    color: #b0b0b0;
    font-weight: 500;
    transition: all 0.3s;
    padding: 8px 0;
    font-size: clamp(12px, 3vw, 14px);
    white-space: nowrap;
}

.nav-links a:hover, .nav-links a.active {
    color: #ffffff;
}

.nav-links a::before {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 0;
    background-color: #4a8bfc;
    transition: width 0.3s;
}

.nav-links a:hover::before {
    width: 100%;
}

.nav-contact {
    color: #aaaaaa;
    font-size: clamp(10px, 2.5vw, 12px);
    white-space: nowrap;
    margin-left: 15px;
    font-weight: 500;
    text-align: right;
    flex-shrink: 0;
}

/* 主内容区 */
main {
    flex: 1 0 auto;
    padding: 90px 0 20px;
    width: 100%;
}

.main-content {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.sidebar {
    flex: 1;
    min-width: 250px;
    max-width: 300px;
    background-color: #1e1e1e;
    padding: 20px;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border: 1px solid #333;
    align-self: stretch;
    display: flex;
    flex-direction: column;
}

.content-area {
    flex: 3;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-title {
    font-size: 1.1rem;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #333;
    color: #ffffff;
}

.sidebar-menu {
    list-style: none;
    flex-grow: 1;
}

.sidebar-menu li {
    margin-bottom: 10px;
}

.sidebar-menu a {
    display: block;
    padding: 8px 12px;
    color: #cccccc;
    border-radius: 4px;
    transition: all 0.3s;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
}

.sidebar-menu a:hover, 
.sidebar-menu a.active {
    background-color: #2a2a2a;
    color: #4a8bfc;
    border-left: 3px solid #4a8bfc;
    font-weight: bold;
    
    /* 修复闪烁的硬件加速属性 */
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
    position: relative;
}

.vertical-section {
    background-color: #1e1e1e;
    padding: 25px;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    width: 100%;
    flex-grow: 1;
    scroll-margin-top: 60px; 
    border: 1px solid #333;
}

.vertical-section h3,
.vertical-section h4,
.vertical-section h5,
.vertical-section h6 {
    scroll-margin-top: 60px;
}

.section-header {
    background-color: #2a2a2a;
    padding: 4px 20px;
    margin: -25px -25px 15px -25px;
    display: flex;
    align-items: center;
    min-height: 28px;
    border-bottom: 1px solid #333;
    border-radius: 4px 4px 0 0;
}

.section-icon {
    font-size: clamp(1rem, 4vw, 1.2rem);
    color: #4a8bfc;
    margin-right: 10px;
}

.section-title {
    font-size: clamp(0.8rem, 3.5vw, 0.9rem); 
    color: #ffffff;
    font-weight: 500;
}

.section-content {
    color: #cccccc;
    line-height: 1.6;
    font-size: clamp(0.75rem, 3vw, 0.85rem);
    overflow: visible;
    width: 100%;
}

.section-content h3 {
    margin: 20px 0 10px 0;
    padding-bottom: 5px;
    border-bottom: 1px solid #333;
    color: #ffffff;
}

.section-content h4 {
    margin: 15px 0 8px 0;
    color: #e0e0e0;
}

.section-content h5 {
    margin: 12px 0 6px 0;
    color: #cccccc;
}

.section-content h6 {
    margin: 10px 0 5px 0;
    color: #aaaaaa;
    font-size: 0.8rem;
}

.section-content p {
    margin-bottom: 12px;
}

.section-content ul, 
.section-content ol {
    margin-left: 20px;
    margin-bottom: 12px;
}

.section-content li {
    margin-bottom: 6px;
}

/* 内容区块特定样式 */
.content-section {
    margin-bottom: 30px;
    display: none;
}

.content-section.active {
    display: block;
}

.content-section h3 {
    font-size: 1.1rem;
    color: #ffffff;
    margin: 0 0 10px 0;
    padding: 0 0 5px 0;
    border-bottom: 1px solid #333;
    font-weight: bold;
    line-height: 1.3;
    text-shadow: 0 0 1px rgba(255,255,255,0.3);
    transition: font-size 0.3s ease;
}

.content-section > div {
    white-space: normal;
    word-wrap: break-word;
    overflow: visible;
    color: #cccccc;
    line-height: 1.6;
}

/* 下载项特定样式 */
.subsection {
    margin-bottom: 30px;
}

.subsection h3 {
    font-size: 1.1rem;
    color: #ffffff;
    margin: 0 0 10px 0;
    padding: 0 0 5px 0;
    border-bottom: 1px solid #333;
    font-weight: bold;
    line-height: 1.3;
    text-shadow: 0 0 1px rgba(255,255,255,0.3);
    transition: font-size 0.3s ease;
}

.subsection-content {
    white-space: normal;
    word-wrap: break-word;
    overflow: visible;
    color: #cccccc;
    line-height: 1.6;
}

/* 强制重置所有可能的间距来源 */
.subsection-content p,
.subsection-content div,
.subsection-content br,
.content-section > div p,
.content-section > div div,
.content-section > div br {
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.6 !important;
}

/* 针对从 Word 粘贴的内容 */
.subsection-content .MsoNormal,
.content-section .MsoNormal {
    margin: 0 !important;
}

.subsection-content ul, 
.subsection-content ol,
.content-section ul,
.content-section ol {
    margin-left: 20px;
    margin-bottom: 12px;
}

.subsection-content li,
.content-section li {
    margin-bottom: 6px;
}

/* 下载区域样式 */
.download-section {
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 27px;
}

.download-label {
    color: #cccccc;
    font-size: 0.85rem;
    white-space: nowrap;
    line-height: 1;
    display: flex;
    align-items: center;
    height: 27px;
    margin: 0;
    padding: 0;
}

.section-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 10px;
    background-color: #2a2a2a;
    color: #4a8bfc;
    font-weight: 500;
    border-radius: 4px;
    transition: all 0.3s ease;
    border: 1px solid #333;
    text-decoration: none;
    line-height: 1;
    height: 27px;
    box-sizing: border-box;
    vertical-align: middle;
    margin: 0;
}

.section-link:hover {
    background-color: #333;
    color: #6ba1ff;
    transform: translateY(-2px);
    border-color: #4a8bfc;
}

/* 取消下载地址右箭头 */
.section-link::after {
    content: '' !important;
    margin-left: 0 !important;
}

.section-link:hover::after {
    content: '' !important;
    margin-left: 0 !important;
}

/* 通用链接样式 */
.section-link {
    display: inline-flex;
    align-items: center;
    margin-top: 15px;
    padding: 5px 10px;
    background-color: #2a2a2a;
    color: #4a8bfc;
    font-weight: 500;
    border-radius: 4px;
    transition: all 0.3s ease;
    border: 1px solid #333;
    font-size: clamp(0.7rem, 3vw, 0.8rem);
}

.section-link:hover {
    background-color: #333;
    color: #6ba1ff;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    border-color: #4a8bfc;
}

.section-link::after {
    content: '→';
    margin-left: 6px;
    transition: margin-left 0.3s;
}

.section-link:hover::after {
    margin-left: 10px;
}

/* 下载项样式 */
.download-items {
    display: grid;
    gap: 15px;
    margin-top: 15px;
}

.download-item {
    background-color: #2a2a2a;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #333;
}

.download-item h4 {
    color: #4a8bfc;
    margin-bottom: 8px;
}

.download-meta {
    display: flex;
    gap: 15px;
    margin: 10px 0;
    font-size: 0.8rem;
    color: #aaaaaa;
}

/* 代码块样式 */
pre {
    background-color: #2a2a2a;
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
    font-family: Consolas, Monaco, 'Andale Mono', monospace;
    margin: 10px 0;
    font-size: 0.75rem;
    border: 1px solid #333;
    color: #e0e0e0;
}

code {
    font-family: Consolas, Monaco, 'Andale Mono', monospace;
    background-color: #2a2a2a;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 0.75rem;
    color: #e0e0e0;
    border: 1px solid #333;
}

/* 警告框样式 */
.alert {
    padding: 10px 15px;
    margin-bottom: 20px;
    border-radius: 4px;
}

.alert-info {
    background-color: #2a527d;
    color: #fff;
}

.alert-success {
    background-color: #2d7d46;
    color: #fff;
}

.alert-error, .alert-danger {
    background-color: #dc3545;
    color: #fff;
}

/* 页脚与友情链接样式 (优化版) */
.friendly-links {
    background: #1e1e1e;          /* 改为与 sidebar、vertical-section 一致 */
    border: none;                  /* 移除上下边框 */
    padding: 16px 0;
    margin-top: -1px;
    position: relative;
    z-index: 5;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2);
}

.friendly-links .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}

/* 链接包装器 - 默认左对齐，与侧边栏视觉对齐 */
.links-wrapper {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 8px;
}

.links-title {
    color: #b0b0b0;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.3px;
    flex-shrink: 0;
    background: rgba(74, 139, 252, 0.1);
    padding: 2px 10px;
    border-radius: 16px;
    border-left: 2px solid #4a8bfc;
}

.links-list {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 8px;
}

.link-item {
    color: #cccccc;
    text-decoration: none;
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    white-space: nowrap;
    background-color: transparent;
    border: 1px solid transparent;
}

.link-item:hover {
    color: #ffffff;
    background-color: rgba(74, 139, 252, 0.15);
    border-color: rgba(74, 139, 252, 0.3);
    transform: translateY(-1px);
}

.link-separator {
    color: #444444;
    font-size: 12px;
    font-weight: 300;
    user-select: none;
}

/* 页脚主区域 - 优化版 */
footer {
    background-color: #1e1e1e;     /* 改为与 sidebar 一致 */
    color: #888888;
    padding: 18px 0;
    text-align: center;
    border-top: 1px solid #333;    /* 改为与导航栏一致 */
    margin-top: 0;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}

.copyright {
    color: #777777;
    font-size: 13px;
    letter-spacing: 0.3px;
    margin: 0;
    transition: color 0.2s;
}

.copyright:hover {
    color: #999999;
}

/* ========== 响应式微调 ========== */

/* 中等屏幕 (小于1200px) */
@media (max-width: 1199px) {
    .friendly-links .container,
    .footer-container {
        padding: 0 20px;
    }
}

/* 平板及以下 (小于992px) */
@media (max-width: 991px) {
    .friendly-links {
        padding: 14px 0;
    }
    
    .links-title {
        font-size: 13px;
        padding: 2px 8px;
    }
    
    .link-item {
        font-size: 12px;
        padding: 3px 6px;
    }
    
    .copyright {
        font-size: 12px;
    }
}

/* 移动端 (小于768px) */
@media (max-width: 767px) {
    .friendly-links {
        padding: 12px 0;
        margin-top: -1px;
    }
    
    .friendly-links .container,
    .footer-container {
        padding: 0 15px;
    }
    
    /* 移动端: 居中对齐更美观 */
    .links-wrapper {
        justify-content: center;
        text-align: center;
        gap: 8px;
    }
    
    .links-list {
        justify-content: center;
    }
    
    .link-item {
        white-space: normal;
        word-break: break-word;
    }
    
    .link-separator {
        margin: 0 2px;
    }
    
    footer {
        padding: 15px 0;
    }
}

/* 小手机 (小于576px) */
@media (max-width: 575px) {
    .friendly-links {
        padding: 10px 0;
    }
    
    .links-wrapper {
        flex-direction: column;
        gap: 6px;
    }
    
    .links-title {
        margin-bottom: 2px;
        display: inline-block;
    }
    
    .links-list {
        gap: 6px 10px;
    }
    
    .link-separator {
        display: inline;
    }
}

/* 超小屏 (小于400px) */
@media (max-width: 399px) {
    .links-list {
        gap: 5px;
    }
    .link-separator {
        margin: 0 1px;
        font-size: 10px;
    }
    .link-item {
        font-size: 11px;
        padding: 2px 5px;
    }
}

/* 额外优化：确保链接区域与上方内容间距自然 */
main + .friendly-links {
    margin-top: -15px;
}

/* 友情链接区域与footer之间空隙调整 */
.friendly-links + footer {
    margin-top: 5px;
}

/* 保留调试按钮样式，仅当debug启用时注入 */

/* 后台管理样式 */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-switcher {
    display: flex;
    gap: 10px;
}

.section-switcher a {
    padding: 8px 16px;
    background: #2a2a2a;
    color: #e0e0e0;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.3s;
}

.section-switcher a:hover {
    background: #3a3a3a;
}

.section-switcher a.active {
    background: #4a8bfc;
    color: white;
}

.admin-container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 20px;
}

.admin-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px;
    margin-top: 20px;
}

.form-section, .list-section {
    background-color: #1e1e1e;
    padding: 20px;
    border-radius: 4px;
    border: 1px solid #333;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 8px 12px;
    background-color: #2a2a2a;
    border: 1px solid #333;
    border-radius: 4px;
    color: #e0e0e0;
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.btn {
    display: inline-block;
    padding: 8px 16px;
    background-color: #4a8bfc;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn:hover {
    background-color: #3a7bec;
    transform: translateY(-2px);
}

.btn-primary {
    background-color: #4a8bfc;
}

.btn-secondary {
    background-color: #6c757d;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-danger {
    background-color: #dc3545;
}

.btn-danger:hover {
    background-color: #c82333;
}

.btn-sm, .btn-small {
    padding: 4px 8px;
    font-size: 0.8rem;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #333;
}

.admin-table th {
    background-color: #2a2a2a;
    font-weight: 500;
}

.actions {
    white-space: nowrap;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.stat-card {
    background-color: #1e1e1e;
    padding: 20px;
    border-radius: 4px;
    border: 1px solid #333;
    text-align: center;
}

.stat-card h3 {
    font-size: 1rem;
    color: #aaaaaa;
    margin-bottom: 10px;
}

.stat-card p {
    font-size: 1.5rem;
    color: #4a8bfc;
    font-weight: bold;
}

.quick-links {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

/* 登录页面样式 */
.login-container {
    max-width: 400px;
    margin: 50px auto;
    padding: 30px;
    background-color: #1e1e1e;
    border-radius: 4px;
    border: 1px solid #333;
}

.login-container h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #4a8bfc;
}

/* 预加载样式防止闪烁 */
#preload-styles {
    display: none;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .nav-container {
        gap: 10px;
    }
    
    .nav-links {
        justify-content: flex-start;
    }
    
    .nav-links li {
        margin-right: 12px;
    }
    
    .vertical-section {
        padding: 20px;
    }
    
    .section-header {
        margin: -20px -20px 15px -20px;
        padding: 4px 15px;
    }

    .main-content {
        flex-direction: column;
    }

    .sidebar {
        max-width: 100%;
        order: -1;
    }
    
    .admin-grid {
        grid-template-columns: 1fr;
    }
    
    .subsection h3,
    .content-section h3 {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .container, .nav-container, .footer-container {
        padding: 0 15px;
    }
    
    .nav-contact {
        margin-left: 0;
        margin-top: 5px;
        width: 100%;
        text-align: left;
    }
    
    .vertical-section {
        padding: 15px;
    }
    
    .section-header {
        margin: -15px -15px 12px -15px;
        padding: 3px 15px;
    }
    
    .section-link {
        padding: 4px 8px;
    }
    
    .quick-links {
        flex-direction: column;
    }
    
    .section-switcher {
        flex-direction: column;
        gap: 5px;
    }
    
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .download-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .download-label,
    .section-link {
        height: auto;
    }
}