@use '../ios-theme.scss' as *;

.knowledge-base-main {
  padding: $ios-spacing-xl;
  background-color: $ios-background;
  min-height: calc(100vh - 60px);
}

/* 通用样式 */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid $ios-border;
  
  h2 {
    font-size: 20px;
    font-weight: 600;
    color: $ios-text-primary;
  }
  
  .search-filter {
    display: flex;
    gap: 10px;
    
    input[type="text"], select {
      padding: 8px 12px;
      border: 1px solid $ios-border;
      border-radius: $ios-radius-lg;
      font-size: 14px;
      background-color: $ios-background;
      color: $ios-text-primary;
      
      &:focus {
        outline: none;
        border-color: $ios-primary;
        box-shadow: 0 0 0 2px rgba(0, 71, 171, 0.1);
      }
    }
  }
}

/* 按钮样式 */
.btn-add, .btn-export, .btn-edit, .btn-play, .btn-assign, .btn-preview, .btn-view, .btn-extend, .btn-sync, .btn-create, .btn-generate {
  padding: 8px 16px;
  border: none;
  border-radius: $ios-radius-lg;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  
  &:hover {
    opacity: 0.9;
    transform: translateY(-1px);
  }
  
  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
  }
}

.btn-add, .btn-create {
  background-color: $ios-primary;
  color: $ios-background;
}

.btn-export, .btn-sync {
  background-color: $ios-info;
  color: $ios-background;
}

.btn-edit {
  background-color: $ios-warning;
  color: $ios-background;
}

.btn-play {
  background-color: $ios-success;
  color: $ios-background;
}

.btn-assign, .btn-preview, .btn-view, .btn-extend, .btn-generate {
  background-color: $ios-background-secondary;
  color: $ios-text-primary;
  
  &:hover {
    background-color: $ios-background-tertiary;
  }
}

/* SOP管理样式 */
.sop-tabs {
  background-color: $ios-background;
  border-radius: $ios-radius-lg;
  overflow: hidden;
  box-shadow: $ios-shadow-sm;
  
  .tab-buttons {
    display: flex;
    background-color: $ios-background-secondary;
    
    button {
      flex: 1;
      padding: $ios-spacing-lg $ios-spacing-xl;
      border: none;
      background-color: transparent;
      font-size: $ios-font-size-base;
      font-weight: $ios-font-weight-medium;
      color: $ios-text-secondary;
      cursor: pointer;
      transition: all 0.2s;
      
      &.active {
        background-color: $ios-background;
        color: $ios-primary;
        box-shadow: inset 0 -2px 0 $ios-primary;
      }
      
      &:hover:not(.active) {
        background-color: rgba(255, 255, 255, 0.5);
      }
    }
  }
  
  .tab-content {
    padding: $ios-spacing-xl;
  }
}

.sop-overview {
  .sop-summary {
    margin-bottom: $ios-spacing-xl;
    
    p {
      color: $ios-text-secondary;
      margin: 10px 0 20px 0;
    }
  }
  
  .sop-stages {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    
    .stage-item {
      padding: $ios-spacing-xl;
      background-color: $ios-background-secondary;
      border-radius: $ios-radius-lg;
      text-align: center;
      cursor: pointer;
      transition: all 0.2s;
      
      &:hover {
        background-color: $ios-primary-light;
        transform: translateY(-2px);
        box-shadow: $ios-shadow-md;
      }
      
      .stage-icon {
        display: inline-flex;
        justify-content: center;
        align-items: center;
        width: 40px;
        height: 40px;
        background-color: $ios-primary;
        color: $ios-background;
        border-radius: 50%;
        font-weight: $ios-font-weight-semibold;
        margin-bottom: 10px;
      }
      
      h4 {
        margin: 5px 0;
        color: $ios-text-primary;
      }
      
      p {
        color: $ios-text-secondary;
        font-size: 13px;
        margin: 0;
      }
    }
  }
}

