/* ============================================================
 *  常用软件下载导航 - 样式表
 * ============================================================ */

/* ===== CSS 变量 ===== */
:root {
    --bg-body: #f4f7fc;
    --bg-card: #ffffff;
    --bg-header: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e9edf4;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 16px 48px rgba(0, 0, 0, 0.12);
    --radius-card: 14px;
    --radius-btn: 8px;
    --transition: all 0.25s ease;
    --primary: #4f7df3;
    --primary-dark: #3a5fcb;
    --primary-light: #eef3ff;
    --tag-bg: #f1f4f9;
    --tag-active: #4f7df3;
    --tag-active-text: #ffffff;
    --scrollbar-track: #e9edf4;
    --scrollbar-thumb: #c1c9d6;
    --ai-glow: rgba(79, 125, 243, 0.12);

    /* 返回顶部按钮 */
    --totop-bg: var(--primary);
    --totop-color: #fff;
    --totop-shadow: 0 4px 16px rgba(79, 125, 243, 0.35);
}

[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-header: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border-color: #334155;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 16px 48px rgba(0, 0, 0, 0.5);
    --primary-light: #1e293b;
    --tag-bg: #334155;
    --tag-active: #4f7df3;
    --tag-active-text: #ffffff;
    --scrollbar-track: #1e293b;
    --scrollbar-thumb: #475569;
    --ai-glow: rgba(79, 125, 243, 0.18);
    --totop-shadow: 0 4px 16px rgba(79, 125, 243, 0.5);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.3s ease;
    line-height: 1.6;
    min-height: 100vh;
    padding: 0 20px 40px;
}

/* ===== 滚动条美化 ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 10px;
}

/* ===== 容器 ===== */
.container {
    max-width: 1460px;
    margin: 0 auto;
}

/* ===== 头部 ===== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0 16px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.logo-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}
.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.logo-text {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #4f7df3, #6c5ce7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.logo-text span {
    font-weight: 400;
    color: var(--text-secondary);
    -webkit-text-fill-color: var(--text-secondary);
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.refresh-btn-header {
    background: var(--tag-bg);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-secondary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.refresh-btn-header:hover {
    background: var(--border-color);
    transform: rotate(60deg);
}

.theme-toggle {
    background: var(--tag-bg);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-secondary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.theme-toggle:hover {
    background: var(--border-color);
    transform: rotate(20deg);
}
.stats-badge {
    font-size: 13px;
    color: var(--text-muted);
    background: var(--tag-bg);
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 500;
    white-space: nowrap;
}

/* ===== 搜索栏 ===== */
.search-section {
    margin-bottom: 24px;
}
.search-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border-radius: 14px;
    padding: 4px 4px 4px 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    max-width: 620px;
    margin: 0 auto;
}
.search-wrapper:focus-within {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}
.search-wrapper i {
    color: var(--text-muted);
    font-size: 16px;
    margin-right: 12px;
    flex-shrink: 0;
}
.search-wrapper input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    padding: 14px 0;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
    min-width: 0;
}
.search-wrapper input::placeholder {
    color: var(--text-muted);
}
.search-wrapper button {
    background: var(--primary);
    border: none;
    color: #fff;
    padding: 10px 24px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
}
.search-wrapper button:hover {
    background: var(--primary-dark);
    transform: scale(0.97);
}

/* ===== 分类标签 ===== */
.categories {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 10px;
    margin-bottom: 28px;
    padding-bottom: 4px;
}
.cat-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 9px 18px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
    white-space: nowrap;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
    line-height: 1.4;
}
.cat-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}
.cat-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 4px 14px rgba(79, 125, 243, 0.3);
}
.cat-btn .count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 4px;
    padding: 0 4px;
    background: rgba(0, 0, 0, 0.06);
    transition: background 0.25s ease;
    vertical-align: middle;
}
.cat-btn:hover .count {
    background: rgba(79, 125, 243, 0.1);
}
.cat-btn.active .count {
    background: rgba(255, 255, 255, 0.2);
}

/* 暗色模式适配分类按钮 */
[data-theme="dark"] .cat-btn .count {
    background: rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .cat-btn:hover .count {
    background: rgba(79, 125, 243, 0.15);
}
.cat-btn.active {
    background: var(--tag-active);
    color: var(--tag-active-text);
    box-shadow: 0 4px 12px rgba(79, 125, 243, 0.3);
}
.cat-btn .count {
    font-size: 12px;
    opacity: 0.6;
    margin-left: 4px;
    font-weight: 400;
}
.cat-btn.active .count {
    opacity: 0.8;
}

/* ===== 网格头部 ===== */
.grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}
.grid-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}
.grid-header .result-count {
    font-size: 14px;
    color: var(--text-muted);
}

/* ===== 软件网格 ===== */
.software-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 16px;
    margin-bottom: 12px;
}

