/* ChemTop Forum - Modern Community Styles */

:root {
    --forum-primary: #1565C0;
    --forum-secondary: #4FC3F7;
    --forum-accent: #00C853;
    /* Emerald Green */
    --forum-bg: #f8fafc;
    --forum-sidebar: #ffffff;
    --forum-text-main: #1e293b;
    --forum-text-sub: #64748b;
    --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

body.forum-page {
    background-color: var(--forum-bg);
    color: var(--forum-text-main);
    padding-top: 40px;
    /* Navbar height (30px) + spacing (10px) */
}

.forum-container {
    max-width: 1500px;
    margin: 0 auto;
    padding: 10px 2%;
    display: grid;
    grid-template-columns: 220px 1fr 280px;
    gap: 20px;
    box-sizing: border-box;
}

/* Sidebar Navigation */
.forum-nav {
    position: sticky;
    top: 40px;
    height: fit-content;
}

.nav-section {
    background: white;
    padding: 8px 10px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    margin-bottom: 8px;
}

.nav-section h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--forum-text-sub);
    letter-spacing: 0.05em;
    padding: 0 4px 5px;
    border-bottom: 1px solid #f1f5f9;
}

.forum-menu {
    list-style: none;
    padding: 4px 0 0;
}

.forum-menu-item a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    color: var(--forum-text-main);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s;
    font-weight: 500;
}

.forum-menu-item a:hover {
    background: #eff6ff;
    color: var(--forum-primary);
}

.forum-menu-item.active a {
    background: var(--forum-primary);
    color: white;
}

/* Content Stream */
.forum-feed {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-bar-inline {
    background: white;
    padding: 10px 15px;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    display: flex;
    gap: 12px;
    align-items: center;
}

.search-bar-inline input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    color: var(--forum-text-main);
}

/* Post Card */
.post-card {
    background: white;
    border-radius: 12px;
    padding: 8px 12px;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    border: 1px solid transparent;
    position: relative;
    /* 启用绝对定位 */
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    border-color: #e2e8f0;
}

.post-card .post-header {
    display: flex;
    justify-content: flex-start;
    /* 改为左对齐，标签紧凑 */
    align-items: center;
    margin-bottom: 2px;
    padding-right: 350px;
    /* 右侧留白给 meta/stats，防止重叠 */
    height: 30px;
    /* 固定高度，确保对齐 */
}

.post-card .pin-btn {
    position: absolute;
    right: 302px;
    top: 11px;
}

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

.tag {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
}

.tag-sim {
    background: #e0f2fe;
    color: #0369a1;
}

.tag-equip {
    background: #fef3c7;
    color: #92400e;
}

.tag-safety {
    background: #fee2e2;
    color: #991b1b;
}

.tag-help {
    background: #d1fae5;
    color: #065f46;
}

/* 标签建议样式 */
.tag-suggestion {
    font-size: 0.8rem;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 500;
    background: #f1f5f9;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid #e2e8f0;
}

.tag-suggestion:hover {
    background: #e0f2fe;
    color: #0369a1;
    border-color: #38bdf8;
}

.tag-suggestion:active {
    transform: scale(0.95);
}

.post-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--forum-text-main);
    margin-bottom: 0;
    line-height: 1.3;
}

.post-card .post-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--forum-text-sub);
    font-size: 0.75rem;
    position: absolute;
    top: 11px;
    right: 110px;
    left: auto;
    bottom: auto;
    width: 190px;
    justify-content: flex-start;
    overflow: hidden;
    white-space: nowrap;
}

.post-author {
    display: flex;
    align-items: center;
    gap: 8px;
}

.author-avatar {
    width: 24px;
    height: 24px;
    background: #e2e8f0;
    border-radius: 50%;
}

.post-card .post-stats {
    display: flex;
    gap: 8px;
    border-top: none;
    margin-top: 0;
    padding-top: 0;
    position: absolute;
    top: 11px;
    right: 12px;
    width: 140px;
    /* 固定宽度 */
    justify-content: flex-end;
    /* 右对齐 */
    bottom: auto;
}

.collect-text {
    white-space: nowrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--forum-text-sub);
}

/* Right Sidebar Widget */
.widget {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--card-shadow);
    margin-bottom: 24px;
}

.widget-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-list {
    list-style: none;
}

.help-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
}