.sop-detail {
  .sop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: $ios-spacing-xl;
    
    h3 {
      font-size: 18px;
      color: $ios-text-primary;
    }
    
    .sop-actions {
      display: flex;
      gap: 10px;
    }
  }
  
  .sop-content {
    .sop-section {
      margin-bottom: 25px;
      
      h4 {
        font-size: 16px;
        margin-bottom: 15px;
        color: $ios-text-primary;
        padding-bottom: 8px;
        border-bottom: 1px solid $ios-border;
      }
      
      .requirement-list {
        list-style: none;
        padding: 0;
        margin: 0;
        
        li {
          padding: 8px 0;
          padding-left: 24px;
          position: relative;
          color: $ios-text-primary;
          
          &::before {
            content: "•";
            position: absolute;
            left: 0;
            color: $ios-primary;
            font-weight: bold;
          }
        }
      }
      
      .timeline {
        position: relative;
        padding-left: 24px;
        
        &::before {
          content: '';
          position: absolute;
          left: 8px;
          top: 0;
          bottom: 0;
          width: 2px;
          background-color: $ios-border;
        }
        
        .timeline-item {
          position: relative;
          padding-bottom: 15px;
          
          &::before {
            content: '';
            position: absolute;
            left: -24px;
            top: 4px;
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background-color: $ios-primary;
          }
          
          .time-marker {
            font-weight: $ios-font-weight-semibold;
            color: $ios-primary;
            margin-right: 10px;
          }
          
          .task {
            color: $ios-text-primary;
          }
        }
      }
      
      .quality-table {
        width: 100%;
        border-collapse: collapse;
        
        th, td {
          padding: 10px;
          text-align: left;
          border-bottom: 1px solid $ios-border;
        }
        
        th {
          background-color: $ios-background-secondary;
          color: $ios-text-primary;
          font-weight: $ios-font-weight-semibold;
        }
        
        td {
          color: $ios-text-primary;
        }
        
        tr:hover td {
          background-color: $ios-primary-light;
        }
      }
      
      .video-tutorials {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 15px;
        
        .tutorial-item {
          display: flex;
          gap: 15px;
          padding: 15px;
          background-color: $ios-background-secondary;
          border-radius: $ios-radius-lg;
          
          .tutorial-thumbnail {
            position: relative;
            width: 120px;
            height: 80px;
            flex-shrink: 0;
            
            img {
              width: 100%;
              height: 100%;
              object-fit: cover;
              border-radius: $ios-radius-lg;
            }
            
            .duration {
              position: absolute;
              bottom: 5px;
              right: 5px;
              background-color: rgba(0, 0, 0, 0.7);
              color: $ios-background;
              padding: 2px 6px;
              border-radius: 4px;
              font-size: 12px;
            }
          }
          
          .tutorial-info {
            flex: 1;
            
            h5 {
              margin: 0 0 8px 0;
              color: $ios-text-primary;
              font-size: 14px;
            }
            
            p {
              margin: 0 0 10px 0;
              color: $ios-text-secondary;
              font-size: 12px;
              line-height: 1.4;
            }
          }
        }
      }
    }
  }
}

/* 视频教程样式 */
.tutorial-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.tutorial-card {
  background-color: $ios-background;
  border-radius: $ios-radius-lg;
  overflow: hidden;
  box-shadow: $ios-shadow-sm;
  transition: all 0.2s;
  
  &:hover {
    transform: translateY(-2px);
    box-shadow: $ios-shadow-lg;
  }
  
  .tutorial-thumbnail {
    position: relative;
    width: 100%;
    height: 180px;
    
    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
    
    .duration {
      position: absolute;
      bottom: 10px;
      right: 10px;
      background-color: rgba(0, 0, 0, 0.7);
      color: $ios-background;
      padding: 4px 8px;
      border-radius: 4px;
      font-size: 12px;
    }
  }
  
  .tutorial-info {
    padding: 15px;
    
    h4 {
      margin: 0 0 10px 0;
      color: $ios-text-primary;
      font-size: 16px;
    }
    
    .tutorial-description {
      margin: 0 0 12px 0;
      color: $ios-text-secondary;
      font-size: 13px;
      line-height: 1.4;
    }
    
    .tutorial-meta {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      margin-bottom: 15px;
      
      .stage-tag {
        background-color: $ios-primary-light;
        color: $ios-primary;
        padding: 2px 8px;
        border-radius: 12px;
        font-size: 12px;
        font-weight: 500;
      }
      
      .view-count, .upload-date {
        color: $ios-text-secondary;
        font-size: 12px;
      }
    }
  }
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-top: 20px;
  
  .page-info {
    color: $ios-text-secondary;
    font-size: 14px;
  }
}

