/* ========================================
   新尧 - 网盘资源搜索 样式表
   极简风格 · 暗色主题
   ======================================== */

/* === 设计令牌 === */
:root {
  /* 颜色 */
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-card: #1a1f2e;
  --bg-card-hover: #1f2537;
  --bg-input: #151b2b;
  --border-color: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #818cf8;
  --accent-hover: #6366f1;
  --accent-glow: rgba(129, 140, 248, 0.15);
  --success: #34d399;
  --danger: #f87171;

  /* 网盘品牌色 */
  --color-baidu: #306cff;
  --color-aliyun: #ff6a00;
  --color-quark: #536dfe;
  --color-tianyi: #2196f3;
  --color-uc: #ff9800;
  --color-115: #ff5722;
  --color-pikpak: #6366f1;
  --color-xunlei: #1a73e8;
  --color-123: #00bcd4;
  --color-magnet: #ef5350;
  --color-ed2k: #ab47bc;
  --color-mobile: #66bb6a;
  --color-others: #78909c;

  /* 间距 */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* 圆角 */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 100px;

  /* 字体 */
  --font-sans: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;

  /* 动画 */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* === 亮色主题 === */
[data-theme="light"] {
  --bg-primary: #f8f9fb;
  --bg-secondary: #f0f2f5;
  --bg-card: #ffffff;
  --bg-card-hover: #f5f6f8;
  --bg-input: #f0f2f5;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.15);
  --text-primary: #1a1a2e;
  --text-secondary: #546178;
  --text-muted: #8896ab;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.12);
}

[data-theme="light"] .header {
  background: rgba(248, 249, 251, 0.85);
}

[data-theme="light"] .skeleton-line {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, rgba(0, 0, 0, 0.03) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
}

[data-theme="light"] .merged-link-item {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .toast {
  background: #1a1a2e;
  color: #fff;
  border-color: transparent;
}

/* === 重置与基础 === */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  font-size: inherit;
}

/* === 顶部导航 === */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11, 15, 25, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
  height: 56px;
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1.1rem;
  transition: opacity 0.2s;
}

.logo:hover {
  opacity: 0.8;
}

.logo-icon {
  font-size: 1.2rem;
}

.logo-text {
  letter-spacing: -0.02em;
}

.header-subtitle {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 400;
}

.header-spacer {
  flex: 1;
}

/* 主题切换按钮 */
.theme-toggle {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-secondary);
  transition: color 0.2s, background 0.2s;
}

.theme-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.theme-icon {
  width: 18px;
  height: 18px;
  transition: transform 0.3s var(--ease-spring), opacity 0.2s;
}

/* 暗色主题：显示太阳（切换到亮色），隐藏月亮 */
.icon-sun {
  display: block;
}

.icon-moon {
  display: none;
}

/* 亮色主题：显示月亮（切换到暗色），隐藏太阳 */
[data-theme="light"] .icon-sun {
  display: none;
}

[data-theme="light"] .icon-moon {
  display: block;
}

/* 全局过渡 */
body,
.header,
.result-card,
.merged-link-item,
.filter-tab,
.search-input,
.toast,
.skeleton-card,
.skeleton-line {
  transition: background-color 0.3s, border-color 0.3s, color 0.3s, box-shadow 0.3s;
}

