/* ══════════════════════════════════════════
   博客系统 — 全局样式
   ══════════════════════════════════════════ */

/* ── CSS 变量 ── */
:root {
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: #eef2ff;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --bg: #f5f7fb;
    --surface: #ffffff;
    --border: #e5e7eb;
    --text: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --nav-height: 60px;
}

/* ── 全局基础 ── */
* { box-sizing: border-box; }

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

@media (min-width: 768px) {
    html { font-size: 16px; }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--bg);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 页面淡入动画 */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

main .container > * {
    animation: fadeInUp 0.4s ease-out;
}

/* ── 导航栏 ── */
.navbar {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #a855f7 100%) !important;
    box-shadow: 0 2px 20px rgba(79, 70, 229, 0.3);
    padding: 0;
    min-height: var(--nav-height);
    border: none !important;
}

.navbar .container {
    min-height: var(--nav-height);
}

.navbar-brand {
    font-weight: 700 !important;
    font-size: 1.25rem !important;
    color: #fff !important;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-brand::before {
    content: "✦";
    font-size: 1.1rem;
    opacity: 0.9;
}

.navbar .nav-link {
    color: rgba(255,255,255,0.85) !important;
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    border-radius: 8px;
    transition: all var(--transition);
    margin: 0 2px;
}

.navbar .nav-link:hover,
.navbar .nav-link.active {
    color: #fff !important;
    background: rgba(255,255,255,0.15);
}

.navbar-toggler {
    border-color: rgba(255,255,255,0.3);
    padding: 4px 8px;
}

.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.9%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* ── 主内容区 ── */
main {
    flex: 1;
    padding-top: 2rem;
    padding-bottom: 3.5rem;
}

/* ── 卡片通用 ── */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: var(--surface);
    transition: all var(--transition);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    padding: 0.85rem 1.25rem;
}

/* ── 按钮 ── */
.btn {
    border-radius: 8px;
    font-weight: 500;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    border: none;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-hover), #4338ca);
    border: none;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
    transform: translateY(-1px);
}

.btn-outline-primary {
    color: var(--accent);
    border-color: var(--accent);
    border-width: 1.5px;
}

.btn-outline-primary:hover {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.btn-outline-secondary {
    border-width: 1.5px;
}

.btn-sm {
    padding: 0.3rem 0.8rem;
    font-size: 0.82rem;
    border-radius: 6px;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border: none;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    border: none;
}

.btn-success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border: none;
}

.btn-success:hover {
    background: linear-gradient(135deg, #16a34a, #15803d);
    border: none;
}

/* ── 表单 ── */
.form-control,
.form-select {
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 0.55rem 0.85rem;
    transition: all var(--transition);
    font-size: 0.95rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 0.35rem;
}

/* ── 分页器 ── */
.pagination {
    gap: 4px;
}

.pagination .page-link {
    color: var(--accent);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 0.45rem 0.85rem;
    font-weight: 500;
    transition: all var(--transition);
}

.pagination .page-item.active .page-link {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.pagination .page-link:hover:not(.active) {
    background: var(--accent-light);
    color: var(--accent-hover);
    border-color: var(--accent);
}

.pagination .page-item.disabled .page-link {
    opacity: 0.5;
}

/* ── Badge ── */
.badge {
    font-weight: 500;
    padding: 0.35em 0.7em;
    border-radius: 6px;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
}

/* ── 文章卡片 ── */
.article-card {
    border: 1px solid var(--border);
    border-left: 4px solid transparent;
    transition: all var(--transition);
    position: relative;
}

.article-card:hover {
    border-left-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateX(3px);
}

.article-card .card-title {
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1.4;
}

.article-card .card-title a {
    color: var(--text) !important;
    transition: color var(--transition);
    text-decoration: none !important;
}

.article-card .card-title a:hover {
    color: var(--accent) !important;
}

.article-card .card-text {
    font-size: 0.92rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

/* ── 首页侧边栏 ── */
.sidebar-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: sticky;
    top: 80px;
}

.sidebar-card .card-header {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #fff;
    font-weight: 600;
    padding: 0.85rem 1.25rem;
    border: none;
}

.sidebar-card .card-header h5 {
    margin: 0;
    font-size: 0.95rem;
}

.sidebar-card .list-group-item {
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 0.65rem 1.25rem;
    font-size: 0.92rem;
    transition: all var(--transition);
    color: var(--text);
}

.sidebar-card .list-group-item:last-child {
    border-bottom: none;
}

.sidebar-card .list-group-item:hover {
    background: var(--accent-light);
    color: var(--accent);
    padding-left: 1.5rem;
}

.sidebar-card .list-group-item.active {
    background: var(--accent);
    color: #fff;
    font-weight: 500;
    border-color: var(--accent);
}

/* ── 首页标题区 ── */
.page-header {
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

/* ── 文章详情 ── */
.article-detail .card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.article-detail .card-title {
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1.35;
    color: var(--text);
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.article-meta .meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--bg);
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
}

.article-meta .meta-item i {
    font-size: 0.8rem;
}

/* ── 管理员回复卡片 ── */
.admin-reply-card {
    border: none;
    border-left: 4px solid #22c55e;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.admin-reply-card .card-body {
    padding: 1.25rem 1.5rem;
}

.admin-reply-card .card-title {
    color: #166534;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.admin-reply-card .card-title::before {
    content: "💬";
}

/* ── 评论区 ── */
.comment-section {
    margin-top: 3rem;
}

.comment-section-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 1.5rem;
}

.comment-section-title .comment-count {
    background: var(--accent);
    color: #fff;
    font-size: 0.8rem;
    padding: 0.15em 0.55em;
    border-radius: 20px;
    font-weight: 600;
}

/* 评论表单 */
.comment-form-card {
    background: var(--bg);
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
}

.comment-form-card .card-body {
    padding: 1.5rem;
}

.comment-form-card .card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1rem;
}

