/* ==================== 基础变量 ==================== */
:root {
    --bg-primary: #F8FAFC;
    --bg-secondary: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F1F5F9;
    --bg-input: #F1F5F9;
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --border-color: #E2E8F0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --gradient-primary: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
    --gradient-hero: linear-gradient(135deg, #6366F1 0%, #8B5CF6 50%, #A855F7 100%);
    --accent-primary: #6366F1;
    --accent-secondary: #8B5CF6;
    --accent-success: #10B981;
    --accent-danger: #EF4444;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --sidebar-width: 240px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="dark"] {
    --bg-primary: #0F172A;
    --bg-secondary: #1E293B;
    --bg-card: #1E293B;
    --bg-card-hover: #334155;
    --bg-input: #334155;
    --text-primary: #F8FAFC;
    --text-secondary: #CBD5E1;
    --text-muted: #64748B;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
}

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

html {
    scroll-behavior: smooth;
    font-size: 14px;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }

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

/* ==================== 滚动条 ==================== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ==================== 左侧导航 ==================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
    z-index: 100;
    overflow-y: auto;
}

/* Logo */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    margin-bottom: 24px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366F1, #8B5CF6);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-icon img {
    width: 24px;
    height: 24px;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.logo-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* 导航 */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

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

.nav-item.active {
    background: var(--gradient-primary);
    color: white;
}

.nav-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.nav-label {
    flex: 1;
}

/* 分隔线 */
.sidebar-divider {
    height: 1px;
    background: var(--border-color);
    margin: 16px 12px;
}

/* 分类列表 */
.sidebar-cats {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.cat-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.cat-link:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

.cat-link.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
}

.cat-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.cat-name {
    flex: 1;
}

.cat-count {
    font-size: 0.65rem;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 10px;
}

.cat-link.active .cat-count {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary);
}

/* 页脚 */
.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    margin-top: 16px;
}

.theme-btn {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.theme-btn:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

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

/* ==================== Hero区域 ==================== */
.hero {
    padding: 48px 0 40px;
    background: var(--gradient-hero);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.hero .container {
    position: relative;
    z-index: 1;
    text-align: center;
}

.hero-title {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    margin-bottom: 8px;
}

.hero-subtitle {
    font-size: 1rem;
    color: rgba(255,255,255,0.9);
    margin-bottom: 24px;
}

.search-box {
    display: flex;
    max-width: 480px;
    margin: 0 auto 16px;
    background: white;
    border-radius: 50px;
    padding: 6px 6px 6px 20px;
    box-shadow: var(--shadow-lg);
}

.search-icon {
    font-size: 1.1rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.95rem;
    background: transparent;
    color: var(--text-primary);
    min-width: 0;
}

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

.search-btn {
    padding: 10px 24px;
    background: var(--gradient-primary);
    color: white;
    font-weight: 600;
    font-size: 0.88rem;
    border-radius: 50px;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.search-btn:hover {
    transform: scale(1.02);
}

.search-hints {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: rgba(255,255,255,0.85);
    font-size: 0.8rem;
    flex-wrap: wrap;
}

.hint-tag {
    padding: 4px 12px;
    background: rgba(255,255,255,0.2);
    border-radius: 20px;
    font-size: 0.75rem;
    transition: all 0.2s ease;
    cursor: pointer;
    color: white;
}

.hint-tag:hover {
    background: rgba(255,255,255,0.35);
}

/* ==================== 内容区块 ==================== */
.section {
    padding: 32px 0;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.title-icon {
    font-size: 1.2rem;
}

.section-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ==================== 热门推荐 ==================== */
.hot-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
}

/* ==================== 工具卡片 ==================== */
.tool-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
}

.tool-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-primary);
}

.tool-card:active {
    transform: scale(0.98);
}

/* 图标 */
.tool-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.4rem;
}

.tool-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

.tool-icon .fallback-icon {
    display: none;
}

.tool-icon .fallback-icon.show {
    display: flex;
}

/* 文字 */
.tool-info {
    flex: 1;
    min-width: 0;
}