/* ===== 卡片 ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-card);
    padding: 16px 10px 14px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    cursor: default;
    min-width: 0;
    overflow: hidden;
}
.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary);
}
.card .icon-wrap {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #fff;
    margin-bottom: 10px;
    flex-shrink: 0;
    transition: var(--transition);
}
.card:hover .icon-wrap {
    transform: scale(1.05) rotate(-2deg);
}
.card .name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.3;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.card .desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.3;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    display: box;
    line-clamp: 2;
    box-orient: vertical;
    overflow: hidden;
    min-height: 28px;
    width: 100%;
}
.card .download-btn {
    background: var(--primary-light);
    border: none;
    color: var(--primary);
    padding: 6px 12px;
    border-radius: var(--radius-btn);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    justify-content: center;
    white-space: nowrap;
}
.card .download-btn:hover {
    background: var(--primary);
    color: #fff;
    transform: scale(0.97);
}
.card .download-btn i {
    font-size: 11px;
}

/* ---- AI 工具卡片微光效 ---- */
.card.ai-card {
    border-color: rgba(79, 125, 243, 0.15);
}
.card.ai-card:hover {
    border-color: var(--primary);
    box-shadow: 0 16px 48px var(--ai-glow);
}
.card.ai-card .icon-wrap {
    background: linear-gradient(135deg, #4f7df3, #6c5ce7) !important;
}

/* 空状态 */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}
.empty-state h3 {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.empty-state p {
    font-size: 14px;
    margin-bottom: 24px;
}

/* 搜索引擎按钮容器 */
.search-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.search-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 14px 22px;
    border-radius: 14px;
    text-decoration: none;
    transition: all 0.25s ease;
    min-width: 200px;
}
.search-action-btn .btn-icon {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
}
.search-action-btn .btn-icon i {
    font-size: 16px !important;
    margin: 0 !important;
    opacity: 1 !important;
}
.search-action-btn .btn-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.search-action-btn .btn-line1 {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
}
.search-action-btn .btn-line2 {
    font-size: 11px;
    font-weight: 400;
    opacity: 0.85;
    line-height: 1.3;
}
.search-action-btn.bing-btn {
    background: #168de2;
    color: #fff;
}
.search-action-btn.bing-btn:hover {
    background: #0f6db3;
    transform: scale(0.97);
    box-shadow: 0 4px 14px rgba(22, 141, 226, 0.35);
}
.search-action-btn.baidu-btn {
    background: var(--primary);
    color: #fff;
}
.search-action-btn.baidu-btn:hover {
    background: var(--primary-dark);
    transform: scale(0.97);
    box-shadow: 0 4px 14px rgba(79, 125, 243, 0.35);
}

/* ===== 返回顶部按钮 ===== */
.back-to-top {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--totop-bg);
    color: var(--totop-color);
    border: none;
    font-size: 18px;
    cursor: pointer;
    box-shadow: var(--totop-shadow);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    z-index: 100;
}
.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.back-to-top:hover {
    transform: translateY(-2px) scale(1.05);
    filter: brightness(1.1);
}

/* ===== 底部 ===== */
.footer {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}
.footer a {
    color: var(--primary);
    text-decoration: none;
}
.footer a:hover {
    text-decoration: underline;
}

/* ===== 入场动画 ===== */
.card {
    opacity: 0;
    animation: fadeUp 0.4s ease forwards;
}
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 尊重用户动画偏好 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    html {
        scroll-behavior: auto;
    }
    .card {
        opacity: 1;
    }
}

/* ===== 响应式 ===== */
@media (max-width: 1380px) {
    .software-grid {
        grid-template-columns: repeat(7, 1fr);
    }
}
@media (max-width: 1200px) {
    .software-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}
@media (max-width: 1024px) {
    .software-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}
@media (max-width: 860px) {
    .software-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .card .icon-wrap {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
    .card .name {
        font-size: 12px;
    }
}
@media (max-width: 640px) {
    .software-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
    .container {
        padding: 0 4px;
    }
    body {
        padding: 0 12px 30px;
    }
    .header .logo-text {
        font-size: 18px;
    }
    .search-wrapper {
        padding: 2px 2px 2px 14px;
    }
    .search-wrapper input {
        padding: 12px 0;
        font-size: 14px;
    }
    .search-wrapper button {
        padding: 8px 16px;
        font-size: 13px;
    }
    .cat-btn {
        font-size: 13px;
        padding: 6px 14px;
    }
    .card {
        padding: 14px 8px 12px;
    }
    .card .icon-wrap {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    .card .desc {
        -webkit-line-clamp: 1;
        min-height: 18px;
    }
    .grid-header h2 {
        font-size: 16px;
    }
    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 38px;
        height: 38px;
        font-size: 15px;
    }
}
@media (max-width: 460px) {
    .software-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .header-actions .stats-badge {
        display: none;
    }
    .card .download-btn {
        font-size: 10px;
        padding: 5px 8px;
    }
}