/**
 * 额外样式 - 侧边栏和评论样式增强
 *
 * @package Qingxin_Theme
 */

/* 侧边栏评论样式 */
.comment-item {
    padding: 12px;
    margin-bottom: 12px;
    background-color: #f8f8f8;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

.comment-item:hover {
    background-color: #f0f0f0;
}

.comment-author {
    font-weight: 600;
    font-size: 13px;
    color: #333;
    margin-bottom: 5px;
}

.comment-excerpt {
    font-size: 12px;
    color: #666;
    line-height: 1.5;
    margin-bottom: 5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.comment-date {
    font-size: 11px;
    color: #999;
}

/* 归档列表样式 */
.archive-list ul {
    list-style: none;
    padding: 0;
}

.archive-list li {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.archive-list li:last-child {
    border-bottom: none;
}

.archive-list a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #666;
    font-size: 13px;
    transition: color 0.3s ease;
}

.archive-list a:hover {
    color: #5a9fd4;
}

/* 友情链接样式 */
.links-list ul {
    list-style: none;
    padding: 0;
}

.links-list li {
    padding: 6px 0;
}

.links-list a {
    color: #666;
    font-size: 13px;
    transition: all 0.3s ease;
    display: inline-block;
}

.links-list a:hover {
    color: #5a9fd4;
    padding-left: 5px;
}

/* 文章导航样式（上一篇/下一篇）*/
.post-navigation {
    margin-top: 30px;
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.nav-previous,
.nav-next {
    flex: 1;
    max-width: 48%;
}

.nav-previous a,
.nav-next a {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    transition: all 0.3s ease;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.nav-previous a::before,
.nav-next a::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #cfe4fa 0%, #e8f4fd 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
}

.nav-previous a:hover::before,
.nav-next a:hover::before {
    opacity: 1;
}

.nav-previous a:hover,
.nav-next a:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(90, 159, 212, 0.2);
    border-color: #cfe4fa;
}

.nav-subtitle {
    display: block;
    font-size: 12px;
    color: #5a9fd4;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    z-index: 1;
}

.nav-title {
    display: block;
    font-size: 15px;
    color: #333;
    font-weight: 600;
    line-height: 1.5;
    position: relative;
    z-index: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.nav-next {
    text-align: right;
}

.nav-next a {
    align-items: flex-end;
}

/* 响应式优化 */
@media (max-width: 768px) {
    .post-navigation {
        flex-direction: column;
        gap: 15px;
    }
    
    .nav-previous,
    .nav-next {
        max-width: 100%;
    }
    
    .nav-next {
        text-align: left;
    }
    
    .nav-next a {
        align-items: flex-start;
    }
}

/* 页面链接分页 */
.page-links {
    margin-top: 20px;
    padding: 15px;
    background-color: #f8f8f8;
    border-radius: 5px;
    font-size: 14px;
}

.page-links .page-number {
    display: inline-block;
    margin: 0 5px;
    padding: 5px 10px;
    background-color: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 3px;
    transition: all 0.3s ease;
}

.page-links .page-number:hover {
    background-color: #cfe4fa;
    border-color: #cfe4fa;
}

/* 搜索结果页面增强 */
.search-header {
    background-color: #fff;
    padding: 30px;
    margin-bottom: 20px;
    border-radius: 5px;
    border: 1px solid #e5e5e5;
}

.search-title {
    font-size: 24px;
    margin-bottom: 10px;
    color: #333;
}

.search-title span {
    color: #5a9fd4;
}

.search-count {
    font-size: 14px;
    color: #666;
}

.search-again {
    margin: 30px 0;
    padding: 20px;
    background-color: #f8f8f8;
    border-radius: 5px;
}

.search-suggestions,
.suggested-posts {
    margin-top: 30px;
    padding: 20px;
    background-color: #f8f8f8;
    border-radius: 5px;
}

.search-suggestions h3,
.suggested-posts h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: #333;
}

.search-suggestions ul,
.suggested-posts ul {
    list-style: disc;
    padding-left: 30px;
}

.search-suggestions li,
.suggested-posts li {
    margin-bottom: 8px;
    color: #666;
    font-size: 14px;
}

.suggested-posts a {
    color: #5a9fd4;
}

/* 归档页面标题 */
.archive-header {
    background-color: #fff;
    padding: 30px;
    margin-bottom: 20px;
    border-radius: 5px;
    border: 1px solid #e5e5e5;
    text-align: center;
}

.archive-title {
    font-size: 28px;
    color: #333;
    margin-bottom: 10px;
}

.archive-description {
    font-size: 14px;
    color: #666;
    line-height: 1.8;
}

/* 相关文章列表优化 */
.related-post-item {
    background-color: #fff;
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid #e5e5e5;
    transition: all 0.3s ease;
}

.related-post-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-3px);
}