.rank-num {
    width: 24px;
    height: 24px;
    background: #f1f5f9;
    color: var(--forum-text-sub);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

.rank-num.top1 {
    background: #fef3c7;
    color: #d97706;
}

/* Responsive */
@media (max-width: 1200px) {
    .forum-container {
        grid-template-columns: 200px 1fr 260px;
    }
}

@media (max-width: 1024px) {
    .forum-container {
        grid-template-columns: 180px 1fr;
        max-width: 1000px;
        padding: 16px 3%;
    }

    .widget-area {
        display: none;
    }
}

/* --- Skeleton Loading Animation --- */
@keyframes skeleton-loading {
    0% {
        background-color: #f1f5f9;
        opacity: 0.7;
    }

    50% {
        background-color: #cbd5e1;
        opacity: 1;
    }

    100% {
        background-color: #f1f5f9;
        opacity: 0.7;
    }
}

.skeleton {
    animation: skeleton-loading 1.5s infinite ease-in-out;
    border-radius: 4px;
    background-color: #f1f5f9;
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    width: 100%;
}

.skeleton-title {
    height: 24px;
    margin-bottom: 12px;
    width: 60%;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-meta {
    width: 100px;
    height: 14px;
}

.skeleton-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

@media (max-width: 768px) {
    .forum-container {
        grid-template-columns: 1fr;
        padding: 12px 3%;
    }

    .forum-nav {
        display: none;
    }
}

/* 附件上传区域样式 */
.upload-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    background: white;
    transition: 0.3s;
    cursor: pointer;
    margin-bottom: 15px;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: #1565C0;
    background: #f0f9ff;
}

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

.upload-text {
    color: #64748b;
    font-size: 0.9rem;
}

.attachment-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 15px;
}

.upload-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.85rem;
}

.upload-item .file-info {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upload-item .btn-remove {
    color: #f43f5e;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 5px;
}

.upload-item.uploading {
    border-color: #38bdf8;
    background: #f0f9ff;
}

.progress-bar {
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    margin-top: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #1565C0;
    width: 0%;
    transition: width 0.3s;
}

/* 搜索和排序样式 */
.sort-btn {
    padding: 6px 12px;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    color: #64748b;
}

.sort-btn:hover {
    border-color: #1565C0;
    color: #1565C0;
}

.sort-btn.active {
    background: #1565C0;
    border-color: #1565C0;
    color: white;
}

.search-history-dropdown {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
}

.search-history-item {
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}

.search-history-item:hover {
    background: #f1f5f9;
}

.search-history-item .keyword {
    font-size: 0.9rem;
    color: #334155;
}

.search-history-item .time {
    font-size: 0.75rem;
    color: #94a3b8;
}

.search-history-item .clear-btn {
    padding: 4px 8px;
    font-size: 0.75rem;
    color: #f43f5e;
    cursor: pointer;
}

.search-history-item .clear-btn:hover {
    background: #fee2e2;
    border-radius: 4px;
}

.search-highlight {
    background: #fef08a;
    padding: 0 2px;
    border-radius: 2px;
}

/* 排序按钮激活状态 */
.sort-btn[data-sort="hot"].active {
    background: #f43f5e;
    border-color: #f43f5e;
}

.sort-btn[data-sort="essence"].active {
    background: #f59e0b;
    border-color: #f59e0b;
}

.sort-btn[data-sort="latest"].active {
    background: #1565C0;
    border-color: #1565C0;
}

/* 搜索信息栏 */
.search-info {
    padding: 8px 0;
    color: #64748b;
    font-size: 0.85rem;
}

.search-info .highlight {
    color: #1565C0;
    font-weight: 600;
}

/* 加载更多按钮 */
.load-more-container {
    text-align: center;
    padding: 20px;
    margin-top: 20px;
}

.load-more-btn {
    display: inline-block;
    padding: 12px 40px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #64748b;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.load-more-btn:hover {
    background: #f8fafc;
    border-color: #1565C0;
    color: #1565C0;
}

.load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 加载状态 */
.loading-indicator {
    text-align: center;
    padding: 20px;
    color: #64748b;
}

/* 无限滚动加载提示 */
.scroll-loading {
    text-align: center;
    padding: 15px;
    color: #94a3b8;
    font-size: 0.85rem;
}

.scroll-loading.show {
    display: block;
}

/* ==================== 移动端响应式优化 ==================== */

/* 移动端菜单按钮 */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 1001;
}

.mobile-menu-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: #333;
    margin: 5px 0;
    transition: all 0.3s;
    border-radius: 2px;
}

/* 移动端遮罩层 */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
}

.mobile-overlay.show {
    display: block;
}

