/* ============================================
   网址目录 - Color Admin 风格主题（响应式修复版）
   六套主题 + 极简轻量卡片 + 标题省略修复
   ============================================ */

/* ---------- 全局变量 ---------- */
:root {
  --primary: #348fe2;
  --primary-hover: #2a72b5;
  --primary-light: rgba(52, 143, 226, 0.08);
  --text: #242a30;
  --text-muted: #707478;
  --border-color: #e2e7eb;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --radius: 3px;
  --topbar-bg: #ffffff;
  --topbar-border: #e2e7eb;
  --sidebar-bg: #2d353c;
  --sidebar-text: #a8acb1;
  --sidebar-active-bg: #1a2229;
  --sidebar-active-text: #ffffff;
  --sidebar-highlight: #4a8bfc;
  --body-bg: #d9e0e7;
  --card-bg: #ffffff;
  --meta-cat-bg: rgba(52, 143, 226, 0.12);
  --meta-cat-text: #348fe2;
  --meta-reg-bg: rgba(52, 143, 226, 0.08);
  --meta-reg-text: #348fe2;
  --tag-bg: rgba(52, 143, 226, 0.05);
  --tag-text: #348fe2;
}

/* 主题扩展 */
[data-theme="green"] {
  --primary: #00acac;
  --primary-hover: #008a8a;
  --meta-cat-bg: rgba(0, 172, 172, 0.12);
  --meta-cat-text: #00acac;
  --meta-reg-bg: rgba(0, 172, 172, 0.08);
  --meta-reg-text: #00acac;
  --tag-bg: rgba(0, 172, 172, 0.05);
  --tag-text: #00acac;
}
[data-theme="red"] {
  --primary: #ff5b57;
  --primary-hover: #cc4946;
  --meta-cat-bg: rgba(255, 91, 87, 0.12);
  --meta-cat-text: #ff5b57;
  --meta-reg-bg: rgba(255, 91, 87, 0.08);
  --meta-reg-text: #ff5b57;
  --tag-bg: rgba(255, 91, 87, 0.05);
  --tag-text: #ff5b57;
}
[data-theme="orange"] {
  --primary: #f59c1a;
  --primary-hover: #c47d15;
  --meta-cat-bg: rgba(245, 156, 26, 0.12);
  --meta-cat-text: #f59c1a;
  --meta-reg-bg: rgba(245, 156, 26, 0.08);
  --meta-reg-text: #f59c1a;
  --tag-bg: rgba(245, 156, 26, 0.05);
  --tag-text: #f59c1a;
}
[data-theme="cyan"] {
  --primary: #49b6d6;
  --primary-hover: #3a92ab;
  --meta-cat-bg: rgba(73, 182, 214, 0.12);
  --meta-cat-text: #49b6d6;
  --meta-reg-bg: rgba(73, 182, 214, 0.08);
  --meta-reg-text: #49b6d6;
  --tag-bg: rgba(73, 182, 214, 0.05);
  --tag-text: #49b6d6;
}
[data-theme="dark"] {
  --primary: #575d63;
  --primary-hover: #3a4047;
  --meta-cat-bg: rgba(182, 194, 201, 0.12);
  --meta-cat-text: #b6c2c9;
  --meta-reg-bg: rgba(182, 194, 201, 0.08);
  --meta-reg-text: #b6c2c9;
  --tag-bg: rgba(182, 194, 201, 0.06);
  --tag-text: #b6c2c9;
  --topbar-bg: #2d353c;
  --topbar-border: #575d63;
  --text: #e2e7eb;
  --text-muted: #a0a0a0;
  --border-color: #3a4047;
  --body-bg: #242a30;
  --card-bg: #2d353c;
}

/* ---------- 全局重置 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--body-bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  font-size: 14px;
  transition: background 0.3s, color 0.3s;
  max-width: 100vw; /* 防止移动端溢出 */
}
a {
  text-decoration: none;
  color: inherit;
}

/* ---------- 顶部通栏 ---------- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 54px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  z-index: 1020;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.1);
}
.topbar-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text);
}
.topbar-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.topbar-brand img {
  margin-top: 10px;
  height: 30px;
}
.topbar-info {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.topbar-info select {
  padding: 4px 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.85rem;
}
.topbar-right {
  flex-shrink: 0;
}
.btn {
  padding: 6px 12px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.85rem;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

/* ---------- 侧边栏 ---------- */
.sidebar {
  position: fixed;
  top: 54px;
  left: 0;
  width: 220px;
  height: calc(100% - 54px);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  overflow-y: auto;
  z-index: 1010;
  transition: transform 0.3s;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.sidebar::-webkit-scrollbar {
  width: 5px;
}
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 4px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.4);
}

