/* ========== 变量与基础 ========== */
:root {
    --primary: #FB7299;
    --primary-hover: #e85a82;
    --primary-light: #fff0f3;
    --bg: #f6f7f8;
    --card-bg: #ffffff;
    --text: #212529;
    --text-secondary: #6c757d;
    --border: #e9ecef;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 2px 12px rgba(0,0,0,0.04);
    --shadow-hover: 0 6px 20px rgba(0,0,0,0.08);
    --transition: all 0.2s ease;
    --max-width: 1200px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: var(--primary);
    transition: color 0.2s;
}
a:hover {
    color: var(--primary-hover);
}

img {
    max-width: 100%;
    height: auto;
}

/* ========== 按钮系统 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: filter 0.2s, background 0.2s, box-shadow 0.2s;
    gap: 6px;
    white-space: nowrap;
}
.btn:hover {
    filter: brightness(0.92);
}
.btn:active {
    filter: brightness(0.85);
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.btn-outline {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline:hover {
    background: var(--primary-light);
    filter: none;
}
.btn-sm {
    padding: 4px 12px;
    font-size: 13px;
    border-radius: 14px;
}
.btn-lg {
    padding: 12px 28px;
    font-size: 16px;
    border-radius: 24px;
}
.btn-block {
    display: block;
    width: 100%;
}
.btn-delete-red {
    background: #ff4d4f;
    color: white;
    border-color: #ff4d4f;
}
.btn-delete-red:hover {
    background: #ff7875;
    filter: none;
}

/* ========== 导航栏 ========== */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 0 24px;
    height: 60px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    max-width: 100vw;
}
.navbar-left {
    display: flex;
    align-items: center;
    gap: 32px;
    flex-wrap: wrap;
}
.logo img {
    height: 32px;
    vertical-align: middle;
}
.logo-text {
    font-size: 20px;
    font-weight: bold;
    color: var(--primary);
}
.nav-links {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}
.nav-links a {
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    padding: 4px 0;
    position: relative;
}
.nav-links a:hover {
    color: var(--primary);
}
.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary);
    transition: width 0.2s;
}
.nav-links a:hover::after {
    width: 100%;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.search-form {
    display: flex;
    align-items: center;
    background: #f1f2f3;
    border-radius: 20px;
    padding: 4px 12px;
}
.search-form input {
    border: none;
    background: transparent;
    outline: none;
    padding: 4px 8px;
    width: 180px;
    font-size: 14px;
}
.search-form button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
}

/* 用户菜单下拉 */
.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-avatar-dropdown, .create-dropdown {
    position: relative;
}
.avatar-sm {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #f0f0f0;
    cursor: pointer;
}
.dropdown-content {
    display: none;
    position: absolute;
    top: 45px;
    right: 0;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px rgba(0,0,0,0.12);
    min-width: 200px;
    z-index: 1001;
    padding: 8px 0;
    overflow: hidden;
}
.dropdown-menu a, .dropdown-menu button {
    display: block;
    width: 100%;
    padding: 10px 16px;
    text-align: left;
    background: none;
    border: none;
    color: var(--text);
    font-size: 14px;
    transition: background 0.15s;
}
.dropdown-menu a:hover, .dropdown-menu button:hover {
    background: #f8f8f8;
    color: var(--primary);
}
.level-info {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.level-badge {
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: bold;
    margin-right: 6px;
}
.score-info {
    color: var(--text-secondary);
}
.progress {
    height: 4px;
    background: #eee;
    border-radius: 2px;
    margin: 6px 0;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.3s;
}
.btn-create {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 14px;
    cursor: pointer;
}

/* ========== 容器与卡片 ========== */
.container {
    max-width: var(--max-width);
    margin: 24px auto;
    padding: 0 20px;
    flex: 1;
    width: 100%;
    box-sizing: border-box;
}
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.card:hover {
    box-shadow: var(--shadow-hover);
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.more-link {
    font-size: 14px;
    color: var(--primary);
    font-weight: 500;
}

/* ========== 主页布局 ========== */
.home-layout {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}
.content-main {
    flex: 2.5;
    min-width: 0;  /* 防止子元素溢出 */
}
.sidebar {
    flex: 1;
    min-width: 250px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.post-list-simple .post-item-simple {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.post-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text);
    display: block;
    margin-bottom: 4px;
    word-break: break-word;
}
.post-meta {
    font-size: 13px;
    color: var(--text-secondary);
}
.forum-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}
.forum-card {
    background: #f9f9f9;
    padding: 12px;
    border-radius: var(--radius);
    text-align: center;
    color: var(--text);
    transition: background 0.2s;
}
.forum-card:hover {
    background: var(--primary-light);
    color: var(--primary);
}
.forum-name {
    font-weight: 600;
}
.forum-stats {
    font-size: 12px;
    color: var(--text-secondary);
}
.checkin-card {
    text-align: center;
}
#checkin-btn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 70px;
    height: 70px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}
#checkin-btn:hover {
    transform: scale(1.05);
}
.checked-in-badge {
    color: var(--text-secondary);
    font-size: 15px;
    padding: 10px 0;
}
.checkin-info {
    margin-top: 8px;
    font-size: 13px;
    color: var(--primary);
}

