/* ============================================
   公共样式 - 硬核指南
   包含所有页面共享的CSS变量和基础样式
   ============================================ */

/* 主题变量定义 */
:root {
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f5f5f7;
    --border-color: #e5e5e7;
    --border-light: #f0f0f2;
    --text-primary: #1d1d1f;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --accent-blue: #4a6cf7;
    --accent-purple: #5e5ce6;
    --accent-orange: #ff6b6b;
    --shadow-sm: 0 2px 8px rgba(0,0,0,.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,.06);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --sidebar-width: 200px;
    --right-sidebar-width: 280px;
    --transition: all 0.3s ease;
}

html[data-theme="dark"] {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-sidebar: #1a1a1a;
    --bg-card: #1c1c1e;
    --bg-hover: #2c2c2e;
    --border-color: #2c2c2e;
    --border-light: #3a3a3c;
    --text-primary: #ffffff;
    --text-secondary: #8e8e93;
    --text-tertiary: #636366;
    --accent-blue: #4a6cf7;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

/* ============================================
   左侧边栏样式
   ============================================ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    z-index: 100;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    overflow-y: auto;
}

.logo-area {
    padding: 0 20px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #ff6b6b, #feca57);
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    /*font-size: 20px;*/
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}
.logo-area {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

.logo-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.logo-text-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.logo-text {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logo-slogan {
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 400;
    letter-spacing: 0.5px;
}

.nav-menu {
    flex: 1;
    padding: 0 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin: 4px 0;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(74, 108, 247, 0.1);
    color: var(--accent-blue);
    font-weight: 600;
}

.nav-icon {
    width: 20px;
    height: 20px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-light);
    font-size: 12px;
    color: var(--text-tertiary);
    text-align: center;
}

.sidebar-action-btn {
    margin: 0 16px 16px;
    padding: 10px;
    background: #e8f5e9;
    border: 1px solid #c8e6c9;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    color: #2e7d32;
    font-weight: 500;
    transition: background 0.2s;
}

.sidebar-action-btn:hover {
    background: #c8e6c9;
}

/* 移动端菜单按钮 */
.mobile-menu-btn {
    display: none;
    position: fixed;
    left: 20px;
    top: 20px;
    z-index: 101;
    width: 40px;
    height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    font-size: 20px;
}

/* ============================================
   主内容区布局
   ============================================ */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.content-layout {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 0 24px 24px;
    display: grid;
    grid-template-columns: 1fr var(--right-sidebar-width);
    gap: 16px;
}

/* ============================================
   顶部搜索区样式
   ============================================ */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 40px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
}

.search-container {
    max-width: 800px;
    margin: 0 auto;
}

.search-tabs {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
    justify-content: center;
}

.search-tab {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 0;
    position: relative;
    transition: color 0.2s;
    background: none;
    border: none;
}

.search-tab:hover { color: var(--text-primary); }

.search-tab.active {
    color: var(--accent-blue);
}

.search-tab.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-blue);
    border-radius: 2px;
}

.search-box-wrapper {
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

.search-box {
    width: 100%;
    padding: 14px 48px 14px 20px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 100px;
    font-size: 15px;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition);
}

.search-box:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 4px rgba(74, 108, 247, 0.1);
}

.search-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    background: var(--accent-blue);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: transform 0.2s;
}

.search-btn:hover { transform: translateY(-50%) scale(1.05); }
.search-btn:active { transform: translateY(-50%) scale(0.95); }

.search-icon-img {
    width: 18px;
    height: 18px;
    filter: brightness(0) invert(1);
}

/* 快捷筛选标签 */
.quick-filters {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.filter-tag {
    padding: 6px 16px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 100px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.filter-tag:hover, .filter-tag.active {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

/* ============================================
   右侧边栏样式
   ============================================ */
.sidebar-right {
    position: sticky;
    top: 140px;
    height: fit-content;
    /*padding-right: 5px;*/
}

.widget {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.widget-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.widget-title-icon {
    width: 18px;
    height: 18px;
}

.widget-tabs {
    display: flex;
    gap: 12px;
    font-size: 12px;
}

.widget-tab {
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 500;
    transition: color 0.2s;
}

.widget-tab:hover { color: var(--text-primary); }

.widget-tab.active {
    color: var(--accent-blue);
    font-weight: 600;
}

.trending-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.trending-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
}

.trending-item:hover {
    background: var(--bg-hover);
}

.trending-rank {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    color: var(--text-tertiary);
}

.trending-rank.top {
    color: var(--accent-orange);
    font-size: 14px;
}

.trending-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.trending-info { flex: 1; }

.trending-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 1px;
}

.trending-desc {
    font-size: 11px;
    color: var(--text-secondary);
}

/* 福利社样式 */
.benefits-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.benefit-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform 0.2s;
}

.benefit-item:hover {
    transform: translateX(4px);
    border-color: var(--accent-blue);
}

.benefit-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

.benefit-icon-img {
    width: 20px;
    height: 20px;
}

.benefit-content { flex: 1; }

.benefit-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}