.tool-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tool-desc {
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tool-hot-tag {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 6px;
    background: linear-gradient(135deg, #F59E0B, #FBBF24);
    color: white;
    font-size: 0.55rem;
    font-weight: 700;
    border-radius: 4px;
    text-transform: uppercase;
}

/* ==================== 分类区块 ==================== */
.cat-block {
    margin-bottom: 40px;
    padding-bottom: 40px;
    border-bottom: 1px solid var(--border-color);
}

.cat-block:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.cat-block-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.cat-block-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.cat-block-icon {
    font-size: 1.3rem;
}

.cat-block-name {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.cat-block-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: 10px;
}

.cat-block-subtabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.cat-block-subtab {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.cat-block-subtab:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.cat-block-subtab.active {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
}

.cat-block-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}

/* 工具网格 */
.tools-grid {
    display: flex;
    flex-direction: column;
}

/* 无结果 */
.no-result {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.no-result-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ==================== 关于区域 ==================== */
.about-section {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.about-content {
    text-align: center;
    max-width: 500px;
    margin: 0 auto;
}

.about-content p {
    color: var(--text-secondary);
    font-size: 0.92rem;
    margin-bottom: 24px;
}

.about-features {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
}

.about-feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-primary);
}

.feature-icon {
    font-size: 1.6rem;
}

.about-feature span:last-child {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ==================== 页脚 ==================== */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 24px 0;
    text-align: center;
}

.footer p {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.footer-hint {
    margin-top: 4px;
    font-size: 0.72rem !important;
    opacity: 0.7;
}

/* ==================== 返回顶部 ==================== */
.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 99;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-2px);
}

/* ==================== 弹窗 ==================== */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal.visible {
    opacity: 1;
    visibility: visible;
}

.modal-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 420px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 28px;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal.visible .modal-content {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--accent-danger);
    color: white;
}

.modal-body {
    text-align: center;
}

.modal-body .tool-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    border-radius: 16px;
    font-size: 2rem;
}

.modal-body .tool-name {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.modal-body .tool-desc {
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin-bottom: 16px;
}

/* ==================== 广告 ==================== */
.ad-container {
    display: none;
    margin: 0 auto;
    max-width: 100%;
    text-align: center;
    padding: 12px 20px;
}

.ad-container.ad-loaded {
    display: block;
}

.ad-container[data-ad-slot="hero_bottom"],
.ad-container[data-ad-slot="tools_grid_top"],
.ad-container[data-ad-slot="tools_grid_bottom"] {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.ad-container.float-ad {
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 98;
    padding: 0;
}

.ad-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
}

.ad-popup-content {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 480px;
    width: 90%;
}

.ad-popup-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-container::before {
    content: '广告';
    display: block;
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.ad-container.float-ad::before {
    display: none;
}

/* ==================== 加载动画 ==================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.tool-card {
    animation: fadeIn 0.35s ease forwards;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    transition: opacity 0.3s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
}

.loading-content .loading-spinner {
    width: 40px;
    height: 40px;
    border-width: 3px;
    margin-bottom: 16px;
}

.loading-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* 图片加载占位 */
.tool-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    background: var(--bg-input);
    transition: opacity 0.2s ease;
}

.tool-icon img[src=""] {
    opacity: 0;
}

/* ==================== 移动端菜单按钮 ==================== */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 101;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mobile-menu-btn:hover {
    background: var(--bg-card-hover);
}

.mobile-menu-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.2s ease;
}

.mobile-menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

.mobile-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-overlay.visible {
    display: block;
    opacity: 1;
}

/* ==================== 响应式 ==================== */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 200px;
    }
    
    .hot-grid,
    .cat-block-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
    }
    
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
    }

    .container {
        padding: 0 16px;
    }

    .hero {
        padding: 56px 0 28px;
    }

    .hero-title {
        font-size: 1.5rem;
    }

    .hero-subtitle {
        font-size: 0.85rem;
    }

    .search-box {
        max-width: 100%;
        margin: 0 16px 16px;
    }
    
    .search-input {
        font-size: 0.9rem;
    }
    
    .search-btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }

    .section {
        padding: 24px 0;
    }

    .hot-grid,
    .cat-block-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .tool-card {
        padding: 12px;
        gap: 10px;
    }
    
    .tool-icon {
        width: 40px;
        height: 40px;
        border-radius: 10px;
        font-size: 1.2rem;
    }
    
    .tool-name {
        font-size: 0.85rem;
    }
    
    .tool-desc {
        font-size: 0.7rem;
    }

    .cat-block {
        margin-bottom: 28px;
        padding-bottom: 28px;
    }
    
    .cat-block-header {
        gap: 8px;
    }
    
    .cat-block-title {
        font-size: 1rem;
    }

    .about-features {
        gap: 10px;
    }
    
    .about-feature {
        padding: 12px 16px;
    }

    .back-to-top {
        bottom: 16px;
        right: 16px;
        width: 36px;
        height: 36px;
    }
    
    .modal-content {
        width: 95%;
        padding: 20px;
    }
}
