/* 自定义滚动条 */
:root {
  --card-padding: 1.25rem; /* 20px, default p-5 */
  --card-radius: 0.75rem;  /* 12px, default rounded-xl */
  --frosted-glass-blur: 15px; /* Default blur */
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #c3d0e3;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: #416d9d;
}

/* Dark Mode Scrollbar */
.dark ::-webkit-scrollbar-track {
  background: transparent;
}
.dark ::-webkit-scrollbar-thumb {
  background: #4b5563;
}
.dark ::-webkit-scrollbar-thumb:hover {
  background: #6b7280;
}

/* ========================================= */
/*  Dark Mode & Wallpaper Optimizations      */
/* ========================================= */

/* 1. 背景压暗 (仅在有壁纸且夜间模式时) */
html.dark body.custom-wallpaper::before {
    content: '';
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6); /* 60% 黑色遮罩 */
    z-index: -1;
    pointer-events: none;
    transition: background-color 0.3s ease;
}

/* 2. 侧边栏深色玻璃化 */
html.dark body.custom-wallpaper .sidebar {
    background-color: rgba(17, 24, 39, 0.85) !important;
    backdrop-filter: blur(var(--frosted-glass-blur, 15px));
    -webkit-backdrop-filter: blur(var(--frosted-glass-blur, 15px));
    border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* 3. 卡片基础与悬停样式 */
.site-card {
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  will-change: transform;
  border-radius: var(--card-radius) !important; /* 强制应用后台设置的圆角 */
  width: 100%;
  height: 100%; /* 撑满 Grid 单元高度 */
  display: flex;
  flex-direction: column;
}

.site-card-content {
  padding: var(--card-padding);
  flex: 1; /* 占据卡片所有垂直空间 */
  display: flex;
  flex-direction: column;
}

.site-card-content a {
    /* flex: 1; Removed to compact height */
    display: flex;
    flex-direction: column;
}

/* 让描述部分撑开，确保底部链接行对齐 */
.site-card p, .site-card .preview-desc {
    /* flex: 1; Removed to reduce height */
    margin-bottom: 0;
    /* 强制两行高度: line-height (relaxed=1.625) * 2 lines * font-size (sm=0.875rem) ≈ 2.85rem */
    height: 2.85rem;
}

.site-card:hover {
  transform: scale(1.15) translateY(-10px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
  z-index: 30;
  border: 2px solid #416d9d !important;
}

/* 夜间模式卡片 - 仅在开启毛玻璃时应用半透明 */
.dark .site-card.frosted-glass-effect {
    background-color: rgba(30, 41, 59, 0.4) !important;
    backdrop-filter: blur(var(--frosted-glass-blur, 15px));
    -webkit-backdrop-filter: blur(var(--frosted-glass-blur, 15px));
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

/* 确保实色模式下也有边框颜色 */
.dark .site-card:not(.frosted-glass-effect) {
    border-color: rgba(255, 255, 255, 0.05);
}

.dark .site-card:hover {
  border-color: rgba(255, 255, 255, 0.3) !important;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.dark .site-card-content h3 {
    color: #f3f4f6 !important;
}

.dark .site-card-content p {
    color: #9ca3af !important;
}

.dark .site-card-content .text-primary-600 {
    color: #60a5fa !important;
}

/* 4. 头部/容器深色化 */
.dark header {
    background-color: transparent !important;
}

/* 搜索框深色化 */
.dark input[type="text"].search-input-target {
    background-color: rgba(0, 0, 0, 0.4) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: #fff !important;
    backdrop-filter: blur(8px);
}
.dark input[type="text"].search-input-target::placeholder {
    color: rgba(255, 255, 255, 0.5);
}
.dark input[type="text"].search-input-target:focus {
    background-color: rgba(0, 0, 0, 0.6) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

/* 5. 分类标签深色化 */
.dark .site-card .inline-flex {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: #d1d5db !important;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* 6. 下拉菜单深色化 */
.dark .dropdown-menu {
    background-color: rgba(31, 41, 55, 0.95) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #e5e7eb;
}
.dark .dropdown-item {
    color: #d1d5db;
}
.dark .dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}
.dark .dropdown-item.active {
    background-color: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

/* 7. 导航按钮样式 */
.nav-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.5rem 1rem; border-radius: 9999px; font-size: 0.875rem;
  line-height: 1.25rem; font-weight: 500; white-space: nowrap;
  transition: all 0.2s ease; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; height: 2.5rem;
}

.nav-btn.inactive {
  background-color: rgba(255, 255, 255, 0.15); color: white; backdrop-filter: blur(4px);
}
.nav-btn.inactive:hover { background-color: rgba(255, 255, 255, 0.25); }

.custom-wallpaper .nav-btn.inactive {
  background-color: rgba(255, 255, 255, 0.7); color: #374151; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.custom-wallpaper .nav-btn.inactive:hover { background-color: white; color: #2563eb; }

.nav-btn.active {
  background-color: white; color: #1d4ed8; box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1); font-weight: 600;
}
.dark .nav-btn.active {
  background-color: rgba(59, 130, 246, 0.2) !important;
  color: #60a5fa !important;
  border: 1px solid rgba(59, 130, 246, 0.4) !important;
}
.custom-wallpaper .nav-btn.active { background-color: #2563eb; color: white; }
.dark.custom-wallpaper .nav-btn.active { background-color: #2563eb !important; color: white !important; }

/* 风格一图标动画 */
.site-card:not(.style-2) .site-icon {
  width: 2.5rem; margin-right: 1rem; opacity: 1;
}
.site-card:not(.style-2):hover .site-icon {
  width: 0; margin-right: 0; opacity: 0; transition-delay: 0.1s;
}
.site-card:not(.style-2) .site-title { transform-origin: left center; }
.site-card:not(.style-2):hover .site-title { transform: scale(1.2); transition-delay: 0.1s; }

/* 风格二 (垂直布局) */
.site-card.style-2 .flex.items-start { flex-direction: column; align-items: center; text-align: center; }
.site-card.style-2 .site-icon { margin-right: 0; margin-bottom: 0.5rem; width: 3rem; height: 3rem; transition: transform 0.3s ease; }
.site-card.style-2:hover .site-icon { transform: scale(1.1); }
.site-card.style-2 .site-icon img, .site-card.style-2 .site-icon div { margin: 0 auto; }
.site-card.style-2 .site-title { text-align: center; margin-bottom: 0.25rem; display: block; width: 100%; }
.site-card.style-2 .flex-1 { width: 100%; display: flex; flex-direction: column; align-items: center; }
.site-card.style-2 .inline-flex { margin-top: 0.25rem; margin-bottom: 0.5rem; }
.site-card.style-2 p { text-align: center; margin-top: 0.5rem; }
.site-card.style-2 .mt-3.flex { margin-top: auto; justify-content: space-between; padding-top: 0.5rem; border-top: 1px solid rgba(0,0,0,0.05); }
.dark .site-card.style-2 .mt-3.flex { border-top: 1px solid rgba(255,255,255,0.1); }

/* 复制提示 */
@keyframes fadeInOut {
  0% { opacity: 0; transform: translateY(10px); }
  20% { opacity: 1; transform: translateY(0); }
  80% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-10px); }
}
.copy-success-animation { animation: fadeInOut 2s ease forwards; }

/* 卡片加载动画 */
@keyframes cardEnter {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.card-anim-enter {
  animation: cardEnter 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  opacity: 0; /* 初始状态不可见 */
}

/* 搜索引擎切换选项 - 胶囊按钮样式 */
.search-engine-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.75rem; /* 稍微比分类按钮小一点 */
  border-radius: 9999px;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  
  /* Default Inactive (Light Mode - Dark Header) */
  background-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  border-bottom: 1px solid transparent; /* Reset old style */
}

.search-engine-option:hover {
  background-color: rgba(255, 255, 255, 0.25);
  color: white;
  opacity: 1;
}

.search-engine-option.active {
  background-color: white;
  color: #1d4ed8; /* Dark Blue */
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);
  font-weight: 600;
  border-bottom-color: transparent; /* Reset old style */
}

/* Custom Wallpaper Mode */
.custom-wallpaper .search-engine-option {
  background-color: rgba(255, 255, 255, 0.7);
  color: #374151;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.custom-wallpaper .search-engine-option:hover {
  background-color: white;
  color: #2563eb;
}
.custom-wallpaper .search-engine-option.active {
  background-color: #2563eb;
  color: white;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

/* Dark Mode */
.dark .search-engine-option {
  background-color: rgba(255, 255, 255, 0.05);
  color: #9ca3af;
  border: 1px solid transparent;
}
.dark .search-engine-option:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: #e5e7eb;
}
.dark .search-engine-option.active {
  background-color: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

/* 侧边栏与 Overlay */
@media (max-width: 1023px) {
  .mobile-sidebar { transform: translateX(-100%); transition: transform 0.3s ease; }
  .mobile-sidebar.open { transform: translateX(0); }
  .mobile-overlay { opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
  .mobile-overlay.open { opacity: 1; pointer-events: auto; }
}

.line-clamp-2 {
  display: -webkit-box !important; -webkit-line-clamp: 2 !important; -webkit-box-orient: vertical !important;
  overflow: hidden !important; text-overflow: ellipsis !important; word-break: break-word;
}

#sidebar-toggle { display: none; }
@media (min-width: 1024px) {
  #sidebar-toggle:checked ~ .sidebar { margin-left: -16rem; }
  #sidebar-toggle:checked ~ .main-content { margin-left: 0; }
}

/* 毛玻璃效果 - Light Mode */
.frosted-glass-effect {
  background: rgba(255, 255, 255, 0.4) !important;
  backdrop-filter: blur(var(--frosted-glass-blur, 15px)) !important;
  -webkit-backdrop-filter: blur(var(--frosted-glass-blur, 15px)) !important;
  border: 1px solid rgba(255, 255, 255, 0.6) !important;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05) !important;
}

.frosted-glass-effect:hover {
  background: rgba(255, 255, 255, 0.6) !important;
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15) !important;
  border: 1px solid rgba(255, 255, 255, 0.9) !important;
}

/* Light Mode + Wallpaper Sidebar Optimization */
html:not(.dark) body.custom-wallpaper .sidebar {
    background-color: rgba(255, 255, 255, 0.4) !important;
    backdrop-filter: blur(var(--frosted-glass-blur, 15px));
    -webkit-backdrop-filter: blur(var(--frosted-glass-blur, 15px));
    border-right: 1px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.dropdown-menu {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%) translateY(4px);
  z-index: 60; min-width: 100px; width: max-content; max-width: 160px;
  padding: 0.25rem; margin-top: 0.2rem;
  background-color: white; border-radius: 0.5rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  border: 1px solid #e5e7eb;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex; flex-direction: column; align-items: stretch;
}

/* 增加透明伪元素填补间隙，防止鼠标移出导致菜单消失 */
.dropdown-menu::before {
  content: '';
  position: absolute;
  top: -1rem;
  left: 0;
  width: 100%;
  height: 1rem;
  background: transparent;
}

.menu-item-wrapper:hover > .dropdown-menu, .dropdown-menu.show {
  opacity: 1; visibility: visible; pointer-events: auto; transform: translateX(-50%) translateY(0);
}

.dropdown-menu .menu-item-wrapper { display: block; width: 100%; }
.dropdown-menu .menu-item-wrapper .dropdown-menu {
  top: 0; left: 100%; margin-top: -0.25rem; margin-left: 0.2rem; transform: translateX(-4px) translateY(0);
}
.dropdown-menu .menu-item-wrapper .dropdown-menu::after {
  content: ''; position: absolute; top: 0; left: -0.4rem; width: 0.4rem; height: 100%; background: transparent;
}
.dropdown-menu .menu-item-wrapper:hover > .dropdown-menu { transform: translateX(0) translateY(0); }

/* Fix for horizontal more dropdown toggling */
#horizontalMoreDropdown:not(.hidden) {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: translateY(0) scale(1) !important;
}

/* Horizontal More Dropdown Items Style */
#horizontalMoreDropdown .dropdown-item {
  display: flex; width: 100%; height: auto; border-radius: 0.25rem;
  background-color: transparent; color: #4b5563; box-shadow: none;
  justify-content: flex-start; padding: 0.5rem 0.75rem; backdrop-filter: none;
}
#horizontalMoreDropdown .dropdown-item:hover { background-color: #f3f4f6; color: #2563eb; }
#horizontalMoreDropdown .dropdown-item.active { background-color: #eff6ff; color: #1d4ed8; font-weight: 600; }

.custom-wallpaper #horizontalMoreDropdown .dropdown-item { color: #374151; }
.custom-wallpaper #horizontalMoreDropdown .dropdown-item:hover { background-color: rgba(255, 255, 255, 0.8); color: #2563eb; }
.custom-wallpaper #horizontalMoreDropdown .dropdown-item.active { background-color: #2563eb; color: white !important; }

.dark #horizontalMoreDropdown .dropdown-item { color: #d1d5db; }
.dark #horizontalMoreDropdown .dropdown-item:hover { background-color: rgba(255, 255, 255, 0.1); color: #fff; }
.dark #horizontalMoreDropdown .dropdown-item.active { background-color: rgba(59, 130, 246, 0.2); color: #60a5fa; }

/* 针对右侧"更多"菜单的特殊处理：子菜单向左弹出，防止溢出屏幕 */
#horizontalMoreDropdown .dropdown-menu {
  left: auto;
  right: 100%;
  margin-left: 0;
  margin-right: 0.2rem;
  transform: translateX(4px) translateY(0);
}

#horizontalMoreDropdown .dropdown-menu::after {
  left: auto;
  right: -0.4rem;
}

#horizontalMoreDropdown .menu-item-wrapper:hover > .dropdown-menu {
  transform: translateX(0) translateY(0);
}

/* Force Card Hover Scale */
.site-card:hover {
  transform: scale(1.15) translateY(-10px) !important;
}

/* ========================================= */
/*  General Dropdown Item Styles             */
/* ========================================= */

.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: #374151;
  border-radius: 0.375rem;
  transition: all 0.2s;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.dropdown-item:hover {
  background-color: #f3f4f6;
  color: #2563eb;
}

.dropdown-item.active {
  background-color: #eff6ff;
  color: #1d4ed8;
  font-weight: 500;
}

.dropdown-arrow-icon {
  width: 1rem;
  height: 1rem;
  margin-left: auto;
  padding-left: 0.5rem;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.dropdown-item:hover .dropdown-arrow-icon {
  opacity: 1;
}

/* Force Dropdown Item Color in Light Mode */
html:not(.dark) .dropdown-item {
    color: #4b5563;
}
html:not(.dark) .dropdown-item:hover {
    color: #2563eb !important;
}
html:not(.dark) .dropdown-item.active {
    color: #1d4ed8 !important;
}