/* ==================== 基础样式 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #6b7280;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f9fafb;
    --card-bg: #ffffff;
    --text: #1f2937;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

a:hover {
    color: var(--primary-light);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ==================== 导航栏 ==================== */
.navbar {
    background: var(--card-bg);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .container {
    display: flex;
    align-items: center;
    height: 60px;
    gap: 30px;
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
}

.nav-links {
    display: flex;
    gap: 20px;
    flex: 1;
}

.nav-links a {
    color: var(--text);
    font-size: 0.95rem;
    padding: 6px 0;
    border-bottom: 2px solid transparent;
}

.nav-links a.active, .nav-links a:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
}

/* ==================== 徽章 ==================== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-official {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: #fff;
}

/* ==================== 按钮 ==================== */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-light);
    color: #fff;
}

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: #d1d5db;
}

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

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

/* ==================== 表单 ==================== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group input[type="number"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group small {
    display: block;
    margin-top: 4px;
    color: var(--text-light);
    font-size: 0.8rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* ==================== 主页布局 ==================== */
.main-content {
    flex: 1;
    padding: 24px 0;
}

.home-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 24px;
}

/* 公告区 */
.announcement-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.announcement-section h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.announcement-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.announcement-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--border);
}

.announcement-item:last-child {
    border-bottom: none;
}

