/**
 * KRA - Code Preview Component Styles
 * 代码预览组件样式
 */

.codePreview {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #fafafa;
  border-bottom: 1px solid #f0f0f0;
  border-radius: 4px 4px 0 0;
}

.fileCount {
  color: #666;
  font-size: 13px;
}

.categories {
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tabs {
  flex: 1;
  height: calc(100vh - 280px);
  min-height: 400px;

  :global {
    .ant-tabs-nav {
      width: 220px;
      max-height: calc(100vh - 280px);
      overflow-y: auto;
      background: #fafafa;
      border-right: 1px solid #f0f0f0;
      
      .ant-tabs-tab {
        padding: 8px 12px !important;
        margin: 0 !important;
        border-bottom: 1px solid #f0f0f0;
        
        &:hover {
          background: #f5f5f5;
        }
        
        &.ant-tabs-tab-active {
          background: #e6f7ff;
          border-right: 2px solid #1890ff;
        }
      }
    }

    .ant-tabs-content-holder {
      flex: 1;
      overflow: hidden;
    }

    .ant-tabs-content {
      height: 100%;
    }

    .ant-tabs-tabpane {
      height: 100%;
      padding: 0 !important;
    }
  }
}

.tabLabel {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 180px;
  overflow: hidden;
}

.filename {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.codeContainer {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #1e1e1e;
}

.codeHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: #252526;
  border-bottom: 1px solid #3c3c3c;
}

.filepath {
  color: #cccccc;
  font-size: 12px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  display: flex;
  align-items: center;
  gap: 8px;
}

.codeContent {
  flex: 1;
  overflow: auto;
  padding: 16px;
  
  :global {
    pre {
      margin: 0;
      padding: 0;
      background: transparent !important;
      
      code {
        font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
        font-size: 13px;
        line-height: 1.6;
      }
    }

    // highlight.js 样式覆盖
    .hljs {
      background: transparent !important;
      padding: 0 !important;
    }
  }
}

.empty {
  padding: 48px;
  background: #fafafa;
  border-radius: 4px;
}

// 滚动条样式
.codeContent::-webkit-scrollbar,
.tabs :global(.ant-tabs-nav)::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.codeContent::-webkit-scrollbar-track,
.tabs :global(.ant-tabs-nav)::-webkit-scrollbar-track {
  background: #2d2d2d;
  border-radius: 4px;
}

.codeContent::-webkit-scrollbar-thumb,
.tabs :global(.ant-tabs-nav)::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 4px;
  
  &:hover {
    background: #666;
  }
}

// 暗色模式支持
:global(.ant-layout-content[data-theme='dark']) {
  .toolbar {
    background: #1f1f1f;
    border-color: #303030;
  }

  .categories {
    background: #141414;
    border-color: #303030;
  }

  .tabs {
    :global {
      .ant-tabs-nav {
        background: #1f1f1f;
        border-color: #303030;
        
        .ant-tabs-tab {
          border-color: #303030;
          
          &:hover {
            background: #2a2a2a;
          }
          
          &.ant-tabs-tab-active {
            background: #111d2c;
            border-right-color: #177ddc;
          }
        }
      }
    }
  }

  .fileCount {
    color: #999;
  }
}
