/* ============================================================
   简约导航 - 前台样式
   极简扁平化设计，支持浅色/深色模式，自适应多端
   ============================================================ */

/* ---------- CSS 变量（浅色主题） ---------- */
:root {
    --bg: #f5f6fa;
    --bg-card: #ffffff;
    --bg-header: rgba(255, 255, 255, 0.85);
    --bg-hover: #f0f2f8;
    --text: #2b2f3a;
    --text-sub: #8a90a3;
    --text-light: #b6bccb;
    --primary: #5b6bf0;
    --primary-soft: rgba(91, 107, 240, 0.1);
    --border: #eceef4;
    --shadow: 0 4px 20px rgba(30, 40, 90, 0.06);
    --shadow-hover: 0 10px 30px rgba(30, 40, 90, 0.12);
    --radius: 14px;
    --radius-sm: 10px;
    --hot: #ff5f57;
    --official: #5b6bf0;
    --quality: #34c77b;
    --notice-bg: #fffbea;
    --notice-border: #f3e7c3;
}

/* ---------- 深色主题变量 ---------- */
body.dark {
    --bg: #13151b;
    --bg-card: #1d2029;
    --bg-header: rgba(22, 24, 31, 0.85);
    --bg-hover: #262a36;
    --text: #e6e8ee;
    --text-sub: #9aa0b0;
    --text-light: #5d6372;
    --primary: #7c88ff;
    --primary-soft: rgba(124, 136, 255, 0.15);
    --border: #2a2e3a;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 10px 30px rgba(0, 0, 0, 0.45);
    --notice-bg: #242110;
    --notice-border: #3a3517;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background 0.3s ease, color 0.3s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ---------- 顶部导航栏 ---------- */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-header);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    transition: background 0.3s ease;
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.logo-img { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; }
.logo-icon { font-size: 30px; line-height: 1; }
.logo-text {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, var(--primary), #a06bff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ---------- 搜索框 ---------- */
.search-box {
    position: relative;
    flex: 1;
    max-width: 480px;
    margin: 0 auto;
}

.search-input {
    width: 100%;
    height: 42px;
    padding: 0 92px 0 16px;
    border: 1px solid var(--border);
    border-radius: 21px;
    background: var(--bg-card);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.search-clear, .search-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-sub);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.search-clear { right: 44px; display: none; }
.search-clear:hover { background: var(--bg-hover); }
.search-btn { right: 6px; font-size: 16px; }
.search-btn:hover { background: var(--bg-hover); }

/* 搜索下拉弹窗 */
.search-dropdown {
    position: absolute;
    top: 52px;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    overflow: hidden;
    display: none;
    z-index: 200;
}
.search-dropdown.show { display: block; animation: fadeIn 0.18s ease; }

.search-tabs {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 12px;
    color: var(--text-sub);
    border-bottom: 1px solid var(--border);
}
.search-tabs .sep { color: var(--text-light); }
.search-tabs .engine-link:hover { color: var(--primary); }

.search-results { max-height: 380px; overflow-y: auto; }
.search-results li { list-style: none; }
.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    transition: background 0.15s;
}
.search-result-item:hover { background: var(--bg-hover); }
.search-result-item img { width: 28px; height: 28px; border-radius: 6px; flex-shrink: 0; }
.search-result-item .r-name { font-size: 14px; font-weight: 600; }
.search-result-item .r-desc {
    font-size: 12px;
    color: var(--text-sub);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.search-empty { padding: 24px; text-align: center; color: var(--text-sub); font-size: 14px; }

/* ---------- 头部操作按钮 ---------- */
.header-actions { flex-shrink: 0; }
.theme-toggle {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.theme-toggle:hover { border-color: var(--primary); transform: rotate(20deg); }

/* ---------- 站点简介条 ---------- */
.site-desc-bar {
    padding: 8px 0;
    font-size: 13px;
    color: var(--text-sub);
    text-align: center;
    background: var(--primary-soft);
    border-bottom: 1px solid var(--border);
}

/* ---------- 公告栏 ---------- */
.notice-bar {
    background: var(--notice-bg);
    border-bottom: 1px solid var(--notice-border);
    overflow: hidden;
}
.notice-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 40px;
}
.notice-label {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
}
.notice-track {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
}
.notice-track::after {
    content: "";
    position: absolute;
    right: 0; top: 0; bottom: 0;
    width: 60px;
    background: linear-gradient(to left, var(--notice-bg), transparent);
}
.notice-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-right: 60px;
    font-size: 13px;
    color: var(--text);
    animation: noticeScroll linear infinite;
}
.notice-top {
    flex-shrink: 0;
    font-size: 11px;
    color: #fff;
    background: var(--hot);
    border-radius: 4px;
    padding: 0 5px;
}
.notice-content { color: var(--text-sub); }

/* ---------- 主体 ---------- */
.main { flex: 1; padding-top: 28px; padding-bottom: 60px; }

.section { margin-bottom: 40px; }
.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 18px;
}
.section-title {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-count { font-size: 12px; color: var(--text-sub); }

/* ---------- 卡片网格 ---------- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}

.site-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    min-height: 72px;
}
.site-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    box-shadow: var(--shadow-hover);
}

.site-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-hover);
    padding: 2px;
}

.site-info { min-width: 0; flex: 1; }
.site-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.site-desc {
    display: block;
    font-size: 12px;
    color: var(--text-sub);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.site-meta {
    display: block;
    font-size: 11px;
    color: var(--text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- 标签 ---------- */
.tag {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 6px;
    color: #fff;
    line-height: 1.6;
}
.tag.hot { background: var(--hot); }
.tag.official { background: var(--official); }
.tag.quality { background: var(--quality); }
.tag.default { background: #9aa0b0; }

/* ---------- 精选置顶区 ---------- */
.featured-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.featured-section .section-head {
    border-left: 3px solid var(--primary);
    padding-left: 12px;
}

/* ---------- 分类布局 ---------- */
.nav-layout { display: flex; gap: 28px; align-items: flex-start; }

.category-sidebar {
    position: sticky;
    top: 84px;
    width: 180px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.category-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-sub);
    font-size: 14px;
    transition: all 0.2s;
}
.category-link:hover { background: var(--bg-hover); color: var(--text); }
.category-link.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}
.category-link .cat-icon { font-size: 16px; }
.cat-icon-img { width: 20px; height: 20px; border-radius: 4px; object-fit: cover; vertical-align: middle; }
.section-title .cat-icon-img { width: 26px; height: 26px; border-radius: 6px; }