/* === 主内容 === */
.main {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* === 搜索区域 === */
.search-section {
  padding: var(--space-3xl) 0 var(--space-xl);
  text-align: center;
}

.search-title {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

.search-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: var(--space-xl);
}

.search-box {
  display: flex;
  gap: var(--space-sm);
  max-width: 640px;
  margin: 0 auto;
}

.search-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 48px;
  padding: 0 40px 0 42px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-clear {
  position: absolute;
  right: 10px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.2rem;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, color 0.2s;
}

.search-input:not(:placeholder-shown)~.search-clear {
  opacity: 1;
  pointer-events: auto;
}

.search-clear:hover {
  color: var(--text-primary);
}

.search-btn {
  height: 48px;
  padding: 0 28px;
  background: var(--accent);
  color: #fff;
  font-weight: 500;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
  transition: background 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 80px;
  flex-shrink: 0;
}

.search-btn:hover {
  background: var(--accent-hover);
}

.search-btn:active {
  transform: scale(0.97);
}

.search-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* 旋转加载动画 */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* === 搜索历史 === */
.search-history {
  max-width: 640px;
  margin: var(--space-md) auto 0;
  text-align: left;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.history-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.history-clear {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: color 0.2s;
}

.history-clear:hover {
  color: var(--text-secondary);
}

.history-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.history-tag {
  padding: 4px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.history-tag:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* === 广告位 === */
.ad-slot {
  max-width: 960px;
  margin: var(--space-lg) auto;
  min-height: 0;
  text-align: center;
}

.ad-slot:empty {
  display: none;
}

/* === 筛选栏 === */
.filter-section {
  margin-bottom: var(--space-lg);
}

.filter-bar {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding-bottom: var(--space-xs);
  scrollbar-width: none;
  cursor: grab;
}

.filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 0.82rem;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}

.filter-tab:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.filter-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.filter-tab .badge {
  background: rgba(255, 255, 255, 0.15);
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 500;
}

.filter-tab.active .badge {
  background: rgba(255, 255, 255, 0.25);
}

/* === 结果统计 === */
.result-stats {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

/* === 骨架屏 === */
.skeleton-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.skeleton-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skeleton-line {
  height: 14px;
  background: linear-gradient(90deg, var(--bg-secondary) 25%, rgba(255, 255, 255, 0.04) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  border-radius: 4px;
  animation: shimmer 1.5s infinite;
}

.skeleton-line.w40 {
  width: 40%;
}

.skeleton-line.w50 {
  width: 50%;
}

.skeleton-line.w60 {
  width: 60%;
}

.skeleton-line.w70 {
  width: 70%;
}

.skeleton-line.w80 {
  width: 80%;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* === 空状态 === */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) 0;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.empty-text {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* === 结果列表 === */
.result-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* 结果卡片 */
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  transition: border-color 0.2s, transform 0.2s;
  animation: fadeUp 0.35s var(--ease-out) both;
}

.result-card:hover {
  border-color: var(--border-hover);
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.card-title {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text-primary);
  word-break: break-word;
}

.card-source {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  padding-top: 2px;
}

.card-time {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

/* 链接列表 */
.link-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.link-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.link-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.link-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 500;
  color: #fff;
  flex-shrink: 0;
}

.link-url {
  flex: 1;
  font-size: 0.82rem;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.link-url:hover {
  text-decoration: underline;
}

.link-pwd {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.link-copy {
  padding: 4px 10px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  flex-shrink: 0;
}

.link-copy:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* === 分类展示模式（merged_by_type）=== */
.type-group {
  animation: fadeUp 0.4s var(--ease-out) both;
  margin-bottom: var(--space-xl);
}

.type-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--space-md);
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
}

.type-group-header::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--group-color, var(--accent));
  border-radius: 0 2px 2px 0;
}

.type-group-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.type-group-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
}

.type-group-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 2px 10px;
  border-radius: var(--radius-full);
  margin-left: auto;
}

.type-group .link-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 结果卡片 */
.merged-link-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s, border-color 0.2s;
  position: relative;
  overflow: hidden;
}

.merged-link-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--card-accent, var(--accent));
  border-radius: 0 2px 2px 0;
  opacity: 0;
  transition: opacity 0.2s;
}

.merged-link-item:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.merged-link-item:hover::before {
  opacity: 1;
}

[data-theme="light"] .merged-link-item:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.merged-link-info {
  flex: 1;
  min-width: 0;
}

.merged-link-note {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.merged-link-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  margin-top: 6px;
}

.meta-sep {
  color: var(--text-muted);
  opacity: 0.5;
}

.meta-pwd {
  color: var(--accent);
  font-weight: 500;
}

.merged-link-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* 操作按钮美化 */
.action-open {
  padding: 6px 16px;
  font-size: 0.8rem;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}

.action-open:hover {
  background: var(--accent-hover);
  color: #fff;
}

.action-open:active {
  transform: scale(0.96);
}

.action-copy {
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  white-space: nowrap;
}

.action-copy:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

/* === Toast 提示 === */
.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  z-index: 1000;
  transition: opacity 0.3s, transform 0.3s var(--ease-out);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* === 底部 === */
.footer {
  text-align: center;
  padding: var(--space-xl) var(--space-lg);
  color: var(--text-muted);
  font-size: 0.75rem;
  border-top: 1px solid var(--border-color);
  margin-top: var(--space-2xl);
}

/* === 响应式 === */
@media (max-width: 640px) {
  .search-section {
    padding: var(--space-2xl) 0 var(--space-lg);
  }

  .search-title {
    font-size: 1.4rem;
  }

  .search-box {
    flex-direction: column;
  }

  .search-btn {
    width: 100%;
  }

  .card-header {
    flex-direction: column;
    gap: var(--space-xs);
  }

  .link-item {
    flex-wrap: wrap;
  }

  .link-url {
    order: 3;
    width: 100%;
    flex: none;
  }

  .merged-link-item {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .merged-link-actions {
    width: 100%;
    justify-content: flex-end;
  }
}