/*
Theme Name: 一为导航
Theme URI: https://nav.iowen.cn
Description: 一款简洁优雅的网址导航WordPress主题，支持分类管理、自定义搜索引擎、毛玻璃侧边栏、粒子动画背景等功能。适配宝塔面板WordPress部署。
Version: 1.0.0
Author: 一为
Author URI: https://www.iotheme.cn
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: weinav
Tags: navigation, one-page, custom-background, custom-menu, featured-images
Requires at least: 5.0
Tested up to: 6.5
Requires PHP: 7.4
*/

/* ===== Base Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s, color 0.3s;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; height: auto; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input { font-family: inherit; }

/* ===== CSS Variables ===== */
:root {
  --bg: #f5f5f7;
  --fg: #1d1d1f;
  --card: #ffffff;
  --muted: #86868b;
  --border: #e5e5e7;
  --accent: #f0f0f2;
  --primary: #667eea;
  --primary-dark: #764ba2;
  --sidebar-bg: rgba(255,255,255,0.8);
  --hero-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --card-hover-shadow: 0 8px 24px rgba(102, 126, 234, 0.12);
  --card-hover-border: rgba(102, 126, 234, 0.3);
}
.dark {
  --bg: #0a0a0f;
  --fg: #e5e5e7;
  --card: #141420;
  --muted: #86868b;
  --border: #2a2a3c;
  --accent: #1c1c2e;
  --primary: #667eea;
  --primary-dark: #764ba2;
  --sidebar-bg: rgba(20,20,32,0.8);
  --hero-gradient: linear-gradient(135deg, #4a5dc7 0%, #5c3680 100%);
  --card-hover-shadow: 0 8px 24px rgba(102, 126, 234, 0.08);
  --card-hover-border: rgba(102, 126, 234, 0.2);
}

/* ===== Custom Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(128,128,128,0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(128,128,128,0.4); }

/* ===== Glass Morphism ===== */
.glass {
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
}

/* ===== Header ===== */
.nav-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: 64px;
  transition: all 0.3s;
  background: transparent;
}
.nav-header.scrolled {
  background: var(--sidebar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.nav-header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
  color: var(--fg);
}
.nav-logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  transition: all 0.2s;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--fg);
  background: var(--accent);
}
.nav-actions { display: flex; align-items: center; gap: 8px; }
.nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all 0.2s;
}
.nav-btn:hover { color: var(--fg); background: var(--accent); }
.nav-login-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--fg);
  font-size: 14px;
  transition: background 0.2s;
}
.nav-login-btn:hover { background: var(--border); }
.mobile-menu-btn { display: none; }

/* ===== Hero / Search Banner ===== */
.hero-section {
  margin-top: 64px;
  position: relative;
  height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--hero-gradient);
}
@media (min-width: 640px) { .hero-section { height: 280px; } }
@media (min-width: 768px) { .hero-section { height: 320px; } }

.hero-content {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 640px;
  padding: 0 16px;
  text-align: center;
}
.hero-greeting {
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}
@media (min-width: 640px) { .hero-greeting { font-size: 24px; } }
@media (min-width: 768px) { .hero-greeting { font-size: 30px; } }
.hero-date { color: rgba(255,255,255,0.7); font-size: 13px; margin-bottom: 16px; }

