/* ==============================
   河木资源站 - 前端样式
   ============================== */

/* 基础变量 */
:root {
    --primary: #1890ff;
    --primary-light: #40a9ff;
    --primary-dark: #096dd9;
    --secondary: #52c41a;
    --bg: #f0f2f5;
    --card-bg: #ffffff;
    --text: #1f1f1f;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --border: #e8e8e8;
    --border-light: #f0f0f0;
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-sm: 4px;
    --header-height: 56px;
    --sidebar-width: 160px;
    --sidebar-right-width: 280px;
    --transition: all 0.25s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

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

img { max-width: 100%; height: auto; }

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

/* ===== 顶部导航栏 ===== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--card-bg);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.header-inner {
    display: flex;
    align-items: center;
    height: var(--header-height);
    gap: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
}

.logo-icon { font-size: 24px; }

.main-nav {
    display: flex;
    gap: 4px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 14px;
    white-space: nowrap;
}

.nav-item:hover { color: var(--primary); background: rgba(24,144,255,0.06); }
.nav-item.active { color: var(--primary); background: rgba(24,144,255,0.1); font-weight: 500; }

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-form {
    display: flex;
    align-items: center;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 0 4px 0 12px;
    border: 1px solid transparent;
    transition: var(--transition);
    width: 220px;
}

.search-form:focus-within {
    border-color: var(--primary);
    background: var(--card-bg);
}

.search-form input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 13px;
    flex: 1;
    padding: 7px 0;
    color: var(--text);
}

.search-form input::placeholder { color: var(--text-tertiary); }

.search-form button {
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 6px 8px;
    font-size: 15px;
}

.search-form button:hover { color: var(--primary); }

.login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    color: var(--text-secondary);
    background: var(--bg);
    font-size: 16px;
}

.login-btn:hover { color: var(--primary); background: rgba(24,144,255,0.1); }

/* ===== 页面主体布局 ===== */
.page-body {
    display: flex;
    gap: 16px;
    padding-top: 16px;
    padding-bottom: 24px;
    align-items: flex-start;
}

/* ===== 左侧边栏 ===== */
.sidebar-left {
    width: var(--sidebar-width);
    flex-shrink: 0;
    position: sticky;
    top: calc(var(--header-height) + 16px);
}

.cat-menu {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 8px 0;
    box-shadow: var(--shadow);
}

.cat-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    color: var(--text-secondary);
    font-size: 13px;
    transition: var(--transition);
    position: relative;
}

.cat-menu-item i { font-size: 16px; width: 20px; text-align: center; }
.cat-menu-item:hover { color: var(--primary); background: rgba(24,144,255,0.04); }
.cat-menu-item.active { color: var(--primary); background: rgba(24,144,255,0.08); font-weight: 500; }
.cat-menu-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 16px;
    background: var(--primary);
    border-radius: 0 2px 2px 0;
}

.cat-menu-divider {
    height: 1px;
    background: var(--border-light);
    margin: 6px 12px;
}

/* ===== 主内容区 ===== */
.main-content {
    flex: 1;
    min-width: 0;
}

/* 资源列表 - 卡片式 */
.res-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.res-card {
    display: flex;
    gap: 14px;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.res-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
}

.res-thumb {
    width: 180px;
    height: 120px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg);
}

.res-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.res-card:hover .res-thumb img { transform: scale(1.04); }

.res-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.res-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--primary);
    background: rgba(24,144,255,0.08);
    padding: 2px 8px;
    border-radius: 4px;
    width: fit-content;
    margin-bottom: 6px;
}

.res-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

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

.res-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.res-meta span { display: flex; align-items: center; gap: 3px; }
.res-meta i { font-size: 13px; }

.res-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: auto;
}

.res-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 40px;
    color: var(--text-tertiary);
    font-size: 12px;
    padding-left: 8px;
    border-left: 1px solid var(--border-light);
}

.res-action i { font-size: 18px; cursor: pointer; transition: var(--transition); }
.res-action i:hover { color: var(--primary); }
.res-action .liked { color: #ff4d4f; }

/* ===== 右侧边栏 ===== */
.sidebar-right {
    width: var(--sidebar-right-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: calc(var(--header-height) + 16px);
}

.side-block {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
}

.side-block-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

/* 公告栏 */
.announce-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* 标签云 */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-cloud a {
    display: inline-block;
    padding: 4px 10px;
    background: var(--bg);
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-secondary);
    transition: var(--transition);
}

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

/* 热榜 */
.hot-list { display: flex; flex-direction: column; gap: 8px; }
.hot-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
}
.hot-rank {
    width: 20px; height: 20px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 4px;
    font-size: 12px; font-weight: 600;
    flex-shrink: 0;
}
.hot-rank.top3 { background: #ff4d4f; color: #fff; }
.hot-rank.normal { background: var(--bg); color: var(--text-tertiary); }
.hot-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}
.hot-title:hover { color: var(--primary); }
.hot-views { font-size: 11px; color: var(--text-tertiary); }

/* ===== 详情页 ===== */
.res-detail {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.detail-header {
    margin-bottom: 16px;
}

.detail-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
    line-height: 1.4;
}

.detail-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: var(--text-tertiary);
    flex-wrap: wrap;
}

.detail-meta .tag {
    background: rgba(24,144,255,0.1);
    color: var(--primary);
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 12px;
}

