// 全局变量定义
$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;
    }
  }
}

// 案例展示区域
.cases-section {
  .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    h3 {
      font-size: 18px;
      font-weight: 600;
      color: $text-primary;
      .cases-count {
        font-size: 14px;
        font-weight: normal;
        color: $text-tertiary;
      }
    }
  }
}

// 案例网格
.cases-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

// 案例卡片
.case-card {
  background-color: $background-primary;
  border-radius: $border-radius;
  overflow: hidden;
  box-shadow: $shadow-sm;
  cursor: pointer;
  transition: $transition;
  border: 2px solid transparent;
  
  &:hover {
    border-color: $primary-color;
    transform: translateY(-4px);
    box-shadow: $shadow-md;
  }
}

.case-image-container {
  position: relative;
  height: 200px;
  overflow: hidden;
}

.case-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.case-card:hover .case-image {
  transform: scale(1.05);
}

.case-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.6) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px;
  gap: 8px;
}

.case-card:hover .case-overlay {
  opacity: 1;
}

.favorite-btn,
.share-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background-color: white;
  border: none;
  border-radius: 20px;
  color: $text-secondary;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: $transition;
  
  &:hover {
    background-color: $primary-color;
    color: white;
  }
}

.favorite-btn.favorited {
  background-color: $danger-color;
  color: white;
}

.case-info {
  padding: 16px;
}

.case-name {
  font-size: 16px;
  font-weight: 600;
  color: $text-primary;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.case-meta {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: $text-tertiary;
}

.case-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-block;
  padding: 4px 10px;
  background-color: $background-tertiary;
  color: $text-secondary;
  border-radius: 12px;
  font-size: 11px;
}

// 空状态
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: $text-tertiary;
  background-color: $background-primary;
  border-radius: $border-radius;
  border: 1px dashed $border-color;
  
  svg {
    margin-bottom: 16px;
  }
  
  p {
    margin-bottom: 16px;
    font-size: 14px;
  }
  
  .btn-reset {
    padding: 8px 20px;
    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;
    }
  }
}

// 分页控件
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.page-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background-color: $background-primary;
  border: 1px solid $border-color;
  border-radius: $border-radius;
  color: $text-secondary;
  cursor: pointer;
  transition: $transition;
  
  &:hover:not(:disabled) {
    background-color: $background-tertiary;
    border-color: $primary-color;
    color: $primary-color;
  }
  
  &.active {
    background-color: $primary-color;
    border-color: $primary-color;
    color: white;
  }
  
  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

// 案例详情模态框
.case-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background-color: $background-primary;
  border-radius: $border-radius;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  background-color: rgba(0, 0, 0, 0.1);
  border: none;
  border-radius: 50%;
  color: $text-secondary;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: $transition;
  z-index: 10;
  
  &:hover {
    background-color: $danger-color;
    color: white;
  }
}

.case-detail-header {
  padding: 24px 24px 0;
  
  h2 {
    font-size: 24px;
    font-weight: 600;
    color: $text-primary;
    margin-bottom: 8px;
  }
  
  .case-detail-meta {
    display: flex;
    gap: 16px;
    font-size: 14px;
    color: $text-secondary;
  }
}

.case-image-gallery {
  margin: 20px 0;
  
  .main-image {
    height: 400px;
    overflow: hidden;
    
    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
  }
  
  .thumbnails {
    display: flex;
    gap: 8px;
    padding: 12px 24px;
    overflow-x: auto;
    
    .thumbnail {
      width: 80px;
      height: 60px;
      object-fit: cover;
      border-radius: 4px;
      cursor: pointer;
      border: 2px solid transparent;
      transition: $transition;
      
      &:hover {
        border-color: $primary-color;
      }
    }
  }
}

.case-detail-info {
  padding: 0 24px 24px;
  
  .info-section {
    margin-bottom: 24px;
    
    h3 {
      font-size: 18px;
      font-weight: 600;
      color: $text-primary;
      margin-bottom: 12px;
    }
    
    p {
      font-size: 14px;
      line-height: 1.6;
      color: $text-secondary;
      margin-bottom: 8px;
    }
  }
  
  .info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    
    .info-item {
      
      label {
        display: block;
        font-size: 12px;
        color: $text-tertiary;
        margin-bottom: 4px;
      }
      
      span {
        font-size: 14px;
        color: $text-primary;
        font-weight: 500;
      }
    }
  }
  
  .tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
}

.case-actions {
  display: flex;
  gap: 12px;
  padding: 20px 24px;
  background-color: $background-tertiary;
  border-top: 1px solid $border-color;
  
  .primary-btn,
  .secondary-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: $border-radius;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: $transition;
    border: none;
  }
  
  .primary-btn {
    background-color: $primary-color;
    color: white;
    
    &:hover {
      background-color: $primary-dark;
      transform: translateY(-1px);
      box-shadow: $shadow-md;
    }
  }
  
  .secondary-btn {
    background-color: $background-primary;
    color: $text-secondary;
    border: 1px solid $border-color;
    
    &:hover {
      background-color: $background-secondary;
      border-color: $primary-color;
      color: $primary-color;
    }
  }
}

// 响应式设计
@media (max-width: 1200px) {
  .cases-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

@media (max-width: 768px) {
  .dashboard-content {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid $border-color;
    
    .sidebar-nav {
      padding: 8px 0;
      
      .nav-item {
        padding: 10px 16px;
      }
    }
  }
  
  .content-wrapper {
    padding: 16px;
  }
  
  .menu-toggle {
    display: block;
  }
  
  .navbar-center {
    margin: 0 16px;
  }
  
  .cases-grid {
    grid-template-columns: 1fr;
  }
  
  .filter-form .filter-row {
    flex-direction: column;
    gap: 16px;
  }
  
  .filter-form .filter-group {
    min-width: 100%;
  }
  
  .modal-content {
    margin: 10px;
    max-height: calc(100vh - 20px);
  }
  
  .case-image-gallery .main-image {
    height: 250px;
  }
  
  .case-actions {
    flex-direction: column;
    
    .primary-btn,
    .secondary-btn {
      width: 100%;
      justify-content: center;
    }
  }
}