/* ============================================================
   css/style.css
   必看 - 全站样式（登录页 + 主应用）
   ============================================================ */

/* ---------- 全局重置 ---------- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #667eea;
    --primary-dark: #5a6fd6;
    --primary-light: rgba(102, 126, 234, 0.1);
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --text-main: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --bg-hover: #f8fafc;
    --bg-light: #f1f5f9;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --success: #22c55e;
    --warning: #f59e0b;
    --radius: 12px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.18);
    --transition: 0.2s ease;
}

body {
    font-family: 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
    background: var(--bg-light);
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.6;
}

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

a:hover {
    text-decoration: underline;
}

button {
    cursor: pointer;
    font-family: inherit;
}

input, textarea, select {
    font-family: inherit;
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ---------- 登录/注册卡片 ---------- */
.card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    max-width: 440px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    margin: 0 auto;
}

body.login-body {
    background: var(--bg-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

h2 {
    font-weight: 600;
    font-size: 28px;
    margin-bottom: 8px;
    color: var(--text-main);
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 28px;
    font-size: 14px;
}

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

label {
    display: block;
    font-weight: 500;
    font-size: 14px;
    color: #334155;
    margin-bottom: 5px;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="search"],
textarea,
select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    outline: none;
    transition: var(--transition);
    background: white;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    border: none;
    transition: var(--transition);
    cursor: pointer;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: #e2e8f0;
    color: var(--text-main);
}
.btn-secondary:hover {
    background: #cbd5e1;
}

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

.btn-google {
    background: white;
    color: var(--text-main);
    border: 1px solid var(--border);
    gap: 10px;
}
.btn-google:hover {
    background: var(--bg-hover);
}

.btn-block {
    width: 100%;
}

.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--text-light);
    font-size: 13px;
}
.divider::before,
.divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.footer-link {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}
.footer-link a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}
.footer-link a:hover {
    text-decoration: underline;
}

.back-link {
    display: inline-block;
    margin-bottom: 20px;
    color: var(--primary);
    cursor: pointer;
    font-weight: 500;
}
.back-link:hover {
    text-decoration: underline;
}

.message {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    display: none;
}
.message.error {
    background: #fee2e2;
    color: #b91c1c;
    display: block;
}
.message.success {
    background: #dcfce7;
    color: #166534;
    display: block;
}

.hidden {
    display: none !important;
}

/* ---------- 主应用布局 ---------- */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* 侧边栏导航 */
.sidebar {
    width: 240px;                     /* 调整宽度，避免过宽挤压主内容 */
    background: white;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100vh;
}

/* 侧边栏头部：改为上下布局，居中显示 */
.sidebar-header {
    padding: 24px 16px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;           /* 垂直排列 */
    align-items: center;              /* 水平居中 */
    gap: 8px;                         /* 图标和文字间距 */
    text-align: center;
}

.sidebar-logo {
    width: 160px;                     /* 图标尺寸，平衡协调 */
    height: 109px;                    /* 160 * 680 / 1000 = 108.8，取整 */
    border-radius: 8px;
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 24px;                  /* 文字大小与图标匹配 */
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
}

/* 导航菜单容器：占据剩余空间，可滚动 */
.sidebar nav#sidebarNav {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.nav-list {
    list-style: none;
    padding: 10px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

/* 侧边栏底部用户信息：固定在底部 */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
    margin-top: auto;
    background: white;
}

.user-mini {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
}

.user-mini:hover {
    background: var(--bg-hover);
}

.avatar-sm {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.avatar-sm img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-mini-info {
    flex: 1;
    min-width: 0;
}

.user-mini-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-mini-id {
    font-size: 12px;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: var(--transition);
    display: flex;
    align-items: center;
}

.logout-btn:hover {
    background: #fee2e2;
    color: var(--danger);
}

/* 主内容区域 */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    background: var(--bg-light);
}

.page-header {
    margin-bottom: 20px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* 二级导航（标签页） */
.tab-bar {
    display: flex;
    gap: 4px;
    background: white;
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.tab-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: var(--transition);
    border: none;
    background: none;
    font-size: 14px;
}

.tab-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.tab-item:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.tab-item.active {
    background: var(--primary);
    color: white;
}

/* 卡片通用 */
.post-card,
.topic-card,
.user-card,
.notification-card,
.message-item,
.announcement-card {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    border: 1px solid transparent;
}

.post-card:hover,
.topic-card:hover,
.notification-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border);
}

