/* ================================================
   TP-Nav 网址导航系统 - 默认主题样式
   现代设计 | 响应式 | 主题变量
   ================================================ */

/* CSS变量 - 主题色 */
:root {
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1d4ed8;
    --bg: #f0f2f5;
    --bg-card: #ffffff;
    --bg-hover: #f8fafc;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 30px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
    --shadow-xl: 0 20px 60px rgba(0,0,0,.12);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-primary: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    --header-bg: rgba(255,255,255,.85);
    --max-width: 1200px;
    --transition: all .25s cubic-bezier(.4,0,.2,1);
}

/* 暗色模式变量 */
[data-theme="dark"] {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --shadow: 0 1px 3px rgba(0,0,0,.3);
    --shadow-lg: 0 10px 30px rgba(0,0,0,.4);
    --header-bg: rgba(30,41,59,.85);
}

/* 全局重置 */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans SC', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background .3s ease, color .3s ease;
    min-height: 100vh;
}
a { color: inherit; text-decoration: none; transition: var(--transition); }
img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input,textarea,select { font-family: inherit; font-size: 14px; }
ul,ol { list-style: none; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* 容器 */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }

/* 头部 */
.header {
    position: sticky; top: 0; z-index: 100;
    background: var(--header-bg);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}
.header-inner {
    max-width: var(--max-width); margin: 0 auto;
    padding: 0 20px; height: 60px;
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.logo { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 700; color: var(--primary); white-space: nowrap; }
.logo .logo-icon {
    width: 32px; height: 32px; border-radius: 8px;
    background: var(--gradient-primary);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 18px;
}
.header-nav { display: flex; align-items: center; gap: 4px; }
.header-nav a {
    padding: 6px 14px; border-radius: 20px; font-size: 14px; font-weight: 500;
    color: var(--text-secondary);
}
.header-nav a:hover, .header-nav a.active { background: var(--primary); color: #fff; }
.header-actions { display: flex; align-items: center; gap: 8px; }

/* 主题切换按钮 */
.theme-toggle {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-hover); color: var(--text-secondary);
    transition: var(--transition); font-size: 18px;
}
.theme-toggle:hover { background: var(--primary); color: #fff; transform: rotate(180deg); }

/* 按钮 */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 20px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
    transition: var(--transition); border: 1px solid transparent; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: var(--bg-hover); color: var(--text-secondary); }
.btn-ghost:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 32px; font-size: 16px; }
.btn-block { display: flex; width: 100%; }

/* 搜索区域 */
.search-section {
    padding: 48px 0 32px; text-align: center;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}