/* 验证码区域 */
.captcha-group {
    display: flex;
    align-items: stretch;
    gap: 0;
    max-width: 320px;
}

.captcha-group .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    letter-spacing: 0.15em;
    font-weight: 600;
    font-size: 1.05rem;
    text-transform: uppercase;
}

.captcha-group .captcha-img {
    height: 42px;
    cursor: pointer;
    border: 1.5px solid var(--border);
    border-left: none;
    border-radius: 0 8px 8px 0;
    transition: opacity var(--transition);
}

.captcha-group .captcha-img:hover {
    opacity: 0.85;
}

/* 评论卡片（时间线风格） */
.comment-item {
    position: relative;
    padding-left: 2.5rem;
    margin-bottom: 1.5rem;
}

.comment-item::before {
    content: "";
    position: absolute;
    left: 16px;
    top: 40px;
    bottom: -1.5rem;
    width: 2px;
    background: var(--border);
}

.comment-item:last-child::before {
    display: none;
}

.comment-item .comment-dot {
    position: absolute;
    left: 10px;
    top: 14px;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border: 3px solid var(--surface);
    border-radius: 50%;
    box-shadow: var(--shadow-xs);
    z-index: 1;
}

.comment-item .comment-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    transition: all var(--transition);
}

.comment-item .comment-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--accent);
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}

.comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.25);
}

.comment-meta strong {
    font-size: 0.92rem;
    color: var(--text);
}

.comment-meta .comment-time {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.comment-body {
    font-size: 0.93rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

/* ── 回到顶部 ── */
#backToTop {
    position: fixed;
    bottom: 32px;
    right: 32px;
    display: none;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
    z-index: 1000;
    transition: all var(--transition);
    opacity: 0;
    transform: translateY(10px);
}

#backToTop.visible {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
    transform: translateY(0);
}

#backToTop:hover {
    opacity: 1;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

#backToTop svg {
    width: 20px;
    height: 20px;
}

/* ── 页脚 ── */
footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.82rem;
    padding: 1.5rem 0;
    flex-shrink: 0;
}

footer a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition);
}

footer a:hover {
    color: var(--accent);
}

.beian-icon {
    vertical-align: middle;
    margin: 0 2px 0 6px;
    opacity: 0.5;
}

/* ── Alert ── */
.alert {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    padding: 0.85rem 1.15rem;
    font-size: 0.92rem;
}

.alert-success {
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
    color: #166534;
    border-left: 4px solid #22c55e;
}