.benefit-desc {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 1px;
}

/* ============================================
   产品卡片样式
   ============================================ */
.product-card, .result-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
    will-change: transform;
}

.product-card:hover, .result-card:hover {
    border-color: var(--accent-blue);
    box-shadow: var(--shadow-md);
    transform: scale(1.02);
    z-index: 1;
}

.product-card:hover .product-desc-short,
.product-card:hover .result-desc-short,
.result-card:hover .product-desc-short,
.result-card:hover .result-desc-short {
    display: none;
}

.product-card:hover .product-desc-full,
.product-card:hover .result-desc-full,
.result-card:hover .product-desc-full,
.result-card:hover .result-desc-full {
    display: block;
}

.product-card:hover .arrow-icon,
.result-card:hover .arrow-icon {
    opacity: 1;
}

.product-icon, .result-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    font-size: 20px;
}

.product-content, .result-content {
    flex: 1;
    min-width: 0;
}

.product-header, .result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
    gap: 6px;
}

.product-name, .result-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-desc-short, .result-desc-short {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-desc-full, .result-desc-full {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    display: none;
}

.arrow-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.2s;
    color: var(--text-tertiary);
    width: 14px;
    height: 14px;
}

/* ============================================
   响应式布局
   ============================================ */
@media (max-width: 1200px) {
    .content-layout {
        grid-template-columns: 1fr;
        padding: 24px;
    }
    .sidebar-right { display: none; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
    .sidebar.open { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
    .mobile-menu-btn { display: flex; }
    .header { padding: 16px 20px; }
    .content-layout { padding: 16px; }
}

/* ===== Tab 按钮 ===== */
.widget-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary, #f1f5f9);
    padding: 3px;
    border-radius: 8px;
}

.widget-tab {
    padding: 4px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary, #64748b);
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.widget-tab.active {
    background: var(--bg-primary, #ffffff);
    color: var(--accent-blue, #4a6cf7);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ===== 面板切换核心逻辑 ===== */
.trending-panel {
    display: none;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    animation: fadeIn 0.25s ease;
}

.trending-panel.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== 榜单项 ===== */
.trending-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.trending-item:hover {
    background: var(--bg-hover, rgba(74, 108, 247, 0.06));
    transform: translateX(2px);
}

.trending-rank {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary, #94a3b8);
    background: var(--bg-tertiary, #f1f5f9);
    border-radius: 6px;
    flex-shrink: 0;
}

.trending-rank.top {
    color: #fff;
    background: linear-gradient(135deg, #ff6b6b, #ff9500);
}

.trending-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-tertiary, #f8fafc);
    display: flex;
    align-items: center;
    justify-content: center;
}

.trending-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.trending-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.trending-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trending-desc {
    font-size: 11px;
    color: var(--text-tertiary, #94a3b8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trending-fire {
    font-size: 14px;
    animation: flame 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes flame {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); opacity: 0.8; }
}

/* 夜间模式 */
[data-theme="dark"] .widget-tab.active {
    background: var(--bg-secondary, #1e293b);
    color: var(--accent-blue, #60a5fa);
}

[data-theme="dark"] .trending-rank {
    background: var(--bg-secondary, #334155);
    color: var(--text-tertiary, #64748b);
}


/* ===== 热门榜单：CSS 自动序号（修复 add 函数报错） ===== */
.trending-panel {
    display: none;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    animation: fadeIn 0.25s ease;
}

.trending-panel.active {
    display: flex;
}

/* ===== 广告位样式 ===== */
.ad-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.ad-item {
    display: block;
    border-radius: var(--radius-md, 10px);
    overflow: hidden;
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    transition: all 0.2s ease;
    text-decoration: none;
}

.ad-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-color: var(--accent-blue, #4a6cf7);
}

.ad-image-wrapper {
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--bg-tertiary, #f1f5f9);
}

.ad-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.ad-item:hover .ad-image-wrapper img {
    transform: scale(1.05);
}

.ad-content {
    padding: 5px;
}

.ad-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ad-desc {
    font-size: 11px;
    color: var(--text-tertiary, #94a3b8);
    margin-top: 4px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 夜间模式 */
[data-theme="dark"] .ad-item {
    background: var(--bg-secondary, #1e293b);
    border-color: var(--border-color-dark, #334155);
}

[data-theme="dark"] .ad-item:hover {
    border-color: var(--accent-blue, #60a5fa);
}

/* 保留 trending-fire 动画 */
@keyframes flame {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); opacity: 0.8; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}