// 组件级样式定义
// 使用 BEM 命名规范，避免样式冲突

// ===== Ant Design 组件定制 =====

// 表格组件定制
.ant-table {
  &-wrapper {
    border-radius: @border-radius-lg;
    box-shadow: @shadow-card;
  }
  
  &-thead > tr > th {
    background: @bg-color-container;
    font-weight: @font-weight-semibold;
    color: @text-color-primary;
    border-bottom: 1px solid @border-color;
    
    &:first-child {
      border-top-left-radius: @border-radius-lg;
    }
    
    &:last-child {
      border-top-right-radius: @border-radius-lg;
    }
  }
  
  &-tbody > tr {
    transition: @animation-fast;
    
    &:hover > td {
      background: @bg-color-hover;
    }
  }
  
  // 表格操作列样式
  &-operation-column {
    .ant-btn-link {
      padding: 0 @spacing-xs;
      font-size: @font-size-sm;
      
      &:not(:last-child) {
        margin-right: @spacing-sm;
      }
      
      &.danger {
        color: @error-color;
        
        &:hover {
          color: @error-color-hover;
        }
      }
    }
  }
}

// 卡片组件定制
.ant-card {
  border-radius: @border-radius-lg;
  box-shadow: @shadow-card;
  border: none;
  
  &-head {
    border-bottom: 1px solid @border-color;
    background: @bg-color-container;
    
    &-title {
      font-weight: @font-weight-semibold;
      color: @text-color-primary;
    }
  }
  
  &-body {
    padding: @spacing-xl;
  }
}

// 按钮组件定制
.ant-btn {
  border-radius: @border-radius-base;
  font-weight: @font-weight-medium;
  transition: @animation-fast;
  
  &-primary {
    background: @primary-color;
    border-color: @primary-color;
    box-shadow: @shadow-button;
    
    &:hover {
      background: @primary-color-hover;
      border-color: @primary-color-hover;
      transform: translateY(-1px);
      box-shadow: @shadow-button-hover;
    }
  }
  
  &-default {
    background: @bg-color-container;
    border-color: @border-color;
    color: @text-color-primary;
    
    &:hover {
      border-color: @primary-color;
      color: @primary-color;
    }
  }
  
  &-link {
    &.danger {
      color: @error-color;
      
      &:hover {
        color: @error-color-hover;
      }
    }
  }
}

// 表单组件定制
.ant-form {
  &-item {
    margin-bottom: @spacing-lg;
    
    &-label > label {
      font-weight: @font-weight-medium;
      color: @text-color-primary;
    }
  }
}

.ant-input {
  border-radius: @border-radius-base;
  border-color: @border-color;
  
  &:focus,
  &-focused {
    border-color: @primary-color;
    box-shadow: 0 0 0 2px fade(@primary-color, 20%);
  }
}

// Popover 组件定制
.ant-popover {
  &-content {
    border-radius: @border-radius-lg;
    box-shadow: @shadow-popup;
  }
  
  &-inner {
    border-radius: @border-radius-lg;
    padding: @spacing-md;
  }
  
  &-title {
    font-weight: @font-weight-semibold;
    color: @text-color-primary;
    border-bottom: 1px solid @border-color;
    padding-bottom: @spacing-xs;
    margin-bottom: @spacing-sm;
  }
}

// ===== 业务组件样式 =====

// 页面容器
.page-container {
  padding: @spacing-xl;
  background: @bg-color-page;
  min-height: 100vh;
  
  &__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: @spacing-xl;
    
    &-title {
      font-size: @font-size-xl;
      font-weight: @font-weight-bold;
      color: @text-color-primary;
      margin: 0;
    }
    
    &-actions {
      display: flex;
      gap: @spacing-sm;
    }
  }
  
  &__content {
    background: @bg-color-container;
    border-radius: @border-radius-lg;
    box-shadow: @shadow-card;
    padding: @spacing-xl;
  }
}

// 工具栏
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: @spacing-xl;
  padding: @spacing-md @spacing-lg;
  background: @bg-color-container;
  border-radius: @border-radius-base;
  border: 1px solid @border-color;
  
  &__left {
    display: flex;
    gap: @spacing-sm;
  }
  
  &__right {
    display: flex;
    gap: @spacing-sm;
  }
}