.category-content { flex: 1; min-width: 0; }

/* ---------- 二级分类分组 ---------- */
.sub-group { margin-bottom: 24px; }
.sub-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-sub);
    margin-bottom: 12px;
    padding-left: 10px;
    border-left: 3px solid var(--primary);
}

/* ---------- 底部 ---------- */
.footer {
    border-top: 1px solid var(--border);
    background: var(--bg-card);
    padding: 22px 0;
}
.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-sub);
    gap: 12px;
    flex-wrap: wrap;
}
.footer a:hover { color: var(--primary); }
.admin-hidden-btn {
    border: none;
    background: transparent;
    color: transparent;
    font-size: 12px;
    padding: 0 4px;
}
.admin-hidden-btn:hover { color: var(--text-light); }

/* ---------- 回到顶部 ---------- */
.back-top {
    position: fixed;
    right: 28px;
    bottom: 28px;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text);
    font-size: 18px;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: all 0.25s ease;
    z-index: 90;
}
.back-top.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.back-top:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- 动画 ---------- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes noticeScroll { from { transform: translateX(100%); } to { transform: translateX(-100%); } }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
    .nav-layout { flex-direction: column; }
    .category-sidebar {
        position: static;
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 8px;
        gap: 8px;
        -webkit-overflow-scrolling: touch;
    }
    .category-link { flex-shrink: 0; }
}

@media (max-width: 640px) {
    .container { padding: 0 16px; }
    .header-inner { gap: 12px; }
    .logo-text { font-size: 17px; }
    .card-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    .featured-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .search-box { max-width: 100%; }
}