.sidebar-nav {
  padding: 8px 0;
}
.category-menu {
  list-style: none;
}
.menu-item {
  margin: 0;
}
.cat-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--sidebar-text);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.cat-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.menu-item.open > .cat-toggle-btn {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 600;
  border-left-color: var(--sidebar-highlight);
}
.menu-text-link {
  flex: 1;
  color: inherit;
  text-decoration: none;
}
.cat-arrow {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
  transform: scaleX(1.8);
  margin-left: 6px;
}

.submenu {
  list-style: none;
  background: rgba(0, 0, 0, 0.2);
  display: none;
}
.menu-item.open .submenu {
  display: block;
}
.submenu li a {
  display: block;
  padding: 8px 20px 8px 40px;
  font-size: 0.75rem;
  color: var(--sidebar-text);
  position: relative;
  transition: all 0.15s;
}
.submenu li a::before {
  content: "";
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  background: currentColor;
  opacity: 0.6;
  border-radius: 50%;
}
.submenu li a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.submenu li a.active {
  background: var(--sidebar-active-bg);
  color: #fff;
  font-weight: 600;
}
.submenu li a.active::before {
  background: var(--sidebar-highlight);
  opacity: 1;
}

/* ---------- 主内容面板 ---------- */
.main-panel {
  margin-left: 220px;
  padding-top: 54px;
  min-height: 100vh;
}
.content {
  padding: 20px;
  max-width: 100%;
} /* 确保内容不溢出 */

/* 区域栏 */
.region-bar {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 8px 16px;
  margin-bottom: 12px;
  overflow: hidden; /* 确保不溢出 */
}
.region-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.region-list a {
  padding: 5px 14px;
  background: #f0f3f4;
  border-radius: 20px;
  color: #333;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
}
.region-list a.active {
  background: var(--primary);
  color: #fff;
}

/* 移动端下拉 */
.region-dropdown-mobile {
  display: none;
  position: relative;
  width: 100%;
}
.region-dropdown-toggle {
  width: 100%;
  padding: 10px 16px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.region-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  z-index: 150;
  max-height: 250px;
  overflow-y: auto;
}
.region-dropdown-menu.open {
  display: block;
}
.region-dropdown-menu a {
  display: block;
  padding: 10px 16px;
  color: var(--text);
  border-bottom: 1px solid var(--border-color);
}
.region-dropdown-menu a.active {
  background: var(--primary);
  color: #fff;
}

/* 搜索栏 */
.search-bar {
  margin-bottom: 16px;
}
.search-row {
  display: flex;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
}
.engine-select {
  border: none;
  padding: 12px 16px;
  background: #b6c2c9;
  outline: none;
  font-size: 0.9rem;
  color: var(--text);
}
.search-input {
  flex: 1;
  border: none;
  padding: 12px 16px;
  outline: none;
  background: transparent;
  font-size: 1rem;
  color: var(--text);
}
.search-input::placeholder {
  color: var(--text-muted);
}
.search-btn {
  border: none;
  padding: 12px 24px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}
.search-btn:hover {
  background: var(--primary-hover);
}

/* ---------- 卡片系统（极简轻量 + 标题省略） ---------- */
.card {
  background: var(--card-bg);
  border: 3px solid transparent;
  border-radius: 5px;
  transition: all 0.25s ease;
}
.card-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-body {
  padding: 10px;
}
.card.site-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 2px 6px 2px rgba(0, 0, 0, 0.1);
  border-bottom-color: var(--primary);
}

/* 卡片头部（图标＋标题） */
.site-card-header {
  padding: 10px 14px 0;
  border-bottom: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.site-icon {
  width: 26px;
  height: 26px;
  object-fit: contain;
  border-radius: 8px;
  flex-shrink: 0;
}
.site-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  flex: 1;
  min-width: 0; /* 允许收缩显示省略号 */
}

/* 描述 */
.site-desc {
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  margin: 6px 0 8px;
  border-bottom: none;
  padding-bottom: 0;
}

