/* 博客系统样式表 - 现代化优化版本 */

/* 性能优化：减少重绘和重排 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth; /* 平滑滚动 */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    max-width: 1200px;
    margin: 1rem auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    min-height: calc(100vh - 2rem);
}

/* 导航栏样式 */
nav {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    will-change: transform; /* 性能优化 */
}

.nav-brand h1 {
    margin: 0;
    font-size: 1.8rem;
}

.nav-brand a {
    color: white;
    text-decoration: none;
    transition: color 0.3s ease;
}

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

.nav-menu {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-links,
.nav-actions {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 1.5rem;
    align-items: center;
}

.nav-links a,
.nav-actions a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-links a:hover,
.nav-actions a:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.nav-actions .action {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    border-radius: 20px;
    padding: 0.5rem 1.5rem;
}

.nav-actions .action:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.user-info {
    color: #bdc3c7;
    font-weight: 500;
}

/* 响应式导航栏 - 移动端优化 */
@media (max-width: 768px) {
    nav {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-menu {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }
    
    .nav-links,
    .nav-actions {
        justify-content: center;
        gap: 1rem;
    }
    
    /* 移动端触摸优化 */
    .nav-links a,
    .nav-actions a {
        padding: 0.75rem 1rem; /* 更大的触摸区域 */
        min-height: 44px; /* 最小触摸尺寸 */
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* 性能优化：图片懒加载和字体优化 */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* 字体优化：使用系统字体栈 */
h1, h2, h3, h4, h5, h6 {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 600;
    line-height: 1.3;
}

h1 {
    font-size: 2.5rem;
    color: #2c3e50;
    margin: 1rem 0;
    font-weight: 700;
}

/* 链接样式 */
a {
    color: #3498db; /* 现代蓝色 */
    text-decoration: none;
    transition: color 0.3s ease; /* 颜色过渡动画 */
}

a:hover {
    color: #2980b9; /* 悬停颜色 */
    text-decoration: underline;
}

/* 分隔线样式 */
hr {
    border: none;
    border-top: 2px solid #ecf0f1; /* 更粗的分隔线 */
    margin: 2rem 0;
}

/* 导航栏样式 - 现代化设计 */
nav {
    background: linear-gradient(90deg, #34495e 0%, #2c3e50 100%); /* 深色渐变导航 */
    display: flex;
    align-items: center;
    padding: 0 2rem; /* 增加内边距 */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

nav h1 {
    flex: auto;
    margin: 0;
    color: white; /* 白色文字 */
}

nav h1 a {
    text-decoration: none;
    padding: 0.5rem 1rem;
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
}

nav ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
}

nav ul li a, nav ul li span, header .action {
    display: block;
    padding: 1rem 1.5rem; /* 增加内边距 */
    color: white;
    font-weight: 500;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

nav ul li a:hover {
    background-color: rgba(255, 255, 255, 0.1); /* 悬停背景 */
}

/* 内容区域样式 */
.content {
    padding: 2rem; /* 增加内边距 */
    background: #f8f9fa; /* 浅灰色背景 */
    min-height: calc(100vh - 200px); /* 最小高度 */
}

.content > header {
    border-bottom: 2px solid #e9ecef; /* 更粗的边框 */
    display: flex;
    align-items: center;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}

.content > header h1 {
    flex: auto;
    margin: 1rem 0 0.25rem 0;
    font-size: 2rem; /* 更大的标题 */
}

/* 消息提示样式 */
.flash {
    margin: 1em 0;
    padding: 1em;
    background: #d4edda; /* 成功消息背景 */
    border: 1px solid #c3e6cb;
    border-radius: 8px; /* 圆角 */
    color: #155724;
    font-weight: 500;
}

/* 文章卡片样式 - 现代化设计 */
.post {
    background: white;
    border-radius: 12px; /* 圆角卡片 */
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08); /* 卡片阴影 */
    transition: transform 0.3s ease, box-shadow 0.3s ease; /* 悬停动画 */
    border: 1px solid #e9ecef;
}

.post:hover {
    transform: translateY(-2px); /* 悬停上移效果 */
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.post > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e9ecef;
}

.post > header > div:first-of-type {
    flex: auto;
}

.post > header h1 {
    font-size: 1.8rem; /* 更大的文章标题 */
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.post .about {
    color: #6c757d; /* 灰色文字 */
    font-style: italic;
    font-size: 0.9rem;
}

.post .body {
    white-space: pre-line;
    line-height: 1.6; /* 更好的行高 */
    color: #495057;
    font-size: 1.1rem;
}

/* 操作按钮样式 */
.action {
    background: #3498db; /* 蓝色按钮 */
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    transition: background-color 0.3s ease;
}

.action:hover {
    background: #2980b9; /* 悬停颜色 */
    text-decoration: none;
    color: white;
}

/* 表单样式 */
.content form {
    margin: 2em 0;
    display: flex;
    flex-direction: column;
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.content label {
    font-weight: 600;
    margin-bottom: 0.5em;
    color: #2c3e50;
}

.content input, .content textarea {
    margin-bottom: 1.5em;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.content input:focus, .content textarea:focus {
    border-color: #3498db; /* 聚焦边框颜色 */
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.content textarea {
    min-height: 12em;
    resize: vertical;
    line-height: 1.5;
}

/* 危险操作按钮 */
input.danger {
    color: #e74c3c; /* 红色危险按钮 */
    background: #fdf2f2;
    border: 1px solid #e74c3c;
}

input[type=submit] {
    align-self: flex-start;
    min-width: 10em;
    background: #27ae60; /* 绿色提交按钮 */
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

input[type=submit]:hover {
    background: #219a52; /* 悬停颜色 */
}

/* 加载动画和用户体验优化 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 平滑过渡效果 */
* {
    transition: all 0.2s ease-in-out;
}

/* 禁用文本选择优化 */
.nav-brand, .nav-links, .nav-actions {
    user-select: none;
}

/* 响应式设计 - 移动设备适配 */
@media (max-width: 768px) {
    body {
        margin: 0.5rem;
        border-radius: 8px;
    }
    
    nav {
        flex-direction: column;
        padding: 1rem;
    }
    
    nav ul {
        flex-direction: column;
        width: 100%;
        margin-top: 1rem;
    }
    
    .content {
        padding: 1rem;
    }
    
    .post {
        padding: 1.5rem;
    }
    
    .post > header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .action {
        margin-top: 1rem;
        align-self: flex-start;
    }
    
    /* 移动端字体优化 */
    h1 {
        font-size: 2rem;
    }
    
    .post h1 {
        font-size: 1.5rem;
    }
}

/* JavaScript交互样式 */
.field-error {
    color: #e74c3c;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: none;
}

input.error, textarea.error {
    border-color: #e74c3c !important;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1) !important;
}

/* 移动端菜单样式 */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }
    
    .nav-menu {
        display: none;
    }
    
    .nav-menu.active {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }
}

/* 搜索自动完成样式 */
.autocomplete {
    position: absolute;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

.autocomplete-item:hover {
    background-color: #f8f9fa;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

/* 无障碍访问优化 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 焦点可见性优化 */
*:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* 减少动画对性能敏感用户的影响 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .loading {
        animation: none;
        border: none;
        background: #3498db;
    }
}