/* ========================================
   UI问题修复CSS
   1. 隐藏顶部滚动进度条
   2. 移除侧边栏链接下划线
   3. 稳定移动端/桌面端切换
   ======================================== */

/* 修复1: 隐藏顶部滚动进度条（视觉干扰） */
.scroll-progress {
  display: none !important;
}

/* 如果想保留但不那么明显，可以用这个替代上面的代码：
.scroll-progress {
  height: 2px !important;
  background: rgba(102, 126, 234, 0.3) !important;
  opacity: 0.5 !important;
}
*/

/* 修复2: 移除侧边栏链接的所有边框/下划线 */
.sidebar .nav-section a,
.nav-section ul li a {
  border: none !important;
  border-bottom: none !important;
  text-decoration: none !important;
  box-shadow: none !important;
}

/* 移除focus状态的边框 */
.sidebar .nav-section a:focus,
.nav-section ul li a:focus {
  outline: 2px solid rgba(26, 106, 255, 0.3);
  outline-offset: 2px;
  border: none !important;
  border-bottom: none !important;
}

/* 移除active状态的边框 */
.sidebar .nav-section a:active,
.nav-section ul li a:active,
.sidebar .nav-section a.active,
.nav-section ul li a.active {
  border: none !important;
  border-bottom: none !important;
}

/* 修复3: 强制稳定布局，避免移动/桌面切换闪烁 */
@media (min-width: 769px) {
  /* 强制桌面端样式 */
  body {
    --layout-type: 'desktop';
  }
  
  .sidebar {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: fixed !important;
  }
  
  .main {
    margin-left: 120px !important;
  }
  
  .mobile-header,
  .mobile-menu-btn {
    display: none !important;
  }
}

@media (max-width: 768px) {
  /* 强制移动端样式 */
  body {
    --layout-type: 'mobile';
  }
  
  .sidebar {
    display: none !important;
  }
  
  .main {
    margin-left: 0 !important;
    width: 100% !important;
  }
  
  .mobile-header {
    display: flex !important;
  }
}

/* 修复4: 保留侧边栏滚动动画，使用GPU加速优化性能 */
@media (prefers-reduced-motion: no-preference) {
  /* 保留侧边栏的平滑展开/收起动画，使用GPU加速 */
  .sidebar {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    will-change: transform, opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }
  
  /* .main的margin-left动画保持，避免跳动 */
  .main {
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }
}

/* 修复6已移除：保持原有的布局，不调整.main的padding-top */
/* 原始样式已经让侧边栏和主内容容器天然对齐 */

/* 修复5: 确保在临界点（768-769px）不会出现问题 */
@media (min-width: 768px) and (max-width: 769px) {
  /* 在临界点强制使用桌面端样式 */
  body {
    --layout-type: 'desktop-edge';
  }
  
  .sidebar {
    display: block !important;
    width: 220px !important;
  }
  
  .main {
    margin-left: 110px !important;
  }
}

/* ========================================
   终极移动端顶部贴合修复（最高优先级）
   确保任何层级的 padding/margin 不会在顶部产生空白
   ======================================== */
@media (max-width: 1024px) {
  html, body {
    margin: 0 !important;
    padding: 0 !important;
    padding-top: 0 !important;
    margin-top: 0 !important;
    background: #dfeaf5 !important; /* 覆盖移动端黑底，避免顶部黑条 */
  }

  .main,
  main,
  .hero-section,
  .hero-slides,
  .hero-slide,
  .intro-overlay,
  .intro-background {
    margin-top: 0 !important;
    padding-top: 0 !important;
    top: 0 !important;
  }

  .hero-section {
    position: relative !important;
    overflow: hidden !important;
  }

  /* 顶部渐变遮罩（background-gradient）在移动端/平板隐藏，避免空条 */
  .background-gradient {
    display: none !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
  }
}

/* ========================================
   骨架屏加载动画
   ======================================== */
@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton-loading {
  pointer-events: none;
}

.skeleton-card {
  background: rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  padding: 1.5rem;
  min-height: 200px;
}

.skeleton-img {
  width: 100%;
  height: 120px;
  border-radius: 12px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite ease-in-out;
  margin-bottom: 1rem;
}

.skeleton-text {
  height: 16px;
  border-radius: 8px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite ease-in-out;
  margin-bottom: 0.75rem;
}

.skeleton-text.short {
  width: 60%;
}

.skeleton-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite ease-in-out;
}

/* 深色模式骨架屏 */
@media (prefers-color-scheme: dark) {
  .skeleton-card {
    background: rgba(255, 255, 255, 0.1);
  }
  
  .skeleton-img,
  .skeleton-text,
  .skeleton-avatar {
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
    background-size: 200% 100%;
  }
}

/* ========================================
   Toast 提示优化
   ======================================== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 14px 20px;
  border-radius: 12px;
  color: white;
  font-weight: 500;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  animation: toast-in 0.3s ease-out;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 350px;
}

.toast.success { background: linear-gradient(135deg, #10b981, #059669); }
.toast.error { background: linear-gradient(135deg, #ef4444, #dc2626); }
.toast.warning { background: linear-gradient(135deg, #f59e0b, #d97706); }
.toast.info { background: linear-gradient(135deg, #3b82f6, #2563eb); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100%); }
}

.toast.removing {
  animation: toast-out 0.3s ease-in forwards;
}

/* 移动端Toast居中 */
@media (max-width: 768px) {
  .toast-container {
    top: auto;
    bottom: 100px;
    right: 50%;
    transform: translateX(50%);
  }
  
  .toast {
    max-width: 90vw;
  }
}