.detail-cover {
    width: 100%;
    max-height: 400px;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
    background: var(--bg);
    text-align: center;
}

.detail-cover img {
    max-height: 400px;
    object-fit: contain;
}

/* 截图网格 */
.screenshots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.screenshots-grid img {
    width: 100%;
    height: 90px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--border-light);
}

.screenshots-grid img:hover { transform: scale(1.03); border-color: var(--primary); }

/* 描述文字 */
.detail-desc {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 20px;
    overflow-wrap: break-word;
    word-break: break-word;
    overflow: hidden; /* clearfix for floated images */
}

.detail-desc p { margin-bottom: 8px; }
.detail-desc img { max-width: 100%; height: auto; display: block; }
.detail-desc img.img-left { float: left; margin: 8px 16px 8px 0; max-width: 50%; display: inline; }
.detail-desc img.img-center { display: block; margin: 8px auto; }
.detail-desc img.img-right { float: right; margin: 8px 0 8px 16px; max-width: 50%; display: inline; }
.detail-desc table { max-width: 100%; display: block; overflow-x: auto; }
.detail-desc pre { overflow-x: auto; white-space: pre-wrap; word-break: break-word; }
.detail-desc iframe { max-width: 100%; }

/* 下载区域 */
.download-section {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.download-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 14px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
}

.download-list { display: flex; flex-direction: column; gap: 10px; }

.download-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card-bg);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    transition: var(--transition);
}

.download-item:hover { border-color: var(--primary-light); }

.download-info { display: flex; align-items: center; gap: 10px; }

.pan-icon {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; color: #fff;
    flex-shrink: 0;
}

.pan-icon.baidu { background: #2932e1; }
.pan-icon.quark { background: #00b4ff; }
.pan-icon.xunlei { background: #0097ff; }

.pan-info { display: flex; flex-direction: column; }
.pan-name { font-size: 14px; font-weight: 500; color: var(--text); }
.pan-link-text {
    font-size: 12px;
    color: var(--text-tertiary);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pan-actions { display: flex; gap: 8px; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

.btn-sm { padding: 4px 10px; font-size: 12px; }

/* 声明区域 */
.notice-box {
    background: #fffbe6;
    border: 1px solid #ffe58f;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 13px;
    color: #ad6800;
    line-height: 1.7;
}

/* ===== 分页 ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 20px 0;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.page-link:hover { border-color: var(--primary); color: var(--primary); }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-ellipsis { color: var(--text-tertiary); padding: 0 4px; }

/* ===== 底部 ===== */
.site-footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border-light);
    padding: 20px 0;
    margin-top: auto;
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.footer-copy { font-size: 13px; color: var(--text-secondary); }
.footer-powered { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }

.footer-right {
    display: flex;
    gap: 16px;
    font-size: 13px;
}

.footer-right a { color: var(--text-secondary); display: flex; align-items: center; gap: 4px; }
.footer-right a:hover { color: var(--primary); }

/* ===== 返回顶部 ===== */
.back-to-top {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 40px;
    height: 40px;
    background: var(--card-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 18px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 99;
}

.back-to-top.visible { opacity: 1; visibility: visible; }
.back-to-top:hover { background: var(--primary); color: #fff; }

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
    .sidebar-right { display: none; }
    .sidebar-left { width: 140px; }
}

@media (max-width: 768px) {
    .page-body { flex-direction: column; }
    .sidebar-left {
        width: 100%;
        position: relative;
        top: 0;
    }
    .cat-menu {
        display: flex;
        flex-wrap: wrap;
        padding: 8px;
        gap: 4px;
    }
    .cat-menu-item { padding: 6px 10px; }
    .cat-menu-divider { display: none; }

    .res-card { flex-direction: column; }
    .res-thumb { width: 100%; height: 180px; }
    .res-action { flex-direction: row; border-left: none; border-top: 1px solid var(--border-light); padding: 8px 0 0; }

    .header-inner { gap: 8px; padding: 0 12px; }
    .header-right { gap: 6px; flex: 1; justify-content: flex-end; min-width: 0; }
    .header-right .search-form { width: auto; flex: 1; max-width: 220px; min-width: 0; }
    .search-form input { min-width: 0; }
    .logo-text { font-size: 15px; }
    .main-nav { display: none; }

    /* 详情页移动端适配 */
    .res-detail { padding: 16px; }
    .detail-title { font-size: 20px; }
    .detail-meta { flex-wrap: wrap; gap: 8px 16px; }
    .detail-desc img { max-width: 100%; height: auto; }
    .download-item { flex-direction: column; gap: 10px; align-items: flex-start; }
    .pan-actions { width: 100%; justify-content: flex-end; }
    .main-content { max-width: 100% !important; padding: 0 12px; }
    .download-info { width: 100%; max-width: 100%; min-width: 0; }
    .pan-info { max-width: 100%; min-width: 0; overflow: hidden; }
    .pan-link-text { max-width: 100% !important; width: 100%; }
}

/* ===== 详情页侧边栏广告 ===== */
.detail-ad {
    overflow: hidden;
}
.detail-ad img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    display: block;
}
.detail-ad-empty {
    background: var(--bg-secondary, #f8f9fa);
    border: 1px dashed var(--border, #e5e7eb);
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary);
}
.empty-state i { font-size: 48px; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 14px; }