.ann-type {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.type-notice { background: #dbeafe; color: #1e40af; }
.type-activity { background: #dcfce7; color: #166534; }
.type-policy { background: #fef3c7; color: #92400e; }

.ann-title {
    flex: 1;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ann-author {
    font-size: 0.8rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 4px;
}

.ann-time {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* 分类标签 */
.category-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--card-bg);
    padding: 6px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.tab {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text);
    transition: all 0.2s;
}

.tab.active, .tab:hover {
    background: var(--primary);
    color: #fff;
}

/* 帖子卡片 */
.post-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.post-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    position: relative;
    transition: transform 0.2s;
}

.post-card:hover {
    transform: translateY(-2px);
}

.post-card.pinned {
    border-left: 3px solid var(--warning);
}

.pin-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--warning);
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
}

.post-header {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.post-category {
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.cat-study { background: #dbeafe; color: #1e40af; }
.cat-life { background: #dcfce7; color: #166534; }
.cat-lost_found { background: #fef3c7; color: #92400e; }

.post-title {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.post-title a {
    color: var(--text);
}

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

.post-excerpt {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 12px;
    line-height: 1.5;
}

.post-images {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.post-thumb {
    width: 100px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.85rem;
    color: var(--text-light);
}

.post-stats {
    display: flex;
    gap: 12px;
    margin-left: auto;
}

/* 侧边栏 */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.widget {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
}

.widget h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.quick-links {
    list-style: none;
}

.quick-links li {
    margin-bottom: 8px;
}

.quick-links a {
    color: var(--text);
    font-size: 0.9rem;
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    padding: 4px 12px;
    background: var(--bg);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-light);
}

.tag:hover {
    background: var(--primary);
    color: #fff;
}

/* ==================== 发布页 ==================== */
.publish-page {
    max-width: 700px;
    margin: 0 auto;
}

.publish-page h1 {
    margin-bottom: 24px;
}

.type-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.type-card {
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.type-card:hover {
    border-color: var(--primary-light);
}

.type-card.selected {
    border-color: var(--primary);
    background: #f0f0ff;
}

.type-icon {
    display: block;
    font-size: 2rem;
    margin-bottom: 8px;
}

.type-name {
    font-size: 0.9rem;
    font-weight: 500;
}

.publish-form {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.image-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
    position: relative;
}

.image-upload:hover {
    border-color: var(--primary);
}

.image-upload input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-hint span {
    display: block;
    font-size: 1rem;
    color: var(--text-light);
    margin-bottom: 4px;
}

.upload-hint small {
    font-size: 0.8rem;
    color: var(--text-light);
}

.image-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.preview-item {
    position: relative;
    width: 80px;
    height: 80px;
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.remove-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--danger);
    color: #fff;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    cursor: pointer;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}

/* ==================== 详情页 ==================== */
.post-detail {
    max-width: 800px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: var(--shadow);
}

.post-detail-header {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.post-detail-title {
    font-size: 1.6rem;
    margin-bottom: 12px;
}

.post-detail-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.post-detail-content {
    font-size: 1rem;
    line-height: 1.8;
    margin-bottom: 24px;
}

.post-detail-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.detail-image {
    width: 100%;
    border-radius: var(--radius);
    cursor: pointer;
}

.post-actions {
    display: flex;
    gap: 12px;
    padding: 16px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.action-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--bg);
}

/* 招领信息 */
.lost-found-info {
    background: #fefce8;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
}

.lost-found-info h3 {
    margin-bottom: 12px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.info-item label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 2px;
}

.claim-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #fde68a;
}

.claim-status {
    margin-top: 16px;
    padding: 12px;
    border-radius: var(--radius);
    text-align: center;
}

.claim-status.pending { background: #fef3c7; }
.claim-status.claimed { background: #dcfce7; }

/* 资料区 */
.resources-section {
    margin-bottom: 24px;
}

.resources-section h3 {
    margin-bottom: 12px;
}

.resource-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.resource-icon {
    font-size: 1.5rem;
}

.resource-info {
    flex: 1;
}

.resource-name {
    display: block;
    font-weight: 500;
}

.resource-meta {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* 评论区 */
.comments-section h3 {
    margin-bottom: 16px;
}

.comment-form {
    margin-bottom: 24px;
}

.comment-form textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    resize: vertical;
    margin-bottom: 8px;
}

.comment-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.comment-item {
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius);
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.comment-author {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

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

.comment-content {
    font-size: 0.95rem;
    line-height: 1.6;
}

.comment-actions {
    margin-top: 8px;
}

.action-link {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 0.85rem;
}

.reply-item {
    margin-top: 12px;
    margin-left: 20px;
    padding: 12px;
    background: var(--card-bg);
    border-radius: var(--radius);
    border-left: 2px solid var(--primary-light);
}

/* 图片灯箱 */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.lightbox.active {
    display: flex;
}

.lightbox img {
    max-width: 90%;
    max-height: 90%;
    border-radius: var(--radius);
}

/* ==================== 认证页 ==================== */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

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

.auth-card h2 {
    text-align: center;
    margin-bottom: 24px;
}

.auth-link {
    text-align: center;
    margin-top: 16px;
    font-size: 0.9rem;
    color: var(--text-light);
}

/* ==================== 失物招领列表 ==================== */
.lost-found-page h1 {
    margin-bottom: 20px;
}

.lost-found-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.lf-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.lf-card-header {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.lf-type {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.lf-type.type-lost { background: #fee2e2; color: #991b1b; }
.lf-type.type-found { background: #dcfce7; color: #166534; }

.lf-title {
    font-size: 1rem;
    margin-bottom: 8px;
}

.lf-desc {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 8px;
}

.lf-meta {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 8px;
}

.lf-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-light);
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.expired-badge {
    background: var(--danger);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
}

/* ==================== 公告列表 ==================== */
.announcements-page h1 {
    margin-bottom: 20px;
}

.announcement-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ann-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.ann-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.ann-card-title {
    font-size: 1.2rem;
    margin-bottom: 12px;
}

.ann-card-content {
    color: var(--text);
    line-height: 1.7;
    margin-bottom: 16px;
}

.ann-card-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-light);
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

/* ==================== 管理后台 ==================== */
.admin-page h1 {
    margin-bottom: 24px;
}

.admin-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.admin-section h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.admin-form {
    margin-bottom: 16px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

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

.admin-table .actions {
    display: flex;
    gap: 6px;
}

.status {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.status-approved { background: #dcfce7; color: #166534; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-rejected { background: #fee2e2; color: #991b1b; }

/* ==================== 分页 ==================== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 24px;
}

.pagination a, .pagination span {
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text);
}

.pagination a.active {
    background: var(--primary);
    color: #fff;
}

.pagination a:hover:not(.active) {
    background: var(--border);
}

/* ==================== 提示框 ==================== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }

/* ==================== 空状态 ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-comments {
    text-align: center;
    padding: 30px;
    color: var(--text-light);
}

.login-hint {
    text-align: center;
    padding: 20px;
    color: var(--text-light);
}

/* ==================== 错误页 ==================== */
.error-page {
    text-align: center;
    padding: 80px 20px;
}

.error-page h1 {
    font-size: 5rem;
    color: var(--primary);
    margin-bottom: 12px;
}

.error-page p {
    font-size: 1.2rem;
    color: var(--text-light);
    margin-bottom: 24px;
}

/* ==================== 底部 ==================== */
.footer {
    background: var(--card-bg);
    text-align: center;
    padding: 20px;
    color: var(--text-light);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
}

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
    .navbar .container {
        flex-wrap: wrap;
        height: auto;
        padding: 10px 16px;
    }
    
    .nav-links {
        order: 3;
        width: 100%;
        overflow-x: auto;
        gap: 12px;
        padding-top: 8px;
    }
    
    .home-layout {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        order: -1;
    }
    
    .type-selector {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .lost-found-list {
        grid-template-columns: 1fr;
    }
    
    .post-detail {
        padding: 16px;
    }
    
    .post-detail-title {
        font-size: 1.3rem;
    }
}

/* ==================== 弹窗 ==================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-card h3 {
    margin-bottom: 16px;
    font-size: 1.2rem;
}

.btn-warning {
    background: var(--warning);
    color: #fff;
}

.btn-warning:hover {
    background: #d97706;
    color: #fff;
}

/* 标签选择器 */
.tag-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-checkbox {
    cursor: pointer;
}

.tag-checkbox input {
    display: none;
}

.tag-label {
    display: inline-block;
    padding: 4px 12px;
    border: 2px solid;
    border-radius: 20px;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.tag-checkbox input:checked + .tag-label {
    background: currentColor;
    color: #fff !important;
}
