/* === Reset & Base === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', 'Noto Sans SC', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container { max-width: 1280px; margin: 0 auto; padding: 0 32px; }

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent); }

/* === Navigation === */
.navbar {
    background: var(--bg-nav);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px);
}

.nav-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 32px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text) !important;
}

.logo-icon { font-size: 1.5rem; }
.nav-logo-img { height: 32px; width: auto; border-radius: 6px; }

.nav-links {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}

.nav-link:hover {
    color: var(--text);
    background: var(--primary-glow);
}

.nav-admin {
    background: var(--primary-glow);
    color: var(--primary);
    border: 1px solid rgba(108, 92, 231, 0.3);
}
.nav-admin:hover { background: var(--primary); color: white; }

/* === 用户下拉菜单 === */
.user-dropdown {
    position: relative;
}

.user-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 6px;
    border-radius: var(--radius-sm);
    background: var(--primary-glow);
    border: 1px solid rgba(108, 92, 231, 0.3);
    cursor: pointer;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    font-family: inherit;
}

.user-dropdown-trigger:hover {
    border-color: var(--primary);
}

.user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
}

.user-avatar-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.user-name {
    color: var(--primary);
    font-weight: 600;
}

.dropdown-arrow {
    transition: transform 0.3s ease;
}

.user-dropdown:hover .dropdown-arrow {
    transform: rotate(180deg);
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 160px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all 0.2s ease;
    z-index: 200;
    overflow: hidden;
}

.user-dropdown:hover .user-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text);
    font-size: 0.88rem;
    transition: var(--transition);
}

.dropdown-item:hover {
    background: var(--primary-glow);
    color: var(--primary);
}

.dropdown-icon {
    font-size: 0.95rem;
    line-height: 1;
}

.dropdown-logout:hover {
    color: var(--error);
    background: rgba(248, 113, 113, 0.08);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .user-dropdown {
        width: 100%;
    }
    .user-dropdown-trigger {
        width: 100%;
        justify-content: center;
        padding: 10px 16px;
    }
    .user-dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border: none;
        border-radius: 0;
        background: transparent;
        margin-top: 4px;
    }
    .dropdown-item {
        padding: 10px 24px;
        justify-content: center;
    }
}

.mobile-menu-btn {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}
.mobile-menu-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: var(--transition);
}

/* === Flash Messages === */
.flash-container {
    position: fixed;
    top: 72px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 90%;
    max-width: 520px;
}

.flash-message {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    animation: slideDown 0.3s ease;
    border: 1px solid;
}

.flash-success { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }
.flash-error { background: rgba(255, 71, 87, 0.1); border-color: var(--error); color: var(--error); }

.flash-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 4px;
    opacity: 0.6;
}
.flash-close:hover { opacity: 1; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Hero === */
.hero {
    text-align: center;
    padding: 80px 0 48px;
}

.hero-title {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
}
.hero-link {
    text-decoration: none;
}
.hero-link:hover .hero-title {
    opacity: 0.85;
}
.hero-cta {
    display: inline-block;
    margin-top: 16px;
    padding: 10px 24px;
    background: var(--primary-glow);
    color: var(--primary) !important;
    border: 1px solid rgba(108, 92, 231, 0.3);
    border-radius: 8px;
    font-weight: 500;
    transition: 0.3s;
}
.hero-cta:hover {
    background: var(--primary);
    color: white !important;
    transform: translateY(-1px);
}

.hero-subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* === Posts Grid === */
.posts-section { padding-bottom: 60px; }

.posts-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.post-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: var(--transition);
}

.post-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px var(--primary-glow);
}

.post-card-body { padding: 20px; }

.post-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.post-date {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.post-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.post-tag {
    display: inline-block;
    padding: 3px 10px;
    background: var(--primary-glow);
    color: var(--primary);
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
    transition: var(--transition);
}
.post-tag:hover { background: var(--primary); color: white; }

.post-title {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 10px;
    line-height: 1.4;
}

.post-title a { color: var(--text) !important; }
.post-title a:hover { color: var(--primary) !important; }

.post-summary {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 16px;
}

.read-more {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--primary);
}

/* === Pagination === */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 40px;
}

.page-link {
    padding: 10px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-weight: 500;
    transition: var(--transition);
}
.page-link:hover { border-color: var(--primary); background: var(--primary-glow); }

.page-info { color: var(--text-muted); font-size: 0.9rem; }

/* === Post Detail === */
.post-detail { padding: 48px 0; }

.post-header { margin-bottom: 40px; }

.post-detail-title {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 16px;
}

.post-meta-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
    flex-wrap: wrap;
}

.post-content { line-height: 1.8; }

/* Markdown Body */
.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    margin-top: 32px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.4;
}
.markdown-body h1 { font-size: 1.8rem; }
.markdown-body h2 { font-size: 1.5rem; }
.markdown-body h3 { font-size: 1.25rem; }

.markdown-body p { margin-bottom: 16px; }

.markdown-body ul, .markdown-body ol {
    margin-bottom: 16px;
    padding-left: 24px;
}

.markdown-body li { margin-bottom: 6px; }

.markdown-body blockquote {
    border-left: 3px solid var(--primary);
    padding: 12px 20px;
    margin: 20px 0;
    background: var(--primary-glow);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.markdown-body code {
    background: var(--bg-card);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.9em;
    color: var(--accent);
}

.markdown-body pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    overflow-x: auto;
    margin: 20px 0;
}

.markdown-body pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.markdown-body a { color: var(--accent); text-decoration: underline; }

/* Code block header */
.markdown-body pre { position: relative; }

/* === Back Link === */
.post-nav {
    padding-bottom: 60px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-weight: 500;
    transition: var(--transition);
}
.back-link:hover { color: var(--primary); }

/* === Auth Page === */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 70vh;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-icon { font-size: 2.5rem; display: block; margin-bottom: 12px; }
.auth-logo-img {
    height: 64px;
    width: auto;
    border-radius: 12px;
}

.auth-header h2 {
    font-size: 1.4rem;
    font-weight: 600;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-muted);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.auth-hint {
    text-align: center;
    margin-top: 20px;
    color: var(--text-muted);
    font-size: 0.82rem;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary); filter: brightness(1.15); transform: translateY(-1px); }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-glow); }

.btn-danger {
    background: transparent;
    border: 1px solid rgba(255, 71, 87, 0.3);
    color: var(--error);
}
.btn-danger:hover { background: rgba(255, 71, 87, 0.1); }

.btn-sm { padding: 8px 16px; font-size: 0.85rem; }

.btn-block { width: 100%; }

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 {
    font-size: 1.3rem;
    margin-bottom: 8px;
}
.empty-state p { color: var(--text-muted); margin-bottom: 20px; }

/* === About Page === */
.about-page {
    padding: 60px 0;
}
.about-page h1 {
    font-size: 2rem;
    margin-bottom: 24px;
}

.about-content { max-width: 860px; }

/* === Footer === */
.footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding: 24px 0;
}

.footer-content {
    display: flex;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* === Responsive === */
@media (max-width: 640px) {
    .hero { padding: 48px 0 32px; }
    .hero-title { font-size: 2rem; }
    .nav-links { display: none; }
    .mobile-menu-btn { display: flex; }
    .nav-links.open { display: flex; flex-direction: column; position: absolute; top: 60px; left: 0; right: 0; background: var(--bg-nav); border-bottom: 1px solid var(--border); padding: 12px 24px; }
    .post-detail-title { font-size: 1.6rem; }
    .stats-grid { grid-template-columns: 1fr; }
}