.related-post-item .post-thumbnail {
    width: 100%;
    height: 150px;
    background-color: #f0f0f0;
}

.related-post-item .post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.related-post-item .post-title {
    padding: 15px;
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

.related-post-item .post-title a {
    color: #333;
}

.related-post-item .post-meta {
    padding: 0 15px 15px;
    font-size: 12px;
    color: #999;
}

/* ===========================
   评论区样式
   =========================== */
.comments-area {
    margin-top: 40px;
    padding: 30px;
    background-color: #fff;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
}

.comments-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #cfe4fa;
    color: #333;
}

.comment-list {
    list-style: none;
    padding: 0;
    margin: 0 0 30px 0;
}

.comment-list > li {
    margin-bottom: 20px;
}

.comment-body {
    display: flex;
    gap: 15px;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
    position: relative;
    transition: all 0.3s ease;
}

.comment-body:hover {
    background-color: #f0f4f8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.comment-author.vcard {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    min-width: 70px;
}

.comment-author img {
    border-radius: 50%;
    border: 2px solid #e5e5e5;
}

.comment-author .fn {
    font-size: 13px;
    color: #333;
    font-weight: 600;
    text-align: center;
    word-break: break-word;
}

.comment-author .fn a {
    color: #5a9fd4;
}

.comment-author .says {
    display: none;
}

.comment-content-wrapper {
    flex: 1;
    min-width: 0;
}

.comment-metadata {
    font-size: 12px;
    color: #999;
    margin-bottom: 10px;
}

.comment-metadata a {
    color: #999;
    transition: color 0.3s ease;
}

.comment-metadata a:hover {
    color: #5a9fd4;
}

.comment-metadata .edit-link {
    color: #999;
}

.comment-content {
    font-size: 14px;
    line-height: 1.8;
    color: #333;
    margin-bottom: 10px;
    word-wrap: break-word;
}

.comment-content p {
    margin-bottom: 10px;
}

.comment-content p:last-child {
    margin-bottom: 0;
}

.comment-awaiting-moderation {
    color: #f39c12;
    font-size: 13px;
    padding: 8px 12px;
    background-color: #fff3cd;
    border-radius: 5px;
    margin: 10px 0;
    border-left: 3px solid #f39c12;
}

.reply {
    margin-top: 10px;
}

.reply a {
    display: inline-block;
    padding: 6px 15px;
    background-color: #5a9fd4;
    color: #fff !important;
    border-radius: 5px;
    font-size: 12px;
    transition: all 0.3s ease;
}

.reply a:hover {
    background-color: #4a8fc4;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(90, 159, 212, 0.3);
}

.children {
    list-style: none;
    margin-left: 50px;
    margin-top: 15px;
}

.children .comment-body {
    background-color: #fff;
}

/* 评论表单样式 */
.comment-form {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid #e5e5e5;
}

.comment-reply-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #333;
}

.comment-form-comment,
.comment-form-author,
.comment-form-email,
.comment-form-url {
    margin-bottom: 15px;
}

.comment-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #e5e5e5;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.3s ease;
    background-color: #fff;
}

.comment-form input:focus,
.comment-form textarea:focus {
    outline: none;
    border-color: #5a9fd4;
    box-shadow: 0 0 0 3px rgba(90, 159, 212, 0.1);
}

.comment-form textarea {
    resize: vertical;
    min-height: 120px;
}

.comment-form .required {
    color: #e74c3c;
}

.form-submit {
    margin-top: 20px;
}

.form-submit input[type="submit"] {
    padding: 12px 30px;
    background: linear-gradient(135deg, #5a9fd4 0%, #4a8fc4 100%);
    color: #fff;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.form-submit input[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(90, 159, 212, 0.3);
}

.form-submit input[type="submit"]:active {
    transform: translateY(0);
}

.no-comments {
    padding: 30px;
    text-align: center;
    color: #999;
    background-color: #f8f9fa;
    border-radius: 8px;
    font-size: 14px;
}

/* 评论导航 */
.comment-navigation {
    margin: 20px 0;
    padding: 15px 0;
    border-top: 1px solid #e5e5e5;
    border-bottom: 1px solid #e5e5e5;
}

.comment-navigation .nav-previous,
.comment-navigation .nav-next {
    display: inline-block;
}

.comment-navigation .nav-next {
    float: right;
}

.comment-navigation a {
    color: #5a9fd4;
    transition: color 0.3s ease;
}

.comment-navigation a:hover {
    color: #4a8fc4;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .comments-area {
        padding: 20px 15px;
    }
    
    .comment-body {
        flex-direction: column;
        padding: 15px;
    }
    
    .comment-author.vcard {
        flex-direction: row;
        width: 100%;
        justify-content: flex-start;
    }
    
    .children {
        margin-left: 20px;
    }
    
    .comment-form input[type="text"],
    .comment-form input[type="email"],
    .comment-form input[type="url"],
    .comment-form textarea {
        font-size: 16px; /* 防止iOS自动缩放 */
    }
}