/* ========== 性别标识 ========== */
.gender-flag {
    font-weight: bold;
    font-size: 14px;
}
.gender-male { color: #4a8bfc; }
.gender-female { color: #ff6b9d; }

/* ========== 帖子详情 ========== */
.post-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}
.author-info {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}
.avatar-md {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.author-detail .nickname {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.signature {
    font-size: 12px;
    color: var(--text-secondary);
}
.post-content {
    margin: 16px 0;
    line-height: 1.8;
    word-break: break-word;
    overflow-wrap: break-word;
}
.post-content img {
    max-width: 100%;
    height: auto;
}
.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
}
.tag {
    background: var(--primary);
    color: white;
    padding: 2px 12px;
    border-radius: 12px;
    font-size: 12px;
}
.post-meta-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
    flex-wrap: wrap;
    gap: 8px;
}
.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* 评论 */
.comments-section {
    margin-top: 24px;
}
.comment-item {
    display: flex;
    gap: 12px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.comment-avatar .avatar-sm {
    width: 36px;
    height: 36px;
}
.comment-body {
    flex: 1;
    min-width: 0;
}
.comment-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 8px;
    font-size: 13px;
    flex-wrap: wrap;
}
.replies {
    margin-top: 12px;
    padding-left: 20px;
    border-left: 2px solid #f0f0f0;
}
.reply-item {
    padding: 8px 0;
    font-size: 14px;
    word-break: break-word;
}
.reply-nickname {
    font-weight: 500;
}
.reply-to {
    color: var(--primary);
}

/* 投票结果条 */
.result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 10px 0;
    flex-wrap: wrap;
}
.result-label {
    width: 120px;
    font-weight: 500;
    flex-shrink: 0;
}
.result-bar-container {
    flex: 1;
    background: #f0f0f0;
    border-radius: 20px;
    height: 28px;
    overflow: hidden;
    min-width: 100px;
}
.result-bar {
    height: 100%;
    background: #00a1d6;
    border-radius: 20px 8px 8px 20px;
    display: flex;
    align-items: center;
    padding-left: 10px;
    color: white;
    font-weight: 500;
    font-size: 13px;
    transition: width 0.6s;
    white-space: nowrap;
}
.result-count {
    width: 50px;
    text-align: right;
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* 私信页 */
.messages-page {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}
.msg-sidebar {
    width: 160px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}
.msg-sidebar .tab {
    background: white;
    border: none;
    padding: 10px 16px;
    border-radius: var(--radius);
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
    transition: background 0.2s;
}
.msg-sidebar .tab.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}
.msg-main {
    flex: 1;
    min-width: 0;
}
.msg-item {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.unread-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #ff4d4f;
    border-radius: 50%;
    margin-right: 6px;
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}
.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}
.close {
    float: right;
    font-size: 24px;
    cursor: pointer;
}

/* 表单 */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
}
.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border 0.2s;
    background: white;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(251,114,153,0.1);
}
textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* 编辑器工具栏 */
.editor-toolbar {
    display: flex;
    gap: 4px;
    padding: 8px;
    background: #f5f5f5;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    flex-wrap: wrap;
}
.editor-toolbar button, .editor-toolbar select {
    padding: 4px 10px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}
.editor-content {
    min-height: 200px;
    border-radius: 0 0 var(--radius) var(--radius);
}

/* 个人主页 */
.profile-header {
    position: relative;
    border-radius: var(--radius-lg);
    padding: 40px 24px 24px;
    margin-bottom: 20px;
    background-size: cover;
    background-position: center;
    color: white;
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}
.profile-header::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(to bottom, rgba(0,0,0,0.1), rgba(0,0,0,0.7));
    border-radius: inherit;
}
.profile-header > * {
    position: relative;
    z-index: 1;
}
.avatar-lg {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid white;
    object-fit: cover;
    flex-shrink: 0;
}
.profile-info {
    color: white;
    word-break: break-word;
}
.profile-stats a {
    color: #ddd;
    margin-right: 16px;
}

/* 管理后台 */
.manage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    flex-wrap: wrap;
}

/* 页脚 */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: auto;
}

/* 工具类 */
.text-muted { color: var(--text-secondary); }
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 12px;
}
.alert-success { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
.alert-danger { background: #fff2f0; color: #ff4d4f; border: 1px solid #ffccc7; }
.alert-warning { background: #fffbe6; color: #faad14; border: 1px solid #ffe58f; }
.alert-info { background: #e6f7ff; color: #1890ff; border: 1px solid #91d5ff; }

/* ========== 响应式增强 ========== */
@media (max-width: 992px) {
    .container {
        padding: 0 15px;
    }
    .home-layout {
        flex-direction: column;
    }
    .content-main, .sidebar {
        flex: none;
        width: 100%;
        min-width: 0;
    }
    .navbar {
        height: auto;
        padding: 10px 15px;
        flex-wrap: wrap;
    }
    .navbar-left {
        gap: 15px;
    }
    .nav-links {
        gap: 12px;
        font-size: 14px;
    }
    .search-form input {
        width: 120px;
    }
    .forum-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .messages-page {
        flex-direction: column;
    }
    .msg-sidebar {
        flex-direction: row;
        overflow-x: auto;
        width: 100%;
        white-space: nowrap;
    }
    .msg-sidebar .tab {
        flex-shrink: 0;
    }
}

@media (max-width: 576px) {
    .navbar {
        justify-content: space-between;
    }
    .nav-links {
        display: none;  /* 移动端隐藏导航，可改为汉堡菜单，此处暂简化 */
    }
    .search-form input {
        width: 80px;
    }
    .card {
        padding: 15px;
    }
    .profile-header {
        flex-direction: column;
        text-align: center;
        padding: 20px 15px;
    }
    .author-info {
        flex-direction: column;
        align-items: flex-start;
    }
    .post-meta-actions {
        flex-direction: column;
        align-items: flex-start;
    }
    .action-buttons {
        width: 100%;
        justify-content: space-between;
    }
    .result-item {
        flex-direction: column;
        align-items: flex-start;
    }
    .result-label, .result-count {
        width: auto;
    }
    .manage-grid {
        grid-template-columns: 1fr;
    }
    .btn-lg {
        padding: 10px 20px;
        font-size: 15px;
    }
}