@use '../../styles/_ios-theme.scss' as ios;

.auto-settlement-config {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;

  // 头部样式
  .config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid ios.$ios-border;

    h2 {
      margin: 0;
      color: ios.$ios-text-primary;
    font-weight: ios.$ios-font-weight-semibold;
      font-size: 24px;
    }
  }

  // 新规则卡片
  .new-rule-card {
    margin-bottom: 24px;
    border: 2px solid ios.$ios-primary;
    background: linear-gradient(135deg, #f8f9ff 0%, #e8f4ff 100%);

    .mat-card-header {
      background: linear-gradient(135deg, ios.$ios-primary 0%, lighten(ios.$ios-primary, 10%) 100%);
      color: white;
      border-radius: 8px 8px 0 0;
      padding: 16px;

      .mat-card-title {
        font-size: 18px;
        font-weight: ios.$ios-font-weight-semibold;
      }

      .mat-card-subtitle {
        color: rgba(255, 255, 255, 0.8);
      }
    }

    .mat-card-content {
      padding: 24px;
    }

    .form-section {
      display: grid;
      grid-template-columns: 1fr 120px;
      gap: 16px;
      margin-bottom: 24px;

      .full-width {
        grid-column: 1 / -1;
      }
    }

    .conditions-section,
    .actions-section {
      margin-bottom: 24px;
      padding: 16px;
      background: #f8f9fa;
      border-radius: 8px;
      border: 1px solid ios.$ios-border;

      h3 {
        margin: 0 0 16px 0;
        color: ios.$ios-text-primary;
        font-size: 16px;
        font-weight: ios.$ios-font-weight-semibold;
      }
    }

    .condition-item,
    .action-item {
      margin-bottom: 16px;
      padding: 16px;
      background: white;
      border-radius: 8px;
      border: 1px solid ios.$ios-border;

      .condition-header,
      .action-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 12px;
        padding-bottom: 8px;
        border-bottom: 1px solid ios.$ios-border;

        span {
          font-weight: ios.$ios-font-weight-semibold;
          color: ios.$ios-text-primary;
        }
      }

      .condition-fields,
      .action-fields {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 12px;

        .mat-form-field {
          margin-bottom: 0;
        }
      }

      .action-params {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 12px;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid ios.$ios-border;
      }
    }

    .mat-card-actions {
      padding: 16px 24px;
      border-top: 1px solid ios.$ios-border;
    }
  }

  // 规则列表
  .rules-list {
    .mat-expansion-panel {
      margin-bottom: 12px;
      border: 1px solid ios.$ios-border;
      border-radius: 8px;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);

      &:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
      }

      .mat-expansion-panel-header {
        padding: 16px 24px;
        height: auto;
        min-height: 64px;

        .rule-header {
          display: flex;
          align-items: center;
          gap: 12px;
          flex: 1;

          .rule-name {
            font-weight: ios.$ios-font-weight-semibold;
            font-size: 16px;
            color: ios.$ios-text-primary;

            &.disabled {
              color: ios.$ios-text-secondary;
              text-decoration: line-through;
            }
          }

          .rule-priority {
            font-size: 12px;
            color: ios.$ios-text-secondary;
            background: #f0f0f0;
            padding: 2px 8px;
            border-radius: 12px;
          }
        }

        .mat-panel-description {
          color: ios.$ios-text-secondary;
          font-size: 14px;
          margin-right: 16px;
        }
      }

      .rule-details {
        padding: 16px 24px;

        .conditions-display,
        .actions-display {
          margin-bottom: 20px;

          h4 {
            margin: 0 0 12px 0;
            color: ios.$ios-text-primary;
            font-size: 14px;
            font-weight: ios.$ios-font-weight-semibold;
          }

          .conditions-list,
          .actions-list {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
          }

          .condition-tag,
          .action-tag {
            background: lighten(ios.$ios-primary, 20%);
            color: ios.$ios-primary;
            padding: 6px 12px;
            border-radius: 16px;
            font-size: 12px;
            font-weight: ios.$ios-font-weight-medium;
            border: 1px solid rgba(ios.$ios-primary, 0.2);
          }

          .no-conditions,
          .no-actions {
            color: ios.$ios-text-secondary;
            font-style: italic;
            margin: 0;
          }
        }

        .rule-actions {
          display: flex;
          gap: 12px;
          justify-content: flex-end;
          padding-top: 16px;
          border-top: 1px solid ios.$ios-border;

          button {
            min-width: auto;
          }
        }
      }
    }
  }

  // 空状态
  .empty-state {
    text-align: center;
    padding: 60px 20px;
    color: ios.$ios-text-secondary;

    .empty-icon {
      font-size: 64px;
      width: 64px;
      height: 64px;
      margin-bottom: 16px;
      opacity: 0.5;
    }

    h3 {
      margin: 0 0 8px 0;
      color: ios.$ios-text-primary;
      font-size: 18px;
      font-weight: ios.$ios-font-weight-semibold;
    }

    p {
      margin: 0;
      font-size: 14px;
      line-height: 1.4;
    }
  }

  // 响应式设计
  @media (max-width: 768px) {
    padding: 16px;

    .config-header {
      flex-direction: column;
      gap: 16px;
      text-align: center;

      h2 {
        font-size: 20px;
      }
    }

    .new-rule-card {
      .form-section {
        grid-template-columns: 1fr;
      }

      .condition-fields,
      .action-fields {
        grid-template-columns: 1fr;
      }
    }

    .rules-list {
      .mat-expansion-panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;

        .rule-header {
          flex-direction: column;
          align-items: flex-start;
          gap: 8px;
        }

        .mat-panel-description {
          margin-right: 0;
          text-align: left;
        }
      }

      .rule-details {
        .rule-actions {
          flex-direction: column;
          align-items: stretch;

          button {
            width: 100%;
          }
        }
      }
    }
  }

  // 动画效果
  .condition-item,
  .action-item,
  .mat-expansion-panel {
    transition: all 0.3s ease;

    &:hover {
      transform: translateY(-1px);
    }
  }

  // 禁用状态样式
  .disabled {
    opacity: 0.6;
  }

  // 表单字段样式
  .mat-form-field {
    margin-bottom: 16px;

    &.mat-form-field-appearance-outline {
      .mat-form-field-outline {
        color: ios.$ios-border;
      }

      .mat-form-field-outline-thick {
        color: ios.$ios-primary;
      }

      &.mat-focused {
        .mat-form-field-outline-thick {
          color: ios.$ios-primary;
        }
      }
    }
  }

  // 按钮样式
  .mat-button,
  .mat-raised-button {
    border-radius: 8px;
    font-weight: ios.$ios-font-weight-medium;

    &.mat-primary {
      background: ios.$ios-primary;
      color: white;

      &:hover {
        background: darken(ios.$ios-primary, 10%);
      }
    }

    &.mat-warn {
      background: #dc3545;
      color: white;

      &:hover {
        background: darken(#dc3545, 10%);
      }
    }
  }

  // 滑动开关样式
  .mat-slide-toggle {
    &.mat-checked {
      .mat-slide-toggle-thumb {
        background-color: ios.$ios-primary;
      }

      .mat-slide-toggle-bar {
        background-color: rgba(ios.$ios-primary, 0.5);
      }
    }
  }
}