// 状态标签
.status-tag {
  &--active {
    background: fade(@success-color, 10%);
    color: @success-color;
    border: 1px solid fade(@success-color, 30%);
  }
  
  &--inactive {
    background: fade(@text-color-disabled, 10%);
    color: @text-color-disabled;
    border: 1px solid fade(@text-color-disabled, 30%);
  }
  
  &--error {
    background: fade(@error-color, 10%);
    color: @error-color;
    border: 1px solid fade(@error-color, 30%);
  }
}

// 响应式辅助类
@media (max-width: @screen-md) {
  .page-container {
    padding: @spacing-md;
    
    &__header {
      flex-direction: column;
      align-items: stretch;
      gap: @spacing-md;
      
      &-actions {
        justify-content: flex-start;
      }
    }
  }
  
  .toolbar {
    flex-direction: column;
    gap: @spacing-md;
    
    &__left,
    &__right {
      width: 100%;
      justify-content: flex-start;
    }
  }
  
  .ant-table {
    &-operation-column {
      .ant-btn-link {
        display: block;
        margin-bottom: @spacing-xs;
        
        &:not(:last-child) {
          margin-right: 0;
        }
      }
    }
  }
}

// 数据展示优化样式
// 这个文件应该被导入到全局样式中

// 数据卡片
.data-card {
  background: @bg-color-container;
  border-radius: @border-radius-lg;
  padding: 16px 20px;
  margin-bottom: 16px;
  border: 1px solid @border-color-base;
  transition: @animation-base;
  
  &:hover {
    border-color: @border-color-dark;
    box-shadow: @box-shadow-base;
  }
  
  .data-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    
    .data-card-title {
      font-size: @font-size-base;
      font-weight: @font-weight-semibold;
      color: @text-color-primary;
    }
    
    .data-card-actions {
      display: flex;
      gap: 8px;
    }
  }
  
  .data-card-content {
    .data-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 6px 0;
      border-bottom: 1px solid @border-color-light;
      
      &:last-child {
        border-bottom: none;
      }
      
      .data-label {
        color: @text-color-secondary;
        font-size: @font-size-2sm;
        min-width: 80px;
      }
      
      .data-value {
        color: @text-color-primary;
        font-size: @font-size-2sm;
        text-align: right;
        
        &.code {
          font-family: @font-family-mono;
          background: @gray-3;
          padding: 2px 6px;
          border-radius: @border-radius-sm;
          font-size: @font-size-sm;
        }
      }
    }
  }
}

// 统一的操作按钮样式（供各页面复用）
.action-btn {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  font-size: @font-size-sm;
  font-weight: @font-weight-medium;
  border-radius: @border-radius-md;
  border: 1px solid @slate-200;
  background: @bg-color-container;
  color: @slate-600;
  transition: @animation-base;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: @shadow-xs-05;

  svg {
    margin-right: 4px;
    width: 16px;
    height: 16px;
  }

  &:hover {
    background: @slate-50;
    border-color: @slate-300;
    color: @slate-700;
    transform: translateY(-1px);
    box-shadow: @shadow-md-10;
  }

  &:focus {
    background: @slate-50;
    border-color: @blue-500;
    color: @slate-700;
    box-shadow: @shadow-lg-ring-blue;
  }

  &:disabled {
    background: @slate-100;
    border-color: @slate-200;
    color: @slate-400;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
  }

  &.primary {
    color: @blue-700;
    background-color: @blue-100;
    border-color: #93c5fd;

    &:hover {
      background-color: @blue-200;
      border-color: #60a5fa;
    }
  }

  &.secondary {
    color: @gray-700;
    background-color: #f3f4f6;
    border-color: @gray-300;

    &:hover {
      background-color: #e5e7eb;
      border-color: @gray-400;
    }
  }

  &.danger {
    color: @red-600;
    background-color: #fef2f2;
    border-color: #fecaca;

    &:hover {
      background-color: #fee2e2;
      border-color: #f87171;
    }
  }

  &.file {
    color: @purple-600;
    background-color: #f3e8ff;
    border-color: #c4b5fd;

    &:hover {
      background-color: #e9d5ff;
      border-color: #a78bfa;
    }
  }

  &.config {
    color: @teal-600;
    background-color: #d1fae5;
    border-color: #86efac;

    &:hover {
      background-color: #bbf7d0;
      border-color: #4ade80;
    }
  }
}

// 空状态
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: @text-color-secondary;
  
  .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
  }
  
  .empty-text {
    font-size: @font-size-base;
    margin-bottom: 8px;
  }
  
  .empty-description {
    font-size: @font-size-sm;
    color: @text-color-tertiary;
  }
}