/* 帖子卡片头部 */
.post-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-lg {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.avatar-lg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-user-info {
    flex: 1;
    min-width: 0;
}

.post-user-name {
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.post-user-id {
    color: var(--text-light);
    font-size: 13px;
}

.post-time {
    color: var(--text-light);
    font-size: 13px;
}

.edited-badge {
    background: var(--bg-light);
    color: var(--text-light);
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 400;
}

/* 帖子内容 */
.post-content {
    margin-bottom: 12px;
    font-size: 15px;
    word-break: break-word;
}

.post-content img,
.post-content video,
.post-content audio {
    max-width: 100%;
    border-radius: var(--radius);
    margin: 8px 0;
}

.post-media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
    margin: 8px 0;
}

.media-item {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    background: #000;
}

.media-item img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
}

.media-item.video::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: rgba(0,0,0,0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: rgba(0,0,0,0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.play-icon svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.audio-progress {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 6px;
    cursor: pointer;
}

.audio-progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    width: 0%;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-light);
    border-radius: 10px;
    margin: 6px 0;
}

.file-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 12px;
    color: var(--text-light);
}

.file-download-btn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 标签 */
.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0;
}

.tag {
    background: var(--primary-light);
    color: var(--primary);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

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

/* 帖子操作按钮 */
.post-actions {
    display: flex;
    gap: 24px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    padding: 4px 8px;
    border-radius: 6px;
}

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

.action-btn.liked {
    color: var(--danger);
}

.action-btn.favorited {
    color: var(--warning);
}

.action-btn svg {
    width: 18px;
    height: 18px;
}

/* 评论区域 */
.comments-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.comment-item {
    margin-bottom: 16px;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.comment-user {
    font-weight: 600;
    font-size: 14px;
}

.comment-reply-to {
    color: var(--text-light);
    font-size: 13px;
}

.comment-content {
    font-size: 14px;
    margin-bottom: 6px;
    word-break: break-word;
}

.comment-actions {
    display: flex;
    gap: 16px;
}

.comment-actions .action-btn {
    font-size: 13px;
}

.comment-reply-form {
    margin-top: 8px;
    margin-left: 20px;
    display: flex;
    gap: 8px;
}

.comment-reply-form input {
    flex: 1;
    padding: 8px 12px;
    font-size: 13px;
}

/* 弹窗/模态框 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 560px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
}

.modal-close {
    float: right;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
}

.modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* 通知 */
.notification-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.notification-content {
    flex: 1;
}

.notification-text {
    font-size: 14px;
    margin-bottom: 4px;
}

.notification-time {
    font-size: 12px;
    color: var(--text-light);
}

.unread-dot {
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

/* 搜索 */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.search-bar input {
    flex: 1;
}

/* 用户卡片 */
.user-card {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.user-card-actions {
    display: flex;
    gap: 6px;
}

/* 话题卡片 */
.topic-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.topic-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 8px;
}

.topic-meta {
    display: flex;
    gap: 16px;
    color: var(--text-light);
    font-size: 13px;
}

/* 公告 */
.announcement-card {
    border-left: 4px solid var(--primary);
}

.announcement-title {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 6px;
}

/* 管理员面板 */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.admin-stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.admin-stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
}

.admin-stat-label {
    color: var(--text-secondary);
    font-size: 14px;
}

/* 响应式 */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 8px;
    }
    .sidebar-header {
        display: none;
    }
    .sidebar nav#sidebarNav {
        flex: none;
        overflow-x: auto;
        display: block;
    }
    .nav-list {
        display: flex;
        flex-direction: row;
        padding: 0;
        overflow-x: auto;
    }
    .nav-item {
        white-space: nowrap;
        padding: 8px 12px;
    }
    .sidebar-footer {
        display: none;
    }
    .main-content {
        padding: 12px;
    }
    .post-actions {
        gap: 12px;
    }
}
