/* 全局样式重置和基础设置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    /* 响应式字体大小 */
    font-size: clamp(14px, 2.5vw, 16px);
}

/* 链接样式 */
a {
    color: #2563eb;
    text-decoration: none;
    transition: color 0.2s ease;
    /* 触摸反馈 */
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(37, 99, 235, 0.2);
}

a:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

a:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
}

/* 按钮基础样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    /* 触摸反馈 */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px; /* 确保足够的触摸区域 */
    min-width: 44px; /* 确保足够的触摸区域 */
}

.btn:active {
    transform: scale(0.96);
    transition: transform 0.1s ease;
}

.btn-primary {
    background-color: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
}

.btn-primary:hover {
    background-color: #1d4ed8;
    border-color: #1e40af;
    color: #ffffff;
    text-decoration: none;
}

.btn-secondary {
    background-color: #64748b;
    color: #ffffff;
    border-color: #64748b;
}

.btn-secondary:hover {
    background-color: #475569;
    border-color: #334155;
    color: #ffffff;
    text-decoration: none;
}

.btn-danger {
    background-color: #ef4444;
    color: #ffffff;
    border-color: #ef4444;
}

.btn-danger:hover {
    background-color: #dc2626;
    border-color: #b91c1c;
    color: #ffffff;
    text-decoration: none;
}

/* 表单样式 */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #111827;
    background-color: #ffffff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #111827;
    background-color: #ffffff;
    resize: vertical;
    min-height: 100px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* 卡片样式 */
.card {
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: translateY(-2px);
    border-color: #d1d5db;
}

/* 文章卡片样式强化 */
article {
    background: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

article::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #2563eb 0%, #8b5cf6 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

article:hover {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: translateY(-2px);
    border-color: #d1d5db;
}

article:hover::before {
    opacity: 1;
}

/* 封面图样式优化 */
article .h-48 {
    border-radius: 1rem 1rem 0 0;
    overflow: hidden;
}

article img {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

article:hover img {
    transform: scale(1.08);
}

/* 卡片内容间距优化 */
article .p-4 {
    padding: 1.25rem;
}

/* 分类标签样式优化 */
article .bg-blue-100 {
    transition: all 0.3s ease;
}

article:hover .bg-blue-100 {
    background-color: #2563eb;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 标题样式优化 */
article h3 {
    transition: all 0.3s ease;
    position: relative;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

article:hover h3 {
    color: #2563eb;
}

/* 标签样式优化 */
article .bg-gray-100 {
    transition: all 0.3s ease;
}

article:hover .bg-gray-100 {
    background-color: #e0e7ff;
    color: #3b82f6;
    transform: translateY(-1px);
}

/* 阅读全文按钮优化 */
article .text-blue-600 {
    transition: all 0.3s ease;
    position: relative;
}

article .text-blue-600::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: #2563eb;
    transition: width 0.3s ease;
}

article:hover .text-blue-600::after {
    width: 100%;
}

.card-header {
    padding: 1rem;
    background-color: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
    color: #111827;
}

.card-body {
    padding: 1rem;
}

.card-footer {
    padding: 1rem;
    background-color: #f9fafb;
    border-top: 1px solid #e5e7eb;
    text-align: right;
}

/* 标签云样式 */
.tag-item {
    transition: all 0.3s ease;
    font-weight: 500;
}

.tag-item.tag-small {
    font-size: 0.875rem;
    color: #4f46e5;
    background-color: #eef2ff;
}

.tag-item.tag-small:hover {
    background-color: #ddd6fe;
    color: #4338ca;
}

.tag-item.tag-medium {
    font-size: 1rem;
    color: #1e40af;
    background-color: #dbeafe;
}

.tag-item.tag-medium:hover {
    background-color: #bfdbfe;
    color: #1e3a8a;
}

.tag-item.tag-large {
    font-size: 1.125rem;
    color: #0c4a6e;
    background-color: #e0f2fe;
}

.tag-item.tag-large:hover {
    background-color: #bae6fd;
    color: #075985;
}

/* 动画效果 */
@keyframes pulse-slow {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
}

.animate-pulse-slow {
    animation: pulse-slow 3s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

/* 响应式工具类 */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
    
    .show-mobile {
        display: block !important;
    }
    
    /* 移动端菜单过渡效果 */
    #mobile-menu {
        transition: all 0.3s ease-in-out;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transform: translateY(-10px);
    }
    
    #mobile-menu:not(.hidden) {
        max-height: 500px;
        opacity: 1;
        transform: translateY(0);
    }
    
    #mobile-category-menu {
        transition: all 0.3s ease-in-out;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
    }
    
    #mobile-category-menu:not(.hidden) {
        max-height: 300px;
        opacity: 1;
    }
}