.search-title { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.search-subtitle { color: var(--text-secondary); font-size: 15px; margin-bottom: 24px; }
.search-box {
    max-width: 600px; margin: 0 auto; position: relative;
    display: flex; align-items: center;
    background: var(--bg); border: 2px solid var(--border);
    border-radius: 50px; padding: 4px 4px 4px 20px;
    transition: var(--transition);
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37,99,235,.1); }
.search-box input {
    flex: 1; border: none; background: none; outline: none;
    font-size: 15px; color: var(--text); padding: 10px 0;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-btn {
    padding: 10px 24px; border-radius: 50px;
    background: var(--primary); color: #fff; font-weight: 500; font-size: 14px;
    transition: var(--transition);
}
.search-btn:hover { background: var(--primary-dark); }
.search-suggestions {
    position: absolute; top: 100%; left: 0; right: 0; margin-top: 8px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    overflow: hidden; display: none; text-align: left; z-index: 50;
}
.search-suggestions.show { display: block; }
.search-suggestions .item { padding: 10px 16px; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.search-suggestions .item:hover { background: var(--bg-hover); }
.search-suggestions .item img { width: 20px; height: 20px; border-radius: 4px; }

/* 搜索引擎切换 */
.search-engines { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.search-engine {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-hover); font-size: 14px; font-weight: 700; color: var(--text-secondary);
    transition: var(--transition); cursor: pointer;
}
.search-engine.active, .search-engine:hover { background: var(--primary); color: #fff; }

/* 分类标签栏 */
.category-bar {
    background: var(--bg-card); border-bottom: 1px solid var(--border);
    position: sticky; top: 60px; z-index: 90;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.category-bar::-webkit-scrollbar { display: none; }
.category-bar-inner {
    max-width: var(--max-width); margin: 0 auto; padding: 0 20px;
    display: flex; align-items: center; gap: 4px; height: 48px;
}
.category-bar a {
    padding: 6px 16px; border-radius: 20px; font-size: 14px; white-space: nowrap;
    color: var(--text-secondary); font-weight: 500;
}
.category-bar a:hover { background: var(--bg-hover); color: var(--text); }
.category-bar a.active { background: var(--primary); color: #fff; }

/* 主内容区 */
.main-content { padding: 24px 0 48px; }

/* 分类区块 */
.section { margin-bottom: 32px; }
.section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
}
.section-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 18px; font-weight: 700;
}
.section-title .icon {
    width: 28px; height: 28px; border-radius: 8px;
    background: var(--gradient-primary);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 14px;
}
.section-title .icon i { font-size: 14px; }
.section-more { font-size: 13px; color: var(--text-muted); }
.section-more:hover { color: var(--primary); }

/* 站点卡片网格 */
.site-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}
.site-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
    display: flex; flex-direction: column; align-items: center; text-align: center;
    transition: var(--transition); cursor: pointer; position: relative; overflow: hidden;
}
.site-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: var(--gradient-primary); opacity: 0; transition: var(--transition);
}
.site-card:hover {
    transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--primary-light);
}
.site-card:hover::before { opacity: 1; }
.site-icon {
    width: 40px; height: 40px; border-radius: 10px; margin-bottom: 10px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-hover); font-size: 20px; font-weight: 700; color: var(--primary);
    overflow: hidden;
}
.site-icon img { width: 100%; height: 100%; object-fit: cover; }
.site-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.site-desc { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.site-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.site-tag { font-size: 10px; padding: 2px 8px; border-radius: 10px; background: var(--bg-hover); color: var(--text-secondary); }
.site-badges { position: absolute; top: 8px; right: 8px; display: flex; flex-direction: column; gap: 4px; }
.badge { font-size: 10px; padding: 2px 6px; border-radius: 8px; font-weight: 600; }
.badge-hot { background: #fee2e2; color: #dc2626; }
.badge-rec { background: #dbeafe; color: #2563eb; }
[data-theme="dark"] .badge-hot { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .badge-rec { background: #1e3a8a; color: #93c5fd; }

/* 推荐站点横向滚动 */
.recommend-section { background: var(--bg-card); border-radius: var(--radius-lg); padding: 24px; margin-bottom: 24px; box-shadow: var(--shadow); }
.recommend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.recommend-card {
    display: flex; align-items: center; gap: 12px;
    background: var(--bg-hover); border-radius: var(--radius);
    padding: 12px 16px; transition: var(--transition);
}
.recommend-card:hover { background: var(--bg-card); box-shadow: var(--shadow-lg); transform: translateX(4px); }

/* 页脚 */
.footer {
    background: var(--bg-card); border-top: 1px solid var(--border);
    padding: 32px 0; margin-top: 48px; text-align: center;
}
.footer-content { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }
.footer-links { display: flex; justify-content: center; gap: 24px; margin-bottom: 16px; }
.footer-links a { color: var(--text-secondary); font-size: 14px; }
.footer-links a:hover { color: var(--primary); }
.footer-copyright { color: var(--text-muted); font-size: 13px; }

/* AI助手浮窗 */
.ai-fab {
    position: fixed; bottom: 24px; right: 24px; z-index: 200;
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--gradient-primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; cursor: pointer; box-shadow: var(--shadow-xl);
    transition: var(--transition); animation: pulse 2s infinite;
}
.ai-fab:hover { transform: scale(1.1); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(37,99,235,.4); } 50% { box-shadow: 0 0 0 12px rgba(37,99,235,0); } }

.ai-panel {
    position: fixed; bottom: 90px; right: 24px; z-index: 201;
    width: 380px; max-width: calc(100vw - 48px); height: 520px; max-height: 70vh;
    background: var(--bg-card); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl); display: none; flex-direction: column;
    overflow: hidden; animation: slideUp .3s ease;
}
.ai-panel.show { display: flex; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.ai-panel-header {
    padding: 16px; background: var(--gradient-primary); color: #fff;
    display: flex; align-items: center; justify-content: space-between;
}
.ai-panel-header .title { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.ai-panel-close { color: #fff; font-size: 20px; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.ai-panel-close:hover { background: rgba(255,255,255,.2); }
.ai-panel-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.ai-message { display: flex; gap: 8px; max-width: 85%; }
.ai-message.user { margin-left: auto; flex-direction: row-reverse; }
.ai-message .avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.ai-message.user .avatar { background: var(--primary); color: #fff; }
.ai-message.assistant .avatar { background: var(--gradient-primary); color: #fff; }
.ai-message .content { padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.5; }
.ai-message.user .content { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.ai-message.assistant .content { background: var(--bg-hover); border-bottom-left-radius: 4px; }
.ai-panel-footer { padding: 12px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.ai-panel-footer input { flex: 1; border: 1px solid var(--border); border-radius: 24px; padding: 8px 16px; outline: none; background: var(--bg); color: var(--text); }
.ai-panel-footer input:focus { border-color: var(--primary); }
.ai-panel-footer button { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ai-typing { display: flex; gap: 4px; padding: 10px 14px; }
.ai-typing span { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); animation: typing 1.4s infinite; }
.ai-typing span:nth-child(2) { animation-delay: .2s; }
.ai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes typing { 0%,60%,100% { transform: scale(.8); opacity: .5; } 30% { transform: scale(1.2); opacity: 1; } }

/* 分页 */
.pagination { display: flex; justify-content: center; align-items: center; gap: 4px; margin-top: 32px; }
.pagination a, .pagination span {
    min-width: 36px; height: 36px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; padding: 0 10px;
    border: 1px solid var(--border); background: var(--bg-card); color: var(--text-secondary);
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 表单 */
.form-group { margin-bottom: 20px; }
.form-label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 500; color: var(--text); }
.form-input, .form-textarea, .form-select {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: var(--bg-card); color: var(--text);
    outline: none; transition: var(--transition); font-size: 14px;
}
.form-input:focus, .form-textarea:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* 登录注册卡片 */
.auth-card {
    max-width: 420px; margin: 48px auto; padding: 40px;
    background: var(--bg-card); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.auth-title { text-align: center; font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.auth-subtitle { text-align: center; color: var(--text-secondary); margin-bottom: 28px; font-size: 14px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-secondary); }
.auth-footer a { color: var(--primary); font-weight: 500; }

/* 空状态 */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 48px; margin-bottom: 16px; opacity: .3; }
.empty-state .text { font-size: 15px; }

/* 响应式 */
@media (max-width: 768px) {
    .header-nav { display: none; }
    .search-title { font-size: 22px; }
    .site-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
    .site-card { padding: 12px; }
    .recommend-grid { grid-template-columns: 1fr; }
    .ai-panel { right: 8px; bottom: 80px; width: calc(100vw - 16px); }
    .ai-fab { right: 16px; bottom: 16px; }
    .auth-card { margin: 20px; padding: 24px; }
    .section-title { font-size: 16px; }
}
@media (max-width: 480px) {
    .site-grid { grid-template-columns: repeat(2, 1fr); }
    .category-bar-inner { padding: 0 12px; }
    .search-section { padding: 24px 0; }
}

/* 工具类 */
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; }
.flex { display: flex; } .items-center { align-items: center; } .gap-2 { gap: 8px; }
.hidden { display: none !important; }