/* Search box */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 9999px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  overflow: visible;
}
.dark .search-box { background: #1f2937; }
.search-box .search-icon {
  position: absolute;
  left: 16px;
  width: 20px;
  height: 20px;
  color: #9ca3af;
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  border: none;
  border-radius: 9999px;
  font-size: 15px;
  color: var(--fg);
  background: transparent;
  outline: none;
}
@media (min-width: 640px) { .search-input { padding: 14px 16px 14px 44px; font-size: 16px; } }
.search-input::placeholder { color: var(--muted); }
.search-btn {
  flex-shrink: 0;
  margin-right: 8px;
  padding: 8px 20px;
  border-radius: 9999px;
  background: linear-gradient(90deg, #667eea, #764ba2);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  transition: opacity 0.2s;
}
@media (min-width: 640px) { .search-btn { padding: 8px 24px; } }
.search-btn:hover { opacity: 0.9; }

/* Engine pills */
.engine-pills {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.engine-pill {
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 13px;
  white-space: nowrap;
  transition: all 0.2s;
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.8);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.engine-pill:hover { background: rgba(255,255,255,0.25); color: #fff; }
.engine-pill.active { background: #fff; color: #667eea; font-weight: 500; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.engine-pill img { width: 14px; height: 14px; border-radius: 2px; }

/* Hot tags */
.hot-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}
.hot-tags span { color: rgba(255,255,255,0.6); font-size: 12px; }
.hot-tag {
  font-size: 12px;
  color: rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.1);
  padding: 2px 8px;
  border-radius: 9999px;
  transition: all 0.2s;
}
.hot-tag:hover { color: #fff; background: rgba(255,255,255,0.2); }

/* Settings panel */
.settings-panel {
  position: absolute;
  top: 48px;
  right: 12px;
  z-index: 40;
  width: 288px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
  border: 1px solid var(--border);
  padding: 16px;
}
.dark .settings-panel { background: var(--card); }
.settings-panel h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.settings-label { font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 8px; display: block; }
.settings-type-btns { display: flex; gap: 6px; margin-bottom: 12px; }
.settings-type-btn {
  flex: 1;
  padding: 6px 0;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  color: var(--muted);
  background: var(--accent);
  transition: all 0.2s;
}
.settings-type-btn.active { background: var(--primary); color: #fff; }
.preset-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.preset-item {
  height: 32px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.2s;
  position: relative;
}
.preset-item.active { border-color: var(--primary); }
.preset-item:hover { border-color: rgba(102,126,234,0.3); }
.preset-item span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: #fff;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.settings-reset {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  transition: color 0.2s;
}
.settings-reset:hover { color: var(--fg); }

/* ===== Main Layout ===== */
.main-wrapper {
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
  padding: 32px 16px;
  display: flex;
  gap: 24px;
  flex: 1;
}

/* ===== Sidebar ===== */
.nav-sidebar {
  width: 180px;
  flex-shrink: 0;
  display: none;
}
@media (min-width: 1024px) { .nav-sidebar { display: block; } }
.sidebar-sticky { position: sticky; top: 80px; }
.sidebar-nav {
  background: var(--sidebar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border: 1px solid rgba(229,229,231,0.5);
}
.dark .sidebar-nav { border-color: rgba(42,42,60,0.5); }
.sidebar-title { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 12px; margin-bottom: 8px; }
.sidebar-list { max-height: calc(100vh - 160px); overflow-y: auto; }
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: rgba(29,29,31,0.7);
  transition: all 0.2s;
  width: 100%;
  text-align: left;
}
.dark .sidebar-item { color: rgba(229,229,231,0.7); }
.sidebar-item:hover { color: var(--fg); background: var(--accent); }
.sidebar-item.active { background: rgba(102,126,234,0.1); color: var(--primary); font-weight: 500; }
.sidebar-item-icon { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar-item.active .sidebar-item-icon { color: var(--primary); }
.sidebar-item .icon-svg { width: 16px; height: 16px; }

/* ===== Content Area ===== */
.nav-content { flex: 1; min-width: 0; }

/* Category section */
.category-section { margin-bottom: 32px; opacity: 0; transform: translateY(16px); transition: opacity 0.5s ease, transform 0.5s ease; }
.category-section.visible { opacity: 1; transform: translateY(0); }
.category-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.category-title { display: flex; align-items: center; gap: 8px; }
.category-bar { width: 4px; height: 16px; border-radius: 2px; }
.category-name { font-size: 18px; font-weight: 700; color: var(--fg); }
.category-more {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s;
}
.category-more:hover { color: var(--primary); }
.category-more svg { width: 12px; height: 12px; }

/* Site cards grid */
.sites-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 640px) { .sites-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1280px) { .sites-grid { grid-template-columns: repeat(4, 1fr); } }

/* Site card */
.site-card {
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid rgba(229,229,231,0.4);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  cursor: pointer;
}
.dark .site-card { border-color: rgba(42,42,60,0.4); }
.site-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-hover-shadow);
  border-color: var(--card-hover-border);
}
.site-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid rgba(229,229,231,0.3);
}
.dark .site-card-icon { background: #1f2937; border-color: rgba(42,42,60,0.3); }
.site-card-icon img { width: 20px; height: 20px; object-fit: contain; }
.site-card-title { font-size: 14px; font-weight: 600; color: var(--fg); margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-card:hover .site-card-title { color: var(--primary); }
.site-card-desc { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== Footer ===== */
.nav-footer {
  margin-top: 48px;
  border-top: 1px solid rgba(229,229,231,0.5);
  background: rgba(255,255,255,0.5);
  padding: 32px 16px;
}
.dark .nav-footer { border-color: rgba(42,42,60,0.5); background: rgba(20,20,32,0.5); }
.nav-footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.nav-footer-copy { font-size: 13px; color: var(--muted); }
.nav-footer-links { display: flex; align-items: center; gap: 16px; }
.nav-footer-links a { color: var(--muted); transition: color 0.2s; }
.nav-footer-links a:hover { color: var(--fg); }

/* ===== Floating Tools ===== */
.floating-tools { position: fixed; bottom: 24px; right: 24px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.float-btn {
  width: 44px;
  height: 44px;
  border-radius: 9999px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg);
  transition: all 0.2s;
  opacity: 0;
  transform: scale(0.8);
}
.float-btn.show { opacity: 1; transform: scale(1); transition: opacity 0.2s, transform 0.2s; }
.float-btn:hover { background: var(--accent); border-color: rgba(102,126,234,0.3); }
.float-btn svg { width: 16px; height: 16px; }

/* ===== Mobile Sidebar Overlay ===== */
.mobile-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity 0.3s;
}
.mobile-sidebar-overlay.active { opacity: 1; }
.mobile-sidebar {
  display: none;
  position: fixed;
  left: 0;
  top: 64px;
  bottom: 0;
  z-index: 50;
  width: 240px;
  background: var(--card);
  box-shadow: 4px 0 20px rgba(0,0,0,0.1);
  transform: translateX(-100%);
  transition: transform 0.3s;
  overflow-y: auto;
  padding: 16px;
}
.mobile-sidebar.active { transform: translateX(0); }
@media (max-width: 1023px) {
  .mobile-sidebar-overlay, .mobile-sidebar { display: block; }
  .mobile-menu-btn { display: flex !important; }
}

/* ===== Particle Animation ===== */
@keyframes float-particle {
  0%, 100% { transform: translateY(0) translateX(0); opacity: 0; }
  10% { opacity: var(--particle-opacity, 0.3); }
  90% { opacity: var(--particle-opacity, 0.3); }
  50% { transform: translateY(-60px) translateX(20px); }
}
.particle {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  animation: float-particle var(--duration, 6s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

/* ===== Color picker row ===== */
.color-picker-row { display: flex; align-items: center; gap: 8px; }
.color-picker-row input[type="color"] { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; padding: 0; }
.color-picker-row input[type="text"] { flex: 1; height: 32px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--fg); font-size: 12px; }

/* Image upload area */
.upload-area {
  width: 100%;
  height: 80px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  transition: all 0.2s;
  cursor: pointer;
}
.upload-area:hover { border-color: rgba(102,126,234,0.5); color: var(--fg); }
.upload-area svg { width: 16px; height: 16px; }

/* ===== Settings button on hero ===== */
.hero-settings-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 30;
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  background: rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.7);
  transition: all 0.2s;
}
.hero-settings-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }
.hero-settings-btn svg { width: 16px; height: 16px; }

/* Settings header row */
.settings-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }

/* ===== WordPress Admin Bar fix ===== */
body.admin-bar .nav-header { top: 32px; }
@media (max-width: 782px) { body.admin-bar .nav-header { top: 46px; } }
body.admin-bar .hero-section { margin-top: 96px; }
@media (max-width: 782px) { body.admin-bar .hero-section { margin-top: 110px; } }

/* ===== Heart icon in footer ===== */
.heart-icon { color: #ef4444; fill: #ef4444; }