/* 返回顶部按钮 - 优化版 */
.back-to-top {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #5a9fd4 0%, #4a8fc4 100%);
    color: #fff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999;
    box-shadow: 0 4px 20px rgba(90, 159, 212, 0.3);
    border: none;
    font-size: 20px;
    line-height: 1;
}

.back-to-top::before {
    content: "↑";
    display: block;
    font-size: 24px;
    font-weight: bold;
    transform: translateY(0);
    transition: transform 0.3s ease;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
    animation: slideInUp 0.5s ease-out;
}

.back-to-top:hover {
    background: linear-gradient(135deg, #4a8fc4 0%, #3a7fb4 100%);
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(90, 159, 212, 0.5);
}

.back-to-top:hover::before {
    transform: translateY(-3px);
}

.back-to-top:active {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(90, 159, 212, 0.4);
}

/* 返回顶部按钮动画 */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 移动端适配 */
@media (max-width: 768px) {
    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
        border-radius: 10px;
    }
    
    .back-to-top::before {
        font-size: 20px;
    }
}

/* 加载动画 */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #5a9fd4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 平滑滚动 */
html {
    scroll-behavior: smooth;
}

/* 图片懒加载占位 */
img[loading="lazy"] {
    background-color: #f0f0f0;
}

/* 打印样式 */
@media print {
    .site-header,
    .main-navigation,
    .sidebar,
    .site-footer,
    .comments-area,
    .post-navigation,
    .back-to-top {
        display: none;
    }
    
    .content-wrapper {
        display: block;
    }
    
    .main-content {
        width: 100%;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    body {
        color: #000;
        background-color: #fff;
    }
    
    a {
        text-decoration: underline;
    }
}

/* 深色模式准备 */
@media (prefers-color-scheme: dark) {
    /* 如需支持深色模式，在此添加样式 */
    /* 例如：
    body {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }
    */
}

/* 动画效果 - 使用 opacity 和 transform 避免 CLS */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 使用 animation-fill-mode: backwards 确保动画开始前元素已就位 */
.post-item {
    animation: fadeIn 0.3s ease-out backwards;
    /* 使用 contain 优化性能并避免布局偏移 */
    contain: layout style;
}

/* 选中文本样式 */
::selection {
    background-color: #cfe4fa;
    color: #333;
}

::-moz-selection {
    background-color: #cfe4fa;
    color: #333;
}

/* ===========================
   CLS 优化 - 移动端菜单按钮
   =========================== */
.menu-toggle {
    display: none;
    padding: 10px 15px;
    background-color: #5a9fd4;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 20px;
    margin-bottom: 10px;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }
    
    .nav-menu {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: #fff;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        z-index: 999;
        padding: 10px 0;
    }
    
    .nav-menu.active {
        display: flex;
    }
    
    .nav-menu li {
        width: 100%;
    }
    
    .main-navigation {
        position: relative;
    }
}

/* ===========================
   CLS 优化 - 阅读进度条
   =========================== */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: #f0f0f0;
    z-index: 9999;
    contain: layout style;
}

.reading-progress-bar {
    height: 100%;
    background: linear-gradient(to right, #5a9fd4, #cfe4fa);
    width: 0%;
    transition: width 0.1s ease;
    will-change: width;
}

/* ===========================
   CLS 优化 - 评论字符计数
   =========================== */
.comment-char-count {
    margin-top: 5px;
    font-size: 12px;
    color: #999;
    text-align: right;
    min-height: 18px;
}

.comment-char-count.exceeded {
    color: #e74c3c;
}

/* ===========================
   CLS 优化 - 图片灯箱
   =========================== */
.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
}

.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
}

.lightbox-content {
    position: relative;
    width: 90%;
    max-width: 1200px;
    margin: 50px auto;
    text-align: center;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 80vh;
    margin: 0 auto;
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    font-size: 40px;
    cursor: pointer;
    line-height: 1;
}

/* ===========================
   CLS 优化 - 搜索框聚焦状态
   =========================== */
.search-form.focused {
    border-color: #cfe4fa;
    box-shadow: 0 0 5px rgba(207, 228, 250, 0.5);
}

/* ===========================
   CLS 优化 - 文章内容图片
   =========================== */
.single-post-content img {
    cursor: pointer;
    transition: transform 0.3s ease;
}

.single-post-content img:hover {
    transform: scale(1.02);
}

/* 滚动条样式（仅Webkit浏览器） */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #cfe4fa;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5a9fd4;
}

