// 全局变量定义
$primary-color: #165DFF;
$primary-dark: #0E42CB;
$secondary-color: #4E5BA6;
$success-color: #00B42A;
$warning-color: #FF7D00;
$danger-color: #F53F3F;
$text-primary: #1D2129;
$text-secondary: #4E5969;
$text-tertiary: #86909C;
$text-light: #C9CDD4; // 新增浅色文本变量
$border-color: #E5E6EB;
$background-primary: #FFFFFF;
$background-secondary: #F2F3F5;
$background-tertiary: #F7F8FA;
$shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
$shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
$shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
$border-radius: 8px;
$transition: all 0.3s ease;

// 主容器
.case-library-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: $background-secondary;
  color: $text-primary;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

// 顶部导航栏
.top-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 64px;
  background-color: $background-primary;
  border-bottom: 1px solid $border-color;
  box-shadow: $shadow-sm;
  position: sticky;
  top: 0;
  z-index: 1000;

  .navbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
  }

  .menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: $text-primary;
    padding: 8px;
    transition: $transition;

    &:hover {
      color: $primary-color;
    }
  }

  .app-title {
    font-size: 20px;
    font-weight: 600;
    color: $primary-color;
  }

  .navbar-center {
    flex: 1;
    max-width: 400px;
    margin: 0 32px;
  }

  .search-container {
    display: flex;
    align-items: center;
    background-color: $background-tertiary;
    border-radius: 20px;
    padding: 8px 16px;
    height: 36px;

    .search-input {
      flex: 1;
      border: none;
      background: none;
      outline: none;
      font-size: 14px;
      color: $text-primary;

      &::placeholder {
        color: $text-tertiary;
      }
    }

    .search-button {
      background: none;
      border: none;
      cursor: pointer;
      color: $text-tertiary;
      padding: 4px;
      transition: $transition;

      &:hover {
        color: $primary-color;
      }
    }
  }

  .navbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
  }

  .notification-btn {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    color: $text-secondary;
    padding: 8px;
    transition: $transition;

    &:hover {
      color: $primary-color;
    }

    .notification-badge {
      position: absolute;
      top: 0;
      right: 0;
      background-color: $danger-color;
      color: white;
      font-size: 10px;
      padding: 2px 6px;
      border-radius: 10px;
      min-width: 16px;
      text-align: center;
    }
  }
// 在分页相关样式中添加省略号样式
.pagination-ellipsis {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  font-size: 14px;
  color: $text-light;
  cursor: default;
}
  .user-profile {
    display: flex;
    align-items: center;
    gap: 8px;

    .user-avatar {
      width: 36px;
      height: 36px;
      border-radius: 50%;
      object-fit: cover;
    }

    .user-name {
      font-size: 14px;
      font-weight: 500;
      color: $text-primary;
    }
  }
}

// 主要内容区
.dashboard-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

// 左侧侧边栏
.sidebar {
  width: 220px;
  background-color: $background-primary;
  border-right: 1px solid $border-color;
  display: flex;
  flex-direction: column;
  transition: $transition;

  .sidebar-nav {
    flex: 1;
    padding: 16px 0;

    .nav-item {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 12px 24px;
      color: $text-secondary;
      text-decoration: none;
      border-left: 3px solid transparent;
      transition: $transition;

      &:hover {
        background-color: $background-tertiary;
        color: $primary-color;
      }

      &.active {
        color: $primary-color;
        background-color: color-mix(in srgb, $primary-color 5%, transparent);
        border-left-color: $primary-color;
        font-weight: 500;
      }
    }
  }

  .sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid $border-color;

    .storage-info {
      margin-bottom: 16px;
      font-size: 12px;
      color: $text-tertiary;
    }

    .logout-btn {
      display: flex;
      align-items: center;
      gap: 8px;

      padding: 8px 12px;
      background: none;
      border: 1px solid $border-color;
      border-radius: $border-radius;
      color: $text-secondary;
      cursor: pointer;
      font-size: 14px;
      transition: $transition;

      &:hover {
        background-color: $background-tertiary;
        border-color: $danger-color;
        color: $danger-color;
      }
    }
  }
}

// 中间内容区
.content-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

