/* ========== 全局变量和重置 ========== */
:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-dark: #0f172a;
    --bg-darker: #020617;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--bg-darker) 0%, var(--bg-dark) 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ========== 导航栏 ========== */
.navbar {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.nav-brand a {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    transition: all 0.3s ease;
}

.nav-brand a:hover {
    color: var(--secondary-color);
    transform: scale(1.05);
}

.nav-menu {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.1);
}

.nav-link.admin {
    color: var(--warning-color);
}

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

/* ========== 容器和布局 ========== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.main-content {
    min-height: calc(100vh - 200px);
    padding: 2rem 0;
}

/* ========== Flash 消息 ========== */
.flash-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 2000;
    max-width: 400px;
}

.flash {
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.flash-success { background: var(--success-color); color: white; }
.flash-error { background: var(--danger-color); color: white; }
.flash-warning { background: var(--warning-color); color: white; }
.flash-info { background: var(--primary-color); color: white; }

.flash-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    margin-left: 1rem;
}

/* ========== 页面标题 ========== */
.page-header {
    text-align: center;
    margin-bottom: 3rem;
}

.page-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* ========== 帖子网格 ========== */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.post-card {
    background: var(--bg-card);
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.post-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.post-header {
    padding: 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    text-decoration: none;
}

.username {
    color: var(--text-primary);
    font-weight: 600;
    text-decoration: none;
    transition: color 0.3s ease;
}

.username:hover {
    color: var(--primary-color);
}

.post-time {
    color: var(--text-secondary);
    font-size: 0.875rem;
    display: block;
}

.post-image-link {
    display: block;
    position: relative;
    overflow: hidden;
}

.post-image {
    width: 100%;
    height: 300px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.post-image-link:hover .post-image {
    transform: scale(1.05);
}

.post-description {
    padding: 1rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.post-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.comment-count {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s ease;
}

.comment-count:hover {
    color: var(--primary-color);
}

/* ========== 表单样式 ========== */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 200px);
    padding: 2rem;
}

.auth-card, .create-post-card {
    background: var(--bg-card);
    border-radius: 1.5rem;
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 100%;
}

.create-post-container .create-post-card {
    max-width: 800px;
    margin: 0 auto;
}

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

.auth-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-secondary);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.required {
    color: var(--danger-color);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-dark);
    border: 2px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.form-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ========== 文件上传 ========== */
.file-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 0.75rem;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.file-upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.file-upload-area.large {
    padding: 3rem;
}

.file-input {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.file-hint {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.image-preview {
    max-width: 100%;
    max-height: 300px;
    border-radius: 0.5rem;
    margin-top: 1rem;
}

.image-preview.large {
    max-height: 500px;
}

/* ========== 按钮 ========== */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    font-size: 1rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--bg-dark);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--primary-color);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-block {
    width: 100%;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

/* ========== 信息框 ========== */
.info-box {
    background: rgba(99, 102, 241, 0.1);
    border-left: 4px solid var(--primary-color);
    padding: 1rem;
    margin: 1.5rem 0;
    border-radius: 0.5rem;
}

/* ========== 空状态 ========== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-state h2 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

/* ========== 分页 ========== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.page-link {
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.3s ease;
}

.page-link:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.page-link.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

/* ========== 帖子详情 ========== */
.post-detail-card {
    background: var(--bg-card);
    border-radius: 1.5rem;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    max-width: 800px;
    margin: 0 auto;
}

.post-detail-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.user-info-large {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
}

.user-avatar-large {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
}

.username-large {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.post-detail-image img {
    width: 100%;
    height: auto;
    display: block;
}

.post-detail-description {
    padding: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.8;
    border-bottom: 1px solid var(--border-color);
}

/* ========== 评论 ========== */
.comments-section {
    padding: 1.5rem;
}

.comments-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

.comment-form {
    margin-bottom: 2rem;
}

.comment-input {
    width: 100%;
    padding: 1rem;
    background: var(--bg-dark);
    border: 2px solid var(--border-color);
    border-radius: 0.75rem;
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 1rem;
    resize: vertical;
    min-height: 100px;
}

.comment-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.comment-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-dark);
    border-radius: 0.75rem;
}

.comment-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    text-decoration: none;
    flex-shrink: 0;
}

.comment-content {
    flex: 1;
}

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

.comment-username {
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
}

.comment-username:hover {
    color: var(--primary-color);
}

.comment-time {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.comment-text {
    color: var(--text-secondary);
    line-height: 1.6;
}

.empty-comments {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

/* ========== 个人主页 ========== */
.profile-header {
    background: var(--bg-card);
    border-radius: 1.5rem;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    gap: 2rem;
    align-items: center;
}

.profile-avatar-large {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.profile-info {
    flex: 1;
}

.profile-username {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.profile-stats {
    display: flex;
    gap: 2rem;
    margin-bottom: 1rem;
}

.stat-item {
    text-align: center;
}

.stat-item a {
    text-decoration: none;
    color: inherit;
    transition: color 0.3s ease;
}

.stat-item a:hover {
    color: var(--primary-color);
}

.stat-number {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.profile-bio {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* ========== 徽章 ========== */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.badge-success {
    background: var(--success-color);
    color: white;
}

.badge-warning {
    background: var(--warning-color);
    color: white;
}

.badge-overlay {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

/* ========== 管理面板 ========== */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
}

.stat-icon {
    font-size: 2.5rem;
}

.quick-links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.quick-link-card {
    background: var(--bg-card);
    border-radius: 1rem;
    padding: 2rem;
    text-align: center;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.quick-link-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.quick-link-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.admin-section {
    margin-bottom: 3rem;
}

.section-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.admin-list, .users-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.admin-item {
    background: var(--bg-card);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.admin-item-header {
    margin-bottom: 1rem;
}

.user-email {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.user-time {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.student-id-preview {
    margin-bottom: 1rem;
}

.student-id-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: 0.5rem;
    margin-top: 0.5rem;
}

.admin-actions {
    display: flex;
    gap: 1rem;
}

.admin-posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.admin-post-card {
    background: var(--bg-card);
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.admin-post-image {
    width: 100%;
    height: 250px;
    object-fit: cover;
}

.admin-post-info {
    padding: 1rem;
}

.admin-post-author {
    margin-bottom: 0.5rem;
}

.admin-post-author a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.admin-post-description {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.user-list-item {
    background: var(--bg-card);
    border-radius: 0.75rem;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-list-info {
    flex: 1;
}

.user-stats {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ========== 页脚 ========== */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    margin-top: 4rem;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .nav-menu {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .posts-grid {
        grid-template-columns: 1fr;
    }

    .profile-header {
        flex-direction: column;
        text-align: center;
    }

    .profile-stats {
        justify-content: center;
    }

    .admin-posts-grid {
        grid-template-columns: 1fr;
    }

    .page-header h1 {
        font-size: 2rem;
    }
}
