/* ===== 门户页样式 ===== */
.portal-page { width: min(100%, 1200px); margin: 0 auto; padding: 8px 16px 20px; overflow-x: hidden; }

/* 轮播+快讯区 */
.portal-hero { display: grid; grid-template-columns: 1fr 340px; gap: 16px; margin-bottom: 20px; }
.portal-slider { position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 16/8; background: var(--bg-primary); box-shadow: var(--shadow-sm); }
.portal-slider .p-slide { position: absolute; inset: 0; opacity: 0; transition: opacity 0.5s; }
.portal-slider .p-slide.active { opacity: 1; }
.portal-slider .p-slide img { width: 100%; height: 100%; object-fit: cover; }
.portal-slider .p-slide-overlay { position: absolute; bottom: 0; left: 0; right: 0; padding: 40px 20px 16px; background: linear-gradient(transparent, rgba(0,0,0,0.7)); }
.portal-slider .p-slide-title { color: #fff; font-size: 18px; font-weight: 600; line-height: 1.4; text-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.portal-slider .p-dots { position: absolute; bottom: 10px; right: 16px; display: flex; gap: 6px; }
.portal-slider .p-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.5); cursor: pointer; transition: all 0.3s; }
.portal-slider .p-dot.active { background: #fff; width: 20px; border-radius: 4px; }
.portal-slide-noimg { display: flex; align-items: flex-end; height: 100%; background: linear-gradient(135deg, var(--primary-color), #6366f1); }

/* 右侧快讯 */
.portal-aside-card { background: var(--bg-primary); border-radius: 12px; box-shadow: var(--shadow-sm); overflow: hidden; height: 100%; display: flex; flex-direction: column; }
.portal-aside-header { padding: 14px 16px; font-size: 15px; font-weight: 600; color: var(--text-primary); border-bottom: 1px solid var(--border-light); display: flex; align-items: center; gap: 8px; }
.portal-aside-header i { color: var(--primary-color); }
.portal-aside-body { flex: 1; overflow-y: auto; padding: 8px 0; }
.portal-news-item { display: flex; align-items: center; padding: 8px 16px; gap: 10px; transition: background 0.2s; }
.portal-news-item:hover { background: var(--bg-hover); }
.portal-news-time { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.portal-news-title { flex: 1; font-size: 13px; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-news-title:hover { color: var(--primary-color); }

/* 广告区域 */
.portal-ad-bar { display: flex; gap: 12px; margin-bottom: 12px; overflow: hidden; border-radius: 12px; position: relative; transition: opacity 0.3s, max-height 0.4s; height: 65px; }
.portal-ad-close { position: absolute; top: 6px; right: 6px; z-index: 2; width: 24px; height: 24px; border-radius: 50%; border: none; background: rgba(0,0,0,0.5); color: #fff; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.2s; line-height: 1; }
.portal-ad-close:hover { background: rgba(0,0,0,0.75); }
.portal-ad-bar.hiding { opacity: 0; max-height: 0 !important; margin-bottom: 0; padding: 0; overflow: hidden; }
.portal-ad-item { flex: 1; min-width: 0; border-radius: 12px; overflow: hidden; display: block; transition: transform 0.2s, box-shadow 0.2s; height: 100%; }
.portal-ad-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.1)); }
.portal-ad-item img { width: 100%; height: 100%; object-fit: contain; display: block; background: #f5f5f5; }

/* 中部广告位 - 三列布局 */
.portal-mid-ad-section { margin: 0 0 12px 0; position: relative; }
.portal-mid-ad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.portal-mid-ad-item { display: block; height: 76px; border-radius: 8px; overflow: hidden; transition: transform 0.2s, box-shadow 0.2s; background: #f5f5f5; }
.portal-mid-ad-item:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.portal-mid-ad-item img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* 主内容区：左右布局 */
.portal-main { display: grid; grid-template-columns: 1fr 300px; gap: 20px; width: 100%; max-width: 100%; overflow-x: hidden; }
.portal-content { min-width: 0; width: 100%; max-width: 100%; overflow-x: hidden; }
.portal-sidebar { display: flex; flex-direction: column; gap: 16px; min-width: 0; max-width: 100%; }

/* 板块聚合 - TAB 布局 */
.portal-tabs-wrap { background: var(--bg-primary); border-radius: 12px 12px 0 0; box-shadow: var(--shadow-sm); overflow: hidden; position: relative; top: auto; z-index: 1; width: 100%; max-width: 100%; margin-bottom: 0; }
.portal-tabs { display: flex; gap: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -ms-overflow-style: none; padding: 0 4px; width: 100%; max-width: 100%; }
.portal-tabs::-webkit-scrollbar { display: none; }
.portal-tab { display: inline-flex; align-items: center; gap: 5px; padding: 14px 18px; background: none; border: none; border-bottom: 2px solid transparent; font-size: 14px; font-weight: 500; color: var(--text-secondary); cursor: pointer; white-space: nowrap; transition: all 0.2s; }
.portal-tab:hover { color: var(--primary-color); background: var(--bg-hover); }
.portal-tab.active { color: var(--primary-color); border-bottom-color: var(--primary-color); font-weight: 600; }
.portal-tab i { font-size: 16px; }
.portal-tab-panels { background: var(--bg-primary); border-radius: 0 0 12px 12px; box-shadow: var(--shadow-sm); min-height: 200px; width: 100%; max-width: 100%; overflow-x: hidden; }
.portal-tab-panel { display: none; padding: 4px 0; }
.portal-tab-panel.active { display: block; }

/* 文章卡片列表 */
.portal-post-list { display: flex; flex-direction: column; }
.portal-post-card { display: flex; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--border-light); transition: background 0.2s; text-decoration: none; }
.portal-post-card:last-child { border-bottom: none; }
.portal-post-card:hover { background: var(--bg-hover); }
.portal-post-thumb { width: 160px; height: 100px; border-radius: 8px; overflow: hidden; flex-shrink: 0; background: var(--bg-tertiary); }
.portal-post-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.portal-post-card:hover .portal-post-thumb img { transform: scale(1.05); }
.portal-post-body { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.portal-post-title { font-size: 16px; font-weight: 600; color: var(--text-primary); line-height: 1.5; margin: 0 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-post-card:hover .portal-post-title { color: var(--primary-color); }
.portal-post-excerpt { font-size: 13px; color: var(--text-muted); line-height: 1.6; margin: 0 0 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-post-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap; }
.portal-post-meta-avatar { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.portal-post-author { color: var(--text-secondary); }
.portal-post-cat-tag { padding: 1px 8px; background: var(--bg-secondary); border-radius: 4px; font-size: 11px; color: var(--text-muted); }
.portal-post-date { color: var(--text-muted); }
.portal-post-stat { display: inline-flex; align-items: center; gap: 3px; color: var(--text-muted); }
.portal-more-link { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; color: var(--text-muted); transition: color 0.2s; }
.portal-more-link:hover { color: var(--primary-color); }
.portal-cat-empty { padding: 40px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* 门户问答列表 */
.portal-qa-list { display: flex; flex-direction: column; }
.portal-qa-item { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border-light); gap: 0; transition: background 0.2s; text-decoration: none; }
.portal-qa-item:last-child { border-bottom: none; }
.portal-qa-item:hover { background: var(--bg-hover); }
.portal-qa-stats { display: flex; gap: 16px; flex-shrink: 0; margin-right: 20px; padding-right: 20px; border-right: 1px solid var(--border-light); }
.portal-qa-stat { text-align: center; min-width: 40px; }
.portal-qa-stat-num { display: block; font-size: 18px; font-weight: 700; line-height: 1.2; color: var(--text-muted); }
.portal-qa-stat-num.solved { color: var(--primary-color); }
.portal-qa-stat-label { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.portal-qa-body { flex: 1; min-width: 0; }
.portal-qa-title { font-size: 15px; font-weight: 600; color: var(--text-primary); margin: 0 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-qa-item:hover .portal-qa-title { color: var(--primary-color); }
.portal-qa-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.portal-qa-tags { display: flex; gap: 6px; }
.portal-qa-tag { padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 500; }
.portal-qa-tag.reward { background: #fef3c7; color: #d97706; }
.portal-qa-tag.best { background: #dcfce7; color: #16a34a; }
.portal-qa-meta { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.portal-qa-heat { display: flex; align-items: center; gap: 3px; font-size: 13px; color: #ef4444; white-space: nowrap; flex-shrink: 0; margin-left: 16px; font-weight: 500; }

/* 侧边栏卡片 */
.portal-side-card { background: var(--bg-primary); border-radius: 12px; box-shadow: var(--shadow-sm); overflow: hidden; }
.portal-side-header { padding: 14px 16px; font-size: 15px; font-weight: 600; color: var(--text-primary); border-bottom: 1px solid var(--border-light); display: flex; align-items: center; gap: 8px; }
.portal-side-header i { color: var(--primary-color); }

/* 排行榜 */
.portal-rank-list { padding: 8px 0; }
.portal-rank-item { display: flex; align-items: center; padding: 8px 16px; gap: 10px; }
.portal-rank-num { width: 20px; height: 20px; border-radius: 4px; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.portal-rank-num.r1 { background: #f59e0b; }
.portal-rank-num.r2 { background: #94a3b8; }
.portal-rank-num.r3 { background: #cd7f32; }
.portal-rank-num.rn { background: var(--bg-tertiary); color: var(--text-muted); }
.portal-rank-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.portal-rank-name { flex: 1; font-size: 13px; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-rank-val { font-size: 13px; font-weight: 600; color: var(--primary-color); }

/* 热门标签 */
.portal-tags { padding: 14px 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.portal-tag { padding: 4px 12px; background: var(--bg-secondary); border-radius: 20px; font-size: 12px; color: var(--text-secondary); transition: all 0.2s; }
.portal-tag:hover { background: var(--primary-color); color: #fff; }

/* 新用户 */
.portal-new-users { padding: 14px 16px; display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.portal-new-user { text-align: center; }
.portal-new-user img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; margin-bottom: 4px; }
.portal-new-user span { display: block; font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 友情链接 */
.portal-friends-list { padding: 12px 16px; max-height: none; overflow: visible; }
.portal-friends-list::-webkit-scrollbar { width: 6px; }
.portal-friends-list::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
.portal-friends-list::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
.portal-friends-list li { list-style: none; margin-bottom: 8px; }
.portal-friends-list li:last-child { margin-bottom: 0; }
.portal-friends-list a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg-secondary); border-radius: 8px; color: var(--text-secondary); text-decoration: none; font-size: 13px; transition: all 0.2s; border: 1px solid transparent; min-width: 0; }
.portal-friends-list a:hover { background: var(--bg-hover); color: var(--primary-color); border-color: var(--primary-color)40; transform: translateX(4px); }
.portal-friends-list a img { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--bg-primary); border: 1px solid var(--border-light); }
.portal-friends-list a .friend-link-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.portal-friends-list a .friend-link-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; line-height: 1.4; color: var(--text-primary); }
.portal-friends-list a .friend-link-desc { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; line-height: 1.4; color: var(--text-muted); }
.portal-friends-list a:hover .friend-link-name { color: var(--primary-color); }

/* 用户信息卡 */
.portal-user-card { padding: 20px 16px; text-align: center; }
.portal-user-avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; margin-bottom: 10px; }
.portal-user-name { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.portal-user-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }
.portal-user-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.portal-user-actions a { padding: 6px 14px; border-radius: 6px; font-size: 13px; background: var(--bg-secondary); color: var(--text-secondary); transition: all 0.2s; }
.portal-user-actions a:hover { background: var(--primary-color); color: #fff; }
.portal-guest-card { padding: 24px 16px; text-align: center; }
.portal-guest-icon { font-size: 40px; color: var(--text-muted); opacity: 0.4; margin-bottom: 10px; }
.portal-guest-card p { font-size: 14px; color: var(--text-muted); margin-bottom: 14px; }
.portal-guest-btns { display: flex; gap: 10px; justify-content: center; }
.portal-guest-btns .btn { padding: 8px 24px; border-radius: 8px; font-size: 14px; }

/* 加载更多按钮 */
.portal-load-more { display: flex; align-items: center; justify-content: center; gap: 6px; width: calc(100% - 40px); margin: 12px 20px; padding: 10px 0; background: var(--bg-secondary); border: 1px solid var(--border-light); border-radius: 8px; font-size: 13px; color: var(--text-secondary); cursor: pointer; transition: all 0.2s; }
.portal-load-more:hover { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }
.portal-load-more:hover .btn-text, .portal-load-more:hover .btn-text i { color: #fff; }
.portal-load-more.loading { pointer-events: none; opacity: 0.6; }
.portal-load-more .spinner { display: none; width: 14px; height: 14px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin 0.6s linear infinite; }
.portal-load-more.loading .spinner { display: inline-block; }
.portal-load-more.loading .btn-text { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.portal-no-more { text-align: center; padding: 12px; font-size: 12px; color: var(--text-muted); }

/* CMS版块展示区 */
.portal-cms-section { margin-top: 20px; width: 100%; }
.portal-cms-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.portal-cms-card { background: var(--bg-primary); border-radius: 12px; box-shadow: var(--shadow-sm); overflow: hidden; transition: box-shadow 0.2s; }
.portal-cms-card:hover { box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.1)); }
.portal-cms-header { display: flex; gap: 0; }
.portal-cms-cover { width: 180px; min-height: 120px; flex-shrink: 0; background-size: cover; background-position: center; display: flex; align-items: center; justify-content: center; position: relative; }
.portal-cms-badge { position: absolute; top: 8px; left: 8px; display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; background: rgba(239,68,68,0.9); color: #fff; border-radius: 10px; font-size: 11px; font-weight: 600; }
.portal-cms-badge i { font-size: 12px; }
.portal-cms-info { flex: 1; padding: 14px 16px; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.portal-cms-name { font-size: 16px; font-weight: 700; color: var(--text-primary); margin: 0 0 4px; }
.portal-cms-desc { font-size: 12px; color: var(--text-muted); margin: 0 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-cms-meta { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-muted); }
.portal-cms-more { color: var(--primary-color); display: inline-flex; align-items: center; gap: 2px; font-size: 12px; }
.portal-cms-more:hover { opacity: 0.8; }
.portal-cms-list { border-top: 1px solid var(--border-light); padding: 6px 0; }
.portal-cms-item { display: flex; align-items: center; gap: 8px; padding: 7px 16px; transition: background 0.15s; text-decoration: none; }
.portal-cms-item:hover { background: var(--bg-hover); }
.portal-cms-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; opacity: 0.5; }
.portal-cms-item-title { flex: 1; font-size: 13px; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-cms-item:hover .portal-cms-item-title { color: var(--primary-color); }
.portal-cms-item-time { font-size: 12px; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }
.portal-cms-tag { display: inline-block; padding: 0 5px; border-radius: 3px; font-size: 11px; margin-right: 4px; vertical-align: middle; }
.portal-cms-tag.solved { background: #dcfce7; color: #16a34a; }
.portal-cms-tag.reward { background: #fef3c7; color: #d97706; }
.portal-cms-empty { padding: 16px; text-align: center; font-size: 12px; color: var(--text-muted); }

/* 响应式 */
@media (max-width: 1024px) {
    .portal-hero { grid-template-columns: 1fr; }
    .portal-aside-card { max-height: 260px; }
    .portal-main { grid-template-columns: 1fr; }
    .portal-sidebar { flex-direction: row; flex-wrap: wrap; }
    .portal-sidebar > * { flex: 1; min-width: 280px; }
    .portal-cms-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .portal-page {
        padding-left: 12px;
        padding-right: 12px;
    }

    .portal-main,
    .portal-content,
    .portal-tabs-wrap,
    .portal-tab-panels,
    .portal-post-list,
    .portal-post-card {
        width: 100%;
        max-width: 100%;
    }

    .portal-tabs {
        padding: 0;
    }

    .portal-ad-bar {
        flex-direction: column;
        height: auto;
        gap: 12px;
        margin: 0 0 16px 0;
    }

    .portal-ad-item {
        height: 180px;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    }

    .portal-ad-item img {
        object-fit: cover;
        border-radius: 12px;
    }

    .portal-ad-close {
        top: 8px;
        right: 8px;
        width: 28px;
        height: 28px;
        background: rgba(0,0,0,0.6);
    }

    .portal-mid-ad-section {
        margin: 0 0 12px 0;
        padding: 0;
        overflow: hidden;
        width: 100%;
        max-width: 100%;
    }

    .portal-mid-ad-grid {
        display: flex;
        gap: 10px;
        width: max-content;
        max-width: none;
        min-width: 100%;
        overflow: visible;
        will-change: transform;
        animation: portalMidAdScroll var(--portal-mid-ad-duration, 18s) linear infinite;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .portal-mid-ad-grid:hover,
    .portal-mid-ad-grid:active {
        animation-play-state: paused;
    }

    .portal-mid-ad-grid::-webkit-scrollbar { display: none; }

    .portal-mid-ad-item {
        width: 160px;
        min-width: 160px;
        height: 60px;
        flex-shrink: 0;
    }

    @keyframes portalMidAdScroll {
        from {
            transform: translateX(0);
        }
        to {
            transform: translateX(calc(-1 * var(--portal-mid-ad-distance, 0px)));
        }
    }

    .portal-mid-ad-item img {
        object-fit: contain;
    }

    .portal-new-users { grid-template-columns: repeat(4, 1fr); }
    .portal-post-card { flex-direction: column; gap: 10px; }
    .portal-post-thumb { width: 100%; height: 160px; }
    .portal-tab { padding: 12px 14px; font-size: 13px; }
    .portal-qa-item { flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px 16px; }
    .portal-qa-stats { flex-direction: row; margin-right: 0; padding-right: 0; border-right: none; gap: 16px; }
    .portal-qa-stat { display: flex; flex-direction: row; align-items: center; gap: 4px; }
    .portal-qa-stat-num { font-size: 14px; }
    .portal-qa-stat-label { margin-top: 0; }
    .portal-qa-body { width: 100%; }
    .portal-qa-title { white-space: normal; }
    .portal-qa-bottom { flex-wrap: wrap; }
    .portal-qa-tags { flex-wrap: wrap; }
    .portal-qa-tag { white-space: nowrap; }
    .portal-qa-heat { margin-left: 0; }
    .portal-cms-cover { width: 120px; min-height: 100px; }
    .portal-cms-name { font-size: 14px; }
    .portal-cms-desc { font-size: 11px; }
    .portal-friends-list {
        padding: 10px 12px;
        max-height: none;
    }
    .portal-friends-list li {
        margin-bottom: 10px;
    }
    .portal-friends-list a {
        padding: 8px 10px;
        gap: 8px;
        border-radius: 8px;
    }
    .portal-friends-list a img {
        width: 28px;
        height: 28px;
    }
    .portal-friends-list a .friend-link-text {
        display: block;
    }
    .portal-friends-list a .friend-link-name {
        font-size: 13px;
        white-space: nowrap;
        display: block;
        line-height: 1.4;
    }
    .portal-friends-list a .friend-link-desc {
        display: none;
    }
}