// 标签系统
.tag-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  
  .custom-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
  border-radius: @border-radius-sm;
  font-size: @font-size-2xs;
  font-weight: @font-weight-medium;
    border: 1px solid transparent;
    
    &.tag-primary {
      background: #e6f7ff;
      color: #1890ff;
      border-color: #91d5ff;
    }
    
    &.tag-success {
      background: fade(@success-color, 6%);
      color: @success-color;
      border-color: fade(@success-color, 40%);
    }
    
    &.tag-warning {
      background: fade(@warning-color, 8%);
      color: @warning-color;
      border-color: fade(@warning-color, 60%);
    }
    
    &.tag-purple {
      background: #f9f0ff;
      color: #722ed1;
      border-color: #d3adf7;
    }
  }
}

// 进度指示器
.progress-steps {
  display: flex;
  align-items: center;
  
  .step {
    display: flex;
    align-items: center;
    
    .step-number {
      width: 24px;
      height: 24px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: @font-size-sm;
      font-weight: @font-weight-semibold;
      background: @gray-3;
      color: @text-color-secondary;
      
      &.active {
        background: @primary-color;
        color: @gray-1;
      }
      
      &.completed {
        background: @success-color;
        color: @gray-1;
      }
    }
    
    .step-title {
      margin-left: 8px;
      font-size: @font-size-2sm;
      color: @gray-8;
      
      &.active {
        color: @primary-color;
        font-weight: @font-weight-medium;
      }
    }
    
    .step-connector {
      width: 40px;
      height: 1px;
      background: @border-color-base;
      margin: 0 16px;
      
      &.completed {
        background: @success-color;
      }
    }
  }
}

// 通用面板组件（头部/内容布局）
.panel {
  background: @component-background;
  border-radius: @border-radius-base;
  box-shadow: @box-shadow-base;
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;

  .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: @spacing-md @spacing-lg;
    background: @background-color-light;
    border-bottom: 1px solid @border-color-base;
    height: 64px;
    min-height: 64px;

    .header-content {
      display: flex;
      align-items: center;
      gap: @spacing-sm;

      .header-icon {
        color: @primary-color;
        font-size: @font-size-lg;
      }

      .header-title {
        font-weight: @font-weight-medium;
        font-size: @font-size-base;
        color: @text-color;
      }
    }

    .header-actions {
      display: flex;
      align-items: center;
      gap: @spacing-xs;
    }
  }

  .panel-content {
    padding: @spacing-lg;
  }
}