@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }
    
    .show-desktop {
        display: block !important;
    }
}

/* 加载状态 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(37, 99, 235, 0.2);
    border-radius: 50%;
    border-top-color: #2563eb;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 错误提示 */
.alert {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: 0.375rem;
}

.alert-success {
    color: #065f46;
    background-color: #d1fae5;
    border-color: #a7f3d0;
}

.alert-error {
    color: #991b1b;
    background-color: #fee2e2;
    border-color: #fecaca;
}

.alert-warning {
    color: #92400e;
    background-color: #fef3c7;
    border-color: #fde68a;
}

.alert-info {
    color: #0891b2;
    background-color: #cffafe;
    border-color: #a5f3fc;
}

/* 分页样式 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem 0;
}

.pagination-link {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    color: #374151;
    text-decoration: none;
    transition: all 0.2s ease;
}

.pagination-link:hover {
    background-color: #f3f4f6;
    border-color: #9ca3af;
    color: #111827;
    text-decoration: none;
}

.pagination-link.active {
    background-color: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

.pagination-link.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* 回到顶部按钮 */
#backToTop {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 3rem;
    height: 3rem;
    background-color: #2563eb;
    color: #ffffff;
    border-radius: 50%;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 50;
    /* 触摸反馈 */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

#backToTop:hover {
    background-color: #1d4ed8;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

#backToTop:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

#backToTop.visible {
    opacity: 1;
    visibility: visible;
}

/* 移动端优化 */
@media (max-width: 768px) {
    #backToTop {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 3.5rem;
        height: 3.5rem;
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    }
}

/* 广告轮播样式 */
.carousel-container {
    position: relative;
    overflow: hidden;
}

.carousel-container > div {
    display: flex;
    transition: transform 0.5s ease;
}

.carousel-slide {
    flex-shrink: 0;
    width: 100%;
    min-width: 100%;
}

.carousel-control {
    cursor: pointer;
    user-select: none;
}

.carousel-indicators {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.carousel-indicators button {
    cursor: pointer;
    user-select: none;
    transition: all 0.3s ease;
}

/* 解决Font Awesome图标显示问题 */
/* 移除外部Font Awesome资源的引用 */
/* @import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css'); */

/* 文章内容样式 */
.prose {
    line-height: 1.8;
    font-size: clamp(1rem, 2.5vw, 1.05rem);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* 修复文章内容中首个h1标题的top margin导致的过多留白 */
.prose > h1:first-child {
    margin-top: 0 !important;
}

/* 统一处理所有页面的空格显示 */
/* 只对代码块使用pre-wrap，保留代码格式 */
.prose pre,
.prose code {
    white-space: pre-wrap !important;
}

/* 对文本内容使用normal，避免HTML缩进导致的空格问题 */
.prose p,
.prose li,
.prose span,
.prose div,
.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
    white-space: normal;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
    font-weight: 600;
    margin: 1.5rem 0 1rem 0;
    color: #111827;
}

.prose h1 {
    font-size: clamp(1.5rem, 4vw, 2rem);
}

.prose h2 {
    font-size: clamp(1.375rem, 3.5vw, 1.75rem);
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 0.5rem;
}

.prose h3 {
    font-size: clamp(1.25rem, 3vw, 1.5rem);
}

.prose h4 {
    font-size: clamp(1.125rem, 2.8vw, 1.25rem);
}

.prose p {
    margin: 1rem 0;
}

.prose img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.5rem auto;
    border-radius: 0.375rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.prose img:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transition: box-shadow 0.3s ease;
}

.prose a {
    color: #2563eb;
    text-decoration: underline;
}

.prose a:hover {
    color: #1d4ed8;
}

.prose ul,
.prose ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.prose li {
    margin: 0.5rem 0;
}

.prose blockquote {
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    background-color: #f3f4f6;
    border-left: 4px solid #2563eb;
    border-radius: 0.375rem;
    font-style: italic;
    color: #4b5563;
}

.prose code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    background-color: #f3f4f6;
    padding: 0.2rem 0.4rem;
    border-radius: 0.375rem;
    font-size: 0.9em;
}

.prose pre {
    background-color: #1f2937;
    color: #f9fafb;
    padding: 1rem;
    border-radius: 0.375rem;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.prose pre code {
    background-color: transparent;
    color: inherit;
    padding: 0;
    border-radius: 0;
}

.prose hr {
    margin: 2rem 0;
    border: none;
    border-top: 1px solid #e5e7eb;
}