/* 分类/区域/标签胶囊 */
.site-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.site-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 30px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.badge-primary {
  background: var(--primary);
  color: #fff;
}
.badge-secondary {
  background: rgba(37, 99, 235, 0.08);
  color: #2563eb;
  border: none;
}
.badge-light {
  background: #f8fafc;
  color: var(--tag-text);
  border: 0.5px solid #e2edf2;
}
.tag {
  background: #f8fafc;
  border: 0.5px solid #e2edf2;
  border-radius: 30px;
  padding: 2px 8px;
  font-size: 0.6rem;
  font-weight: 500;
  color: #2b5d7c;
  transition: background 0.2s, color 0.2s;
}
.tag:hover {
  background: var(--primary);
  color: #fff;
}

/* 主题色覆盖胶囊 */
[data-theme] .badge-secondary {
  background: var(--meta-cat-bg);
  color: var(--meta-cat-text);
}
[data-theme] .badge-light {
  background: var(--meta-reg-bg);
  color: var(--meta-reg-text);
  border-color: var(--meta-reg-bg);
}
[data-theme="dark"] .badge-secondary {
  background: rgba(182, 194, 201, 0.12);
  color: #b6c2c9;
}
[data-theme="dark"] .badge-light {
  background: rgba(182, 194, 201, 0.06);
  color: #b6c2c9;
  border-color: rgba(182, 194, 201, 0.2);
}

/* 推荐区块 */
.featured {
  background: var(--card-bg);
  border: 2px solid transparent;
  margin-bottom: 12px;
}
.featured-card .featured-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* 分组标题 */
.category-block {
  margin-bottom: 12px;
}
.category-block-title {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}
.category-block-title h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}
.category-block-title a {
  color: var(--text);
  text-decoration: none;
}
.category-block-title a:hover {
  color: var(--primary);
}

/* 网站网格（默认4列，媒体查询覆盖） */
.website-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* 默认桌面四列 */
  gap: 12px;
}

/* 分页 */
.pagination {
  display: flex;
  justify-content: center;
  gap: 5px;
  list-style: none;
  margin: 24px 0;
}
.pagination a,
.pagination span {
  padding: 5px 10px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
}
.pagination a.active,
.pagination a:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* 页脚 */
.footer {
  padding-bottom: 20px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* 遮罩 & 工具类 */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
}
.sidebar-overlay.show {
  display: block;
}
.hide-mobile {
  display: flex;
}

/* ---------- 响应式（断点清晰，不冲突） ---------- */
/* 大屏幕：1200px 以上，保持默认4列 */
@media (min-width: 1200px) {
  .website-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .pagination-mobile {
    display: none;
  }
}

/* 中等屏幕：992px - 1199px，3列 */
@media (max-width: 1199px) and (min-width: 992px) {
  .website-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .pagination-mobile {
    display: none;
  }
}

/* 中等屏幕：768px - 991px，2列 */
@media (max-width: 991px) and (min-width: 768px) {
  .website-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .topbar-brand img {
    height: 26px;
  }
  .pagination-desktop {
    display: none;
  }
}

/* 小平板及以下：767px 以下，1列 + 移动端布局 */
@media (max-width: 767px) {
  .website-grid {
    grid-template-columns: 1fr;
  }
  .topbar-info.hide-mobile {
    display: none;
  }
  .topbar-left {
    gap: 10px;
  }
  .topbar-brand img {
    height: 24px;
  }
  .sidebar {
    transform: translateX(-100%);
    position: fixed;
    top: 54px;
    left: 0;
    width: 260px;
    height: calc(100% - 54px);
    z-index: 1050;
    transition: transform 0.3s ease;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay {
    z-index: 1040;
    background: rgba(0, 0, 0, 0.5);
  }
  .menu-toggle {
    display: inline-block;
  }
  .main-panel {
    margin-left: 0;
  }
  .region-list-desktop {
    display: none;
  }
  .region-dropdown-mobile {
    display: block;
  }
  .region-bar {
    overflow: visible;
  }
  .search-row {
    flex-direction: column;
  }
  .engine-select {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 10px 16px;
  }
  .search-btn {
    width: 100%;
    padding: 12px;
  }
  .hide-mobile {
    display: none !important;
  }
  .pagination-desktop {
    display: none;
  }
}
