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

:host { 
  display: block; 
  height: 100%; 
}

.settlement-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid $ios-border;

  // 统计数据概览
  .stats-overview {
    margin-bottom: 24px;

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

    .stats-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
      gap: 16px;

      .stat-item {
        background: #f8f9fa;
        border-radius: 8px;
        padding: 16px;
        text-align: center;
        border: 1px solid $ios-border;

        &.total {
          background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
          color: white;
          border: none;
        }

        &.pending {
          background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
          color: #8b4513;
        }

        &.overdue {
          background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
          color: #dc3545;
        }

        &.completed {
          background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
          color: #28a745;
        }

        .stat-value {
          font-size: 24px;
          font-weight: $ios-font-weight-bold;
          margin-bottom: 4px;
        }

        .stat-label {
          font-size: 12px;
          opacity: 0.8;
        }
      }
    }
  }

  // 筛选和搜索区域
  .filter-section {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;

    .search-bar {
      width: 100%;

      .search-input {
        width: 100%;
        padding: 10px 16px;
        border: 1px solid $ios-border;
        border-radius: 8px;
        font-size: 14px;
        background: white;
        transition: border-color 0.2s ease;
        box-sizing: border-box;

        &:focus {
          outline: none;
          border-color: $ios-primary;
          box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.1);
        }

        &::placeholder {
          color: $ios-text-secondary;
        }
      }
    }

    .filter-buttons {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      width: 100%;
      justify-content: flex-start;

      .filter-btn {
        padding: 8px 16px;
        border: 1px solid $ios-border;
        border-radius: 20px;
        background: white;
        color: $ios-text-secondary;
        font-size: 14px;
        cursor: pointer;
        transition: all 0.2s ease;
        white-space: nowrap; // 防止按钮文字换行

        &:hover {
          background: #f8f9fa;
        }

        &.active {
          background: $ios-primary;
          color: white;
          border-color: $ios-primary;
        }

        &.pending.active {
          background: #ff9500;
          border-color: #ff9500;
        }

        &.overdue.active {
          background: #dc3545;
          border-color: #dc3545;
        }

        &.completed.active {
          background: #28a745;
          border-color: #28a745;
        }
      }
    }
  }

  // 结算列表
  .settlements-list {
    .list-header {
      display: grid;
      grid-template-columns: 2fr 1fr 1fr 1fr;
      gap: 16px;
      padding: 12px 16px;
      background: #f8f9fa;
      border-radius: 8px;
      font-weight: $ios-font-weight-semibold;
      color: $ios-text-secondary;
      font-size: 12px;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      margin-bottom: 8px;
    }

    .list-body {
      .settlement-item {
        display: grid;
        grid-template-columns: 2fr 1fr 1fr 1fr;
        gap: 16px;
        padding: 16px;
        border: 1px solid $ios-border;
        border-radius: 8px;
        margin-bottom: 8px;
        background: white;
        transition: all 0.2s ease;

        &:hover {
          box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
          transform: translateY(-1px);
        }

        &.overdue {
          border-left: 4px solid #dc3545;
          background: #fff5f5;
        }

        &.pending {
          border-left: 4px solid #ff9500;
        }

        &.completed {
          border-left: 4px solid #28a745;
          background: #f8fff9;
        }

        .col-project {
          .project-name {
            font-weight: $ios-font-weight-semibold;
            color: $ios-text-primary;
            margin-bottom: 4px;
          }

          .stage-name {
            font-size: 12px;
            color: $ios-text-secondary;
          }
        }

        .col-amount {
          .amount {
            font-weight: $ios-font-weight-bold;
            color: $ios-primary;
            font-size: 16px;
          }

          .percentage {
            font-size: 12px;
            color: $ios-text-secondary;
            margin-top: 2px;
          }
        }

        .col-status {
          .status-badge {
            display: inline-block;
            padding: 4px 8px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: $ios-font-weight-medium;

            &.pending {
              background: rgba(255, 149, 0, 0.1);
              color: #ff9500;
            }

            &.overdue {
              background: rgba(220, 53, 69, 0.1);
              color: #dc3545;
            }

            &.completed {
              background: rgba(40, 167, 69, 0.1);
              color: #28a745;
            }
          }

          .overdue-days {
            font-size: 11px;
            color: #dc3545;
            margin-top: 4px;
            font-weight: $ios-font-weight-medium;
          }
        }

        .col-date {
          text-align: right;

          .settled-date,
          .due-date {
            font-weight: $ios-font-weight-medium;
            color: $ios-text-primary;
          }

          .date-label {
            font-size: 11px;
            color: $ios-text-secondary;
            margin-top: 2px;
          }
        }
      }
    }
  }

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

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

    .empty-title {
      font-size: 16px;
      font-weight: $ios-font-weight-semibold;
      color: $ios-text-primary;
      margin-bottom: 8px;
    }

    .empty-desc {
      font-size: 14px;
      line-height: 1.4;
    }
  }
}

// 响应式设计
@media (max-width: 768px) {
  .settlement-card {
    .stats-overview .stats-grid {
      grid-template-columns: repeat(2, 1fr);
    }

    .filter-section {
      .filter-buttons {
        justify-content: center;
      }
    }

    .settlements-list {
      .list-header {
        display: none;
      }

      .list-body .settlement-item {
        grid-template-columns: 1fr;
        gap: 8px;

        .col-project,
        .col-amount,
        .col-status,
        .col-date {
          display: flex;
          justify-content: space-between;
          align-items: center;
        }
      }
    }
  }
}