.alert-danger {
    background: linear-gradient(135deg, #fef2f2, #fef2f2);
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

.alert-info {
    background: linear-gradient(135deg, #eff6ff, #f0f9ff);
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}

.alert-warning {
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    color: #92400e;
    border-left: 4px solid #f59e0b;
}

/* ── Breadcrumb ── */
.breadcrumb {
    background: transparent;
    padding: 0;
    font-size: 0.88rem;
    margin-bottom: 1.25rem;
}

.breadcrumb-item a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}

.breadcrumb-item a:hover {
    color: var(--accent-hover);
}

.breadcrumb-item.active {
    color: var(--text-muted);
}

/* ── 管理后台 ── */
.admin-toolbar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.admin-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.admin-page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.admin-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
}

.admin-card:hover {
    box-shadow: var(--shadow);
}

.admin-card .card-title {
    font-weight: 600;
}

/* ── 登录页 ── */
.login-card {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.login-card .card-body {
    padding: 2.5rem;
}

.login-card .login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-card .login-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}

.login-card .login-icon svg {
    width: 28px;
    height: 28px;
    color: #fff;
}

.login-card h3 {
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.login-card .d-grid .btn {
    padding: 0.7rem;
    font-size: 1rem;
    font-weight: 600;
}

/* ── 表格 ── */
.table {
    font-size: 0.92rem;
}

.table thead th {
    background: var(--bg);
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.75rem 1rem;
}

.table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-color: var(--border);
}

.table-hover tbody tr:hover {
    background: var(--accent-light);
}

/* ── 空状态 ── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 1rem;
    margin: 0;
}

/* ── Markdown 内容 ── */
.markdown-content {
    line-height: 1.85;
    font-size: 1.02rem;
    color: var(--text);
}

.markdown-content h1, .markdown-content h2, .markdown-content h3,
.markdown-content h4, .markdown-content h5, .markdown-content h6 {
    margin-top: 1.8rem;
    margin-bottom: 1rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text);
}

.markdown-content h1 { font-size: 1.8rem; border-bottom: 2px solid var(--border); padding-bottom: 0.5rem; }
.markdown-content h2 { font-size: 1.45rem; }
.markdown-content h3 { font-size: 1.25rem; }
.markdown-content h4 { font-size: 1.1rem; }

.markdown-content p { margin-bottom: 1rem; }

.markdown-content :not(pre) > code {
    background: #f1f5f9;
    padding: 0.15em 0.45em;
    border-radius: 5px;
    font-size: 0.88em;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Monaco', monospace;
    color: #e11d48;
    border: 1px solid #e5e7eb;
}

.markdown-content pre {
    padding: 1.2rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 1rem 0;
    border: 1px solid #2d3748;
}

.markdown-content pre code {
    font-size: 0.88rem;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Monaco', monospace;
}

.markdown-content blockquote {
    border-left: 4px solid var(--accent);
    padding: 0.75rem 1.25rem;
    color: var(--text-secondary);
    margin: 1rem 0;
    background: var(--accent-light);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.markdown-content ul, .markdown-content ol {
    margin-bottom: 1rem;
    padding-left: 1.8rem;
}

.markdown-content li { margin-bottom: 0.35rem; }

.markdown-content a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--transition);
}

.markdown-content a:hover {
    border-bottom-color: var(--accent);
}

.markdown-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    margin: 0.5rem 0;
    box-shadow: var(--shadow);
}

.markdown-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
    font-size: 0.95rem;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.markdown-content table th,
.markdown-content table td {
    border: 1px solid var(--border);
    padding: 0.6rem 0.85rem;
    text-align: left;
}

.markdown-content table th {
    background: var(--bg);
    font-weight: 600;
}

.markdown-content table tr:nth-child(even) td {
    background: #fafafa;
}

/* ── 响应式 ── */
@media (max-width: 767px) {
    main {
        padding-top: 1rem;
        padding-bottom: 2rem;
    }

    .navbar-brand {
        font-size: 1.1rem !important;
    }

    .article-detail .card-title {
        font-size: 1.35rem;
    }

    .admin-page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .comment-item {
        padding-left: 2rem;
    }

    .comment-item::before {
        left: 12px;
    }

    .comment-item .comment-dot {
        left: 6px;
    }

    #backToTop {
        bottom: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
    }

    .captcha-group {
        max-width: 100%;
    }

    .sidebar-card {
        position: static;
    }
}

/* ── 滚动条美化 ── */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ── 选中文本颜色 ── */
::selection {
    background: rgba(99, 102, 241, 0.2);
    color: var(--text);
}