/* 移动端侧边栏 */
.mobile-sidebar {
    display: none !important;
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100%;
    background: white;
    z-index: 999;
    padding: 20px;
    overflow-y: auto;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.mobile-sidebar.open {
    left: 0;
}

/* 小屏幕设备 (320px - 480px) */
@media (max-width: 480px) {
    .forum-container {
        padding: 10px 12px;
        gap: 12px;
    }

    .post-card {
        padding: 16px;
        border-radius: 12px;
    }

    .post-title {
        font-size: 1.05rem;
    }

    .post-meta {
        font-size: 0.8rem;
        gap: 8px;
        flex-wrap: wrap;
        width: auto;
        position: static;
        margin-top: 5px;
    }

    .post-stats {
        width: auto;
        position: static;
        justify-content: flex-start;
        margin-top: 5px;
    }

    .post-header {
        flex-direction: column;
        gap: 8px;
        padding-right: 0;
        height: auto;
    }

    .post-tags {
        gap: 6px;
    }

    .tag {
        font-size: 0.7rem;
        padding: 2px 8px;
    }

    .search-bar-inline {
        padding: 12px 15px;
        flex-wrap: wrap;
    }

    .search-bar-inline input {
        font-size: 0.9rem;
    }

    .sort-btn {
        padding: 5px 10px;
        font-size: 0.75rem;
    }

    .nav-section {
        padding: 10px;
    }

    .nav-section h3 {
        font-size: 0.75rem;
        padding: 0 8px 8px;
    }

    .forum-menu-item a {
        padding: 8px 10px;
        font-size: 0.9rem;
    }

    .load-more-btn {
        padding: 10px 30px;
        font-size: 0.85rem;
    }

    /* 详情页移动端 */
    .post-content-full {
        padding: 20px;
        border-radius: 12px;
    }

    .post-content-full h1 {
        font-size: 1.3rem;
    }

    .post-body {
        font-size: 0.95rem;
    }

    .comments-section {
        padding: 20px;
        border-radius: 12px;
    }

    .comment-card {
        padding: 15px 0;
    }

    .comment-textarea {
        height: 100px;
        padding: 12px;
    }

    /* 用户主页移动端 */
    .profile-header {
        padding: 25px 15px;
    }

    .profile-avatar {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }

    .profile-name {
        font-size: 1.2rem;
    }

    .profile-stats {
        gap: 20px;
    }

    .stat-item {
        padding: 10px 15px;
    }

    .stat-number {
        font-size: 1.4rem;
    }

    /* 消息页面移动端 */
    .messages-container {
        grid-template-columns: 1fr;
        height: auto;
        min-height: auto;
    }

    .messages-sidebar {
        height: 300px;
        border-radius: 12px;
        margin-bottom: 15px;
    }

    .messages-main {
        height: 400px;
        border-radius: 12px;
    }

    .message-input-area {
        padding: 15px;
    }
}

/* 中等移动设备 (481px - 768px) */
@media (max-width: 768px) {

    /* 显示移动端菜单按钮 */
    .mobile-menu-btn {
        display: block;
    }

    /* 显示遮罩层和侧边栏 */
    .mobile-overlay {
        display: block;
    }

    .mobile-sidebar {
        display: block !important;
    }

    .forum-container {
        grid-template-columns: 1fr;
        padding: 12px 4%;
    }

    .forum-nav {
        display: none;
    }

    .widget-area {
        display: none;
    }

    .post-card {
        padding: 20px;
    }

    .post-title {
        font-size: 1.15rem;
    }

    .post-meta {
        font-size: 0.85rem;
    }

    .post-stats {
        gap: 12px;
        margin-top: 12px;
        padding-top: 12px;
        position: static;
        border-top: 1px solid #f1f5f9;
        width: 100%;
    }

    .post-header {
        flex-direction: column;
        align-items: flex-start;
        padding-right: 0;
        height: auto;
        margin-bottom: 8px;
    }

    .post-meta {
        position: static;
        margin-bottom: 8px;
        width: 100%;
        justify-content: flex-start;
        /* 移动端恢复自然对齐 */
    }

    .post-stats {
        position: static;
        width: 100%;
        justify-content: flex-start;
        /* 移动端恢复自然对齐 */
        margin-top: 0;
    }

    /* 详情页 */
    .forum-container[style*="grid-template-columns: 1fr 260px"] {
        grid-template-columns: 1fr !important;
    }

    .forum-container[style*="grid-template-columns: 1fr 260px"] .widget-area {
        display: block !important;
    }

    .post-content-full {
        padding: 24px;
    }

    .comments-section {
        padding: 24px;
    }

    /* 用户主页 */
    .profile-header {
        padding: 30px 20px;
    }

    .profile-stats {
        gap: 25px;
    }

    .stat-item {
        padding: 12px 20px;
    }

    .stat-number {
        font-size: 1.6rem;
    }

    /* 消息页面 */
    .messages-container {
        grid-template-columns: 1fr;
        height: auto;
    }

    .messages-sidebar {
        height: 250px;
        margin-bottom: 15px;
    }

    .messages-main {
        height: 350px;
    }

    /* 帖子列表排序栏 */
    .sort-bar {
        flex-wrap: wrap;
        gap: 8px;
    }

    .sort-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

/* 大平板设备 (769px - 1024px) */
@media (max-width: 1024px) {
    .forum-container {
        grid-template-columns: 180px 1fr;
        max-width: 1000px;
        padding: 16px 3%;
    }

    .widget-area {
        display: none;
    }
}

/* 大屏幕设备优化 */
@media (min-width: 1400px) {
    .forum-container {
        max-width: 1400px;
        padding: 20px 3%;
    }
}