// 欢迎区域
.welcome-section {
  margin-bottom: 24px;

  h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    color: $text-primary;
  }

  p {
    font-size: 14px;
    color: $text-secondary;
  }
}

// 筛选区域
.filter-section {
  background-color: $background-primary;
  border-radius: $border-radius;
  padding: 16px 20px;
  box-shadow: $shadow-sm;
  margin-bottom: 24px;
}

.filter-header {
  display: flex;
  gap: 12px;
}

.filter-toggle-btn,
.reset-filter-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background-color: $background-tertiary;
  border: 1px solid $border-color;
  border-radius: $border-radius;
  color: $text-secondary;
  cursor: pointer;
  font-size: 14px;
  transition: $transition;

  &:hover {
    background-color: $background-secondary;
    border-color: $primary-color;
    color: $primary-color;
  }
}

.filter-panel {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid $border-color;
  display: none;
  animation: slideDown 0.3s ease;
}

.filter-panel.show {
  display: block;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.filter-form {
  .filter-row {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
    flex-wrap: wrap;
  }
  
  .filter-group {
    flex: 1;
    min-width: 200px;
    label {
      display: block;
      font-size: 14px;
      font-weight: 500;
      color: $text-primary;
      margin-bottom: 8px;
    }
    select,
    input[type="number"] {
      width: 100%;
      padding: 8px 12px;
      border: 1px solid $border-color;
      border-radius: $border-radius;
      font-size: 14px;
      transition: $transition;
      &:focus {
        outline: none;
        border-color: $primary-color;
        box-shadow: 0 0 0 3px color-mix(in srgb, $primary-color 10%, transparent);
      }
    }
  }
  
  .checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
  }
  
  .checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: $text-secondary;
    cursor: pointer;
    input[type="checkbox"] {
      width: auto;
    }
    &.full-width {
      width: 100%;
      justify-content: flex-start;
    }
  }
  
  .range-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    input {
      flex: 1;
    }
    span {
      font-size: 14px;
      color: $text-secondary;
    }
  }
}

/* 覆盖与新增：筛选区域固定与过渡 */
.filter-section {
  position: sticky;
  top: 0;
  z-index: 12;
  background: #fff;
  padding-top: 8px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.filter-toggle-btn, .reset-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  color: #1e5eff;
  background: #f3f7ff;
  border: 1px solid #dbe6ff;
  border-radius: 6px;
  cursor: pointer;
  transition: all .2s ease;
}
.filter-toggle-btn:hover, .reset-filter-btn:hover {
  background: #e8f0ff;
  box-shadow: 0 2px 8px rgba(30,94,255,0.12);
}

.filter-panel {
  overflow: hidden;
  max-height: 0;
  transition: max-height .28s ease;
}
.filter-panel.show {
  max-height: 560px; // 兼容动画高度
}

.filter-form {
  padding: 12px 0 8px;
}
.filter-row {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px 16px;
  margin-bottom: 10px;
}
.filter-group { grid-column: span 3; }
@media (max-width: 1200px) { .filter-group { grid-column: span 4; } }
@media (max-width: 900px) { .filter-group { grid-column: span 6; } }
@media (max-width: 640px) { .filter-group { grid-column: span 12; } }

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
}
.checkbox-item { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.checkbox-item input { accent-color: #1e5eff; }

.range-inputs { display: inline-flex; align-items: center; gap: 6px; }
.range-inputs input { width: 110px; }

/* 瀑布流布局 */
.cases-grid {
  column-count: 1;
  column-gap: 16px;
}
@media (min-width: 768px) { .cases-grid { column-count: 2; } }
@media (min-width: 1200px) { .cases-grid { column-count: 3; } }
@media (min-width: 1600px) { .cases-grid { column-count: 4; } }

.case-card {
  display: inline-block; // 关键：配合 columns
  width: 100%;
  break-inside: avoid;
  margin: 0 0 16px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
}
.case-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,0.08); }

.case-image-container { position: relative; }
.case-image { width: 100%; height: auto; display: block; }

.case-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 10px;
  opacity: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.35), rgba(0,0,0,0.0));
  transition: opacity .2s ease;
}
.case-card:hover .case-overlay { opacity: 1; }

