/* ============================================================
   知识库系统 - 自定义样式
   ============================================================ */

/* CSS Variables */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-shadow: 0 2px 12px rgba(0,0,0,.08);
    --card-hover-shadow: 0 5px 20px rgba(0,0,0,.12);
    --border-radius: 12px;
}

/* Base */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #f8f9fc;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main { flex: 1; }

/* Typography */
h1, h2, h3, h4, h5, h6 { letter-spacing: 0.3px; }

a { transition: color .2s; }

/* Navigation */
.navbar { box-shadow: 0 2px 10px rgba(0,0,0,.1); }
.navbar .nav-link { font-size: .92rem; padding: .6rem 1rem; border-radius: 6px; transition: all .2s; }
.navbar .nav-link:hover { background: rgba(255,255,255,.08); }

/* Hero Section */
.hero-section {
    background: var(--primary-gradient);
    position: relative;
    overflow: hidden;
}
.hero-section::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,.05) 1px, transparent 1px);
    background-size: 30px 30px;
    pointer-events: none;
}

/* Cards */
.card {
    border-radius: var(--border-radius);
    transition: all .3s ease;
}
.card:hover {
    box-shadow: var(--card-hover-shadow);
}

.book-card {
    transition: all .3s ease;
    overflow: hidden;
}
.book-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-hover-shadow);
}
.book-card .card-img-top {
    height: 180px;
    object-fit: cover;
}
.book-card-hover:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-hover-shadow);
}

.category-card {
    transition: all .3s ease;
    border: 2px solid transparent !important;
}
.category-card:hover {
    transform: translateY(-3px);
    border-color: var(--bs-primary) !important;
    box-shadow: var(--card-hover-shadow);
}
.category-card:hover .bi {
    color: var(--bs-primary) !important;
}

/* Badges */
.badge { font-weight: 500; letter-spacing: .3px; }

/* Buttons */
.btn {
    border-radius: 8px;
    font-weight: 500;
    transition: all .2s;
}
.btn-lg { border-radius: 10px; }

/* Forms */
.form-control, .form-select {
    border-radius: 8px;
    border-color: #e0e0e0;
    transition: border-color .2s, box-shadow .2s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, .15);
}
.form-control-lg { border-radius: 10px; }

/* Tables */
.table th { font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .5px; }
.table td { vertical-align: middle; }

/* Alerts */
.alert { border-radius: 10px; border: none; }

/* Pagination */
.page-link {
    border-radius: 8px !important;
    margin: 0 2px;
    border: none;
    color: var(--bs-primary);
}
.page-item.active .page-link {
    background: var(--bs-primary);
}
.page-item.disabled .page-link {
    background: transparent;
}

/* Markdown Content */
.book-content {
    line-height: 1.8;
    font-size: 1.05rem;
    color: #2c3e50;
}
.book-content h1 { font-size: 2rem; margin-top: 2rem; margin-bottom: 1rem; border-bottom: 2px solid #f0f0f0; padding-bottom: .5rem; }
.book-content h2 { font-size: 1.6rem; margin-top: 1.8rem; margin-bottom: .8rem; }
.book-content h3 { font-size: 1.35rem; margin-top: 1.5rem; margin-bottom: .6rem; }
.book-content p { margin-bottom: 1.2rem; }
.book-content img { max-width: 100%; border-radius: 8px; margin: 1.5rem 0; box-shadow: 0 2px 12px rgba(0,0,0,.1); }
.book-content blockquote {
    border-left: 4px solid var(--bs-primary);
    padding: .8rem 1.2rem;
    margin: 1.2rem 0;
    background: #f8f9fa;
    border-radius: 0 8px 8px 0;
    color: #555;
}
.book-content pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 1.2rem 1.5rem;
    border-radius: 10px;
    overflow-x: auto;
    margin: 1.2rem 0;
    font-size: .9rem;
    line-height: 1.6;
}
.book-content code {
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: .88em;
    color: #e74c3c;
}
.book-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}
.book-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.2rem 0;
    border-radius: 8px;
    overflow: hidden;
}
.book-content th, .book-content td {
    border: 1px solid #e0e0e0;
    padding: 10px 14px;
}
.book-content th {
    background: #f8f9fa;
    font-weight: 600;
}
.book-content ul, .book-content ol {
    margin-bottom: 1.2rem;
    padding-left: 1.5rem;
}
.book-content ul li, .book-content ol li { margin-bottom: .4rem; }
.book-content hr { margin: 2rem 0; opacity: .2; }

/* Tag Cloud */
.tag-cloud a { transition: all .2s; }
.tag-cloud a:hover { background: var(--bs-primary) !important; color: #fff !important; }

/* List group */
.list-group-item { transition: background .15s; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* Footer */
.footer { margin-top: auto; }
.footer a { color: #6c757d; transition: color .2s; }
.footer a:hover { color: var(--bs-primary); }

/* Responsive */
@media (max-width: 768px) {
    .hero-section { padding: 2rem !important; }
    .hero-section h1 { font-size: 1.8rem; }
    .book-content { font-size: .95rem; }
}

/* Print */
@media print {
    .navbar, .footer, .btn, .admin-sidebar, .d-print-none { display: none !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd; }
    .container { max-width: 100% !important; width: 100% !important; }
}

/* Loading spinner */
.spinner-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* File format colors */
.format-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: .78rem; font-weight: 500; }

/* Gradient backgrounds */
.bg-gradient-primary { background: var(--primary-gradient); }
.bg-gradient-success { background: linear-gradient(135deg, #11998e, #38ef7d); }
.bg-gradient-info { background: linear-gradient(135deg, #396afc, #2948ff); }
.bg-gradient-warning { background: linear-gradient(135deg, #f093fb, #f5576c); }

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in { animation: fadeInUp .4s ease; }

/* Empty states */
.empty-state { padding: 4rem 2rem; text-align: center; }

/* EasyMDE Overrides */
.editor-toolbar { border-color: #e0e0e0 !important; }
.editor-toolbar button { border-radius: 4px !important; }
.editor-toolbar button.active, .editor-toolbar button:hover { border-color: var(--bs-primary) !important; background: rgba(102, 126, 234, .1) !important; }
.CodeMirror { border-color: #e0e0e0 !important; font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace !important; }
.CodeMirror-focused { border-color: var(--bs-primary) !important; box-shadow: 0 0 0 3px rgba(102, 126, 234, .15); }

/* Admin chart container */
canvas { max-height: 250px; }

/* Stats card hover effect */
.card .bg-opacity-10 { transition: all .3s; }
.card:hover .bg-opacity-10 { transform: scale(1.1); }