// 优雅步骤条样式（供多个向导页面复用）
.elegant-steps {
  .ant-steps-item {
    .ant-steps-item-title {
      font-weight: @font-weight-semibold;
      color: #1f2937;
      font-size: @font-size-2lg;
      margin-top: 8px;
      line-height: 1.4;
    }

    .ant-steps-item-description {
      color: @slate-500;
      font-size: @font-size-2sm;
      margin-top: 4px;
      line-height: 1.5;
    }

    &.ant-steps-item-active {
      .ant-steps-item-title {
        background: linear-gradient(135deg, @blue-500 0%, #6366f1 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
        font-weight: @font-weight-bold;
      }

      .ant-steps-item-description {
        color: @blue-500;
        font-weight: @font-weight-medium;
      }
    }

    &.ant-steps-item-finish {
      .ant-steps-item-title {
        color: @teal-600;
        font-weight: @font-weight-semibold;
      }

      .ant-steps-item-description {
        color: #10b981;
      }
    }

    .ant-steps-item-content {
      min-height: 60px;
      padding-top: 6px;
    }
  }

  .ant-steps-item-icon {
    width: 36px;
    height: 36px;
    line-height: 36px;
    font-size: 14px;
    border-width: 2px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);

    .ant-steps-icon {
      font-size: 14px;
      font-weight: @font-weight-bold;
    }
  }

  .ant-steps-item-tail::after {
    height: 3px;
    background: linear-gradient(90deg, @border-color-200 0%, @gray-300 100%);
    border-radius: 2px;
    top: 16px;
  }

  .ant-steps-item-finish .ant-steps-item-tail::after {
    background: linear-gradient(90deg, #10b981 0%, @teal-600 100%);
  }

  .ant-steps-item-process .ant-steps-item-icon {
    background: linear-gradient(135deg, @blue-500 0%, #6366f1 100%);
    border-color: @blue-500;
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);

    .ant-steps-icon {
      color: @gray-1;
    }
  }

  .ant-steps-item-finish .ant-steps-item-icon {
    background: linear-gradient(135deg, #10b981 0%, @teal-600 100%);
    border-color: #10b981;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);

    .anticon {
      color: @gray-1;
    }
  }

  .ant-steps-item-wait .ant-steps-item-icon {
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    border-color: @gray-300;

    .ant-steps-icon { color: @gray-400; }
  }
}

// 统一卡片工具栏（顶部条）- Option A: subtle background + hairline divider
.card-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: @spacing-md;
  background: linear-gradient(90deg, fade(@gray-1, 96%), fade(#f7faff, 96%));
  border-bottom: 1px solid @border-color-200;
}

// 统一卡片标题区（适用于管理页的 card header）
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: @spacing-md;
  /* Unified padding consistent with detail/list headers */
  padding: 22px 24px;
  background: @bg-color-container;
  border-bottom: 1px solid @border-color-200;
  border-top-left-radius: 0.5rem;
  border-top-right-radius: 0.5rem;

  .card-title {
    display: inline-flex;
    align-items: center;
    gap: @spacing-sm;
    margin: 0;
    font-size: @font-size-lg;
    font-weight: @font-weight-semibold;
    color: @text-color-primary;
    line-height: 1.25;
  min-height: 36px; // unify inner content height of headers
    /* Ensure icons align nicely with text */
    .anticon, svg { display: block; }
  }

  .card-subtitle {
    font-size: @font-size-sm;
    color: @text-color-secondary;
  }

  .card-meta {
    font-size: @font-size-sm;
    color: @slate-500;
  }

  .card-actions {
    display: inline-flex;
    align-items: center;
    gap: @spacing-sm;
    flex-shrink: 0;
  }
}

// 全局主按钮（Tailwind 版本）的统一高度与对齐（避免不同容器下高度漂移）
.btn-primary {
  display: inline-flex;
  align-items: center;
  height: 36px !important;
  min-height: 36px !important;
  line-height: 1 !important;
  padding-top: 6px !important;
  padding-bottom: 6px !important;

  // 修正 Ant 图标/内联 SVG 的基线下沉
  .anticon,
  svg { display: block; }
}

// Hero Capsule（品牌胶囊图标）
.hero-capsule {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  color: @gray-1;
  background: linear-gradient(135deg, @blue-600 0%, #6366f1 100%);
  box-shadow: 0 10px 24px rgba(59, 130, 246, 0.25), 0 2px 6px rgba(99, 102, 241, 0.15);
  border: 1px solid fade(@blue-500, 35%);
  position: relative;

  &.sm { width: 32px; height: 32px; }
  &.md { width: 40px; height: 40px; }

  // 内部发光环
  &::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: inherit;
    box-shadow: 0 0 0 3px fade(@blue-500, 18%), 0 12px 28px fade(#6366f1, 22%);
    pointer-events: none;
  }
}

// Ghost Steps（极简步骤条）
.steps-ghost {
  .ant-steps-item {
    .ant-steps-item-title {
      font-weight: @font-weight-medium;
      color: @slate-600;
      font-size: @font-size-lg;
      margin-top: 6px;
    }

    .ant-steps-item-description {
      color: @slate-500;
      font-size: @font-size-sm;
      margin-top: 2px;
    }

    .ant-steps-item-content { min-height: 48px; padding-top: 2px; }
  }

  .ant-steps-item-icon {
    width: 28px;
    height: 28px;
    line-height: 28px;
    font-size: 13px;
    border-radius: 9999px;
    border-width: 1.5px;
    background: transparent;
    border-color: @border-color-200;
    box-shadow: none;
  }

  .ant-steps-item-tail::after {
    height: 2px;
    background: @border-color-200;
    border-radius: 2px;
    top: 14px;
  }

  .ant-steps-item-process {
    .ant-steps-item-icon {
      background: linear-gradient(135deg, @blue-500 0%, #6366f1 100%);
      border-color: @blue-500;
      .ant-steps-icon { color: @gray-1; }
    }
    .ant-steps-item-title { color: @text-color-primary; font-weight: @font-weight-semibold; }
  }

  .ant-steps-item-finish {
    .ant-steps-item-icon {
      background: linear-gradient(135deg, #10b981 0%, @teal-600 100%);
      border-color: #10b981;
      .anticon { color: @gray-1; }
    }
    .ant-steps-item-tail::after { background: linear-gradient(90deg, #10b981, @teal-600); }
  }

  .ant-steps-item-wait {
    .ant-steps-item-icon { background: transparent; border-color: @border-color-200; }
    .ant-steps-item-title { color: @slate-500; }
  }
}