/* 实践考核样式 */
.assessment-tabs {
  background-color: $ios-background;
  border-radius: $ios-radius-lg;
  overflow: hidden;
  box-shadow: $ios-shadow-sm;
  
  .tab-buttons {
    display: flex;
    background-color: $ios-background-secondary;
    
    button {
      flex: 1;
      padding: 12px 20px;
      border: none;
      background-color: transparent;
      font-size: 14px;
      font-weight: 500;
      color: $ios-text-secondary;
      cursor: pointer;
      transition: all 0.2s;
      
      &.active {
        background-color: $ios-background;
        color: $ios-primary;
        box-shadow: inset 0 -2px 0 $ios-primary;
      }
      
      &:hover:not(.active) {
        background-color: rgba(255, 255, 255, 0.5);
      }
    }
  }
  
  .tab-content {
    padding: 20px;
  }
}

.assessment-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
  
  .assessment-item {
    padding: 20px;
    background-color: $ios-background-secondary;
    border-radius: $ios-radius-lg;
    
    .assessment-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 15px;
      
      h3 {
        margin: 0;
        color: $ios-text-primary;
        font-size: 16px;
      }
      
      .assessment-stage {
        background-color: $ios-primary-light;
        color: $ios-primary;
        padding: 4px 12px;
        border-radius: 16px;
        font-size: 12px;
        font-weight: 500;
      }
    }
    
    .assessment-info {
      margin-bottom: 15px;
      
      p {
        margin: 0 0 10px 0;
        color: $ios-text-secondary;
        font-size: 13px;
        line-height: 1.4;
      }
      
      .assessment-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 15px;
        
        .difficulty, .duration, .assignee, .deadline, .status, .completion-date, .score {
          color: $ios-text-primary;
          font-size: 13px;
        }
        
        .difficulty.easy {
          color: $ios-success;
        }
        
        .difficulty.medium {
          color: $ios-warning;
        }
        
        .difficulty.hard {
          color: $ios-danger;
        }
      }
      
      .assessment-result {
        display: inline-block;
        padding: 4px 12px;
        border-radius: 16px;
        font-size: 12px;
        font-weight: 500;
        margin-top: 10px;
        
        &.pass {
          background-color: $ios-success;
          color: $ios-background;
        }
        
        &.fail {
          background-color: $ios-danger;
          color: $ios-background;
        }
      }
    }
    
    .assessment-actions {
      display: flex;
      gap: 10px;
    }
  }
}

/* 培训效果跟踪样式 */
.effect-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
  
  .metric-card {
    padding: 20px;
    background-color: $ios-background;
    border-radius: $ios-radius-lg;
    box-shadow: $ios-shadow-sm;
    text-align: center;
    
    h3 {
        margin: 0 0 10px 0;
        color: $ios-text-secondary;
        font-size: 14px;
        font-weight: 500;
      }
    
    .metric-value {
        margin: 0 0 5px 0;
        color: $ios-text-primary;
        font-size: 28px;
        font-weight: 700;
      }
    
    .metric-change {
      margin: 0;
      font-size: 13px;
      font-weight: 500;
      
      &.positive {
          color: $ios-success;
        }
        
        &.negative {
          color: $ios-danger;
        }
    }
    
    .metric-description {
        margin: 0;
        color: $ios-text-secondary;
        font-size: 12px;
      }
  }
}

.effect-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 20px;
  
  .chart-container {
    background-color: $ios-background;
    border-radius: $ios-radius-lg;
    padding: 20px;
    box-shadow: $ios-shadow-sm;
    
    h3 {
        margin: 0 0 20px 0;
        color: $ios-text-primary;
        font-size: 16px;
        text-align: center;
      }
    
    .chart-placeholder {
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .knowledge-base-main {
    padding: 10px;
  }
  
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    
    .search-filter {
      width: 100%;
      flex-direction: column;
      
      input[type="text"], select {
        width: 100%;
      }
    }
  }
  
  .sop-tabs .tab-buttons, .assessment-tabs .tab-buttons {
    flex-direction: column;
  }
  
  .tutorial-grid {
    grid-template-columns: 1fr;
  }
  
  .effect-charts {
    grid-template-columns: 1fr;
    
    .chart-container {
      padding: 15px;
      
      .chart-placeholder svg {
        width: 100%;
        max-width: 300px;
        height: auto;
      }
    }
  }
  
  .pagination {
    flex-direction: column;
    gap: 10px;
  }
}