.favorite-btn, .share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  color: #fff;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 8px;
  backdrop-filter: blur(2px);
  cursor: pointer;
}
.favorite-btn:hover, .share-btn:hover { background: rgba(255,255,255,0.2); }

.case-info { padding: 12px; }
.case-name { font-size: 15px; margin: 0 0 6px; }
.case-meta { display: flex; gap: 12px; color: #667085; font-size: 12px; }
.case-meta .meta-item { display: inline-flex; align-items: center; gap: 6px; }
.case-tags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.case-tags .tag { padding: 2px 8px; border-radius: 999px; background: #f3f7ff; color: #1e5eff; font-size: 12px; }

/* 空状态 */
.empty-state { text-align: center; color: #98a2b3; padding: 40px 0; }
.btn-reset { margin-top: 10px; padding: 6px 12px; border-radius: 6px; border: 1px solid #d0d5dd; background: #fff; cursor: pointer; }

/* 分页省略号 */
.pagination-ellipsis { padding: 0 6px; color: #98a2b3; display: inline-flex; align-items: center; }

/* 案例详情模态框优化 */
.case-modal { position: fixed; inset: 0; background: rgba(17,24,39,0.45); backdrop-filter: blur(2px); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; }
.case-modal .modal-content { width: min(980px, 92vw); max-height: 92vh; overflow: auto; border-radius: 12px; background: #fff; position: relative; box-shadow: 0 20px 48px rgba(0,0,0,0.18); }
.case-modal .close-btn { position: absolute; right: 12px; top: 12px; background: #fff; border: 1px solid #e5e7eb; border-radius: 999px; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; }

.case-image-gallery { padding: 12px; }
.case-image-gallery .main-image img { width: 100%; border-radius: 10px; }
.case-image-gallery .thumbnails { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 10px; }
.case-image-gallery .thumbnail { width: 100%; border-radius: 8px; }

.info-section { padding: 12px; }
.info-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 14px; }
@media (max-width: 900px) { .info-grid { grid-template-columns: repeat(2, 1fr); } }
.info-item label { color: #98a2b3; font-size: 12px; }
.info-item span { color: #111827; font-size: 14px; }

.case-actions { padding: 12px; display: flex; gap: 10px; border-top: 1px solid #f2f4f7; }
.primary-btn, .secondary-btn { display: inline-flex; align-items: center; gap: 8px; border-radius: 8px; padding: 8px 12px; cursor: pointer; border: 1px solid transparent; }
.primary-btn { background: linear-gradient(135deg, #1e5eff, #4f8cff); color: #fff; box-shadow: 0 6px 16px rgba(30,94,255,0.25); }
.secondary-btn { background: #f8fafc; color: #1f2937; border-color: #e5e7eb; }

/* 分享弹窗 */
.share-modal { position: fixed; inset: 0; background: rgba(17,24,39,0.45); z-index: 110; display: flex; align-items: center; justify-content: center; padding: 24px; }
.share-modal-content { width: min(520px, 92vw); background: #fff; border-radius: 12px; box-shadow: 0 18px 44px rgba(0,0,0,0.16); position: relative; padding: 18px; }
.share-modal .close-btn { position: absolute; right: 12px; top: 12px; background: #fff; border: 1px solid #e5e7eb; border-radius: 999px; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; }
.share-modal h3 { margin: 0 0 6px; font-size: 18px; }
.share-tip { color: #667085; font-size: 13px; margin-bottom: 12px; }
.share-body { display: flex; gap: 12px; align-items: flex-start; }
.share-link-box { flex: 1; display: flex; gap: 8px; }
.share-link-input { flex: 1; height: 36px; padding: 0 10px; border: 1px solid #e5e7eb; border-radius: 8px; font-size: 13px; }
.btn-primary { height: 36px; padding: 0 12px; border-radius: 8px; color: #fff; background: #1e5eff; border: 1px solid #1e5eff; cursor: pointer; }
.qr-box { width: 160px; height: 160px; border: 1px dashed #e5e7eb; border-radius: 8px; display: grid; place-items: center; color: #98a2b3; font-size: 12px; }

/* 响应式微调 */
@media (max-width: 720px) {
  .share-body { flex-direction: column; }
  .qr-box { width: 100%; height: 140px; }
}