@use '../../../shared/styles/_ios-theme.scss' as *;
@use 'sass:color';

.team-assignment-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;

  .modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
  }

  .modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
  }

  .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid $ios-border;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);

    .modal-title {
      font-size: 20px;
      font-weight: 600;
      color: $ios-text-primary;
      margin: 0;
    }

    .close-btn {
      appearance: none;
      border: none;
      background: none;
      color: $ios-text-secondary;
      cursor: pointer;
      padding: 8px;
      border-radius: 8px;
      transition: all 0.2s ease;

      &:hover {
        background: rgba(0, 0, 0, 0.05);
        color: $ios-text-primary;
      }
    }
  }

  .modal-body {
    padding: 24px;
    max-height: calc(90vh - 140px);
    overflow-y: auto;

    .assignment-form {
      .project-overview {
        margin-bottom: 32px;
        padding: 20px;
        background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
        border-radius: 12px;
        border: 1px solid $ios-border;

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

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

          .info-item {
            display: flex;
            align-items: center;

            .label {
              font-size: 14px;
              color: $ios-text-secondary;
              font-weight: 500;
              min-width: 80px;
            }

            .value {
              font-size: 14px;
              color: $ios-text-primary;
              font-weight: 500;
            }
          }
        }
      }

      .team-selection {
        h3 {
          font-size: 18px;
          font-weight: 600;
          color: $ios-text-primary;
          margin: 0 0 24px 0;
        }

        .role-section {
          margin-bottom: 32px;

          h4 {
            font-size: 16px;
            font-weight: 600;
            color: $ios-text-primary;
            margin: 0 0 16px 0;
            padding-left: 12px;
            border-left: 4px solid $ios-primary;
          }

          .member-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 16px;

            .member-card {
              position: relative;
              display: flex;
              align-items: center;
              padding: 16px;
              background: white;
              border: 2px solid $ios-border;
              border-radius: 12px;
              cursor: pointer;
              transition: all 0.3s ease;

              &:hover {
                transform: translateY(-2px);
                box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
                border-color: rgba($ios-primary, 0.3);
              }

              &.selected {
                border-color: $ios-primary;
                background: linear-gradient(135deg, rgba($ios-primary, 0.05) 0%, rgba($ios-primary, 0.02) 100%);
                box-shadow: 0 4px 20px rgba($ios-primary, 0.2);
              }

              .member-avatar {
                width: 48px;
                height: 48px;
                border-radius: 50%;
                overflow: hidden;
                margin-right: 16px;
                border: 2px solid $ios-border;

                img {
                  width: 100%;
                  height: 100%;
                  object-fit: cover;
                }
              }

              .member-info {
                flex: 1;

                .member-name {
                  font-size: 16px;
                  font-weight: 600;
                  color: $ios-text-primary;
                  margin-bottom: 4px;
                }

                .member-role {
                  font-size: 14px;
                  color: $ios-text-secondary;
                  margin-bottom: 6px;
                }

                .task-status {
                  font-size: 12px;
                  font-weight: 500;
                  padding: 4px 8px;
                  border-radius: 6px;
                  display: inline-block;

                  &.status-light {
                    background: rgba(52, 199, 89, 0.1);
                    color: #34c759;
                  }

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

                  &.status-heavy {
                    background: rgba(255, 59, 48, 0.1);
                    color: #ff3b30;
                  }
                }
              }

              .selected-indicator {
                position: absolute;
                top: 12px;
                right: 12px;
                width: 24px;
                height: 24px;
                background: $ios-primary;
                border-radius: 50%;
                display: flex;
                align-items: center;
                justify-content: center;
                color: white;
                font-size: 14px;
              }
            }
          }
        }
      }
    }
  }

  .modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid $ios-border;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);

    .cancel-btn {
      appearance: none;
      border: 1px solid $ios-border;
      background: white;
      color: $ios-text-secondary;
      padding: 12px 24px;
      border-radius: 8px;
      font-size: 14px;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.2s ease;

      &:hover {
        background: rgba(0, 0, 0, 0.05);
        color: $ios-text-primary;
      }
    }

    .confirm-btn {
      appearance: none;
      border: none;
      background: linear-gradient(135deg, $ios-primary 0%, color.adjust($ios-primary, $lightness: -10%) 100%);
      color: white;
      padding: 12px 24px;
      border-radius: 8px;
      font-size: 14px;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.2s ease;
      min-width: 100px;

      &:hover:not(:disabled) {
        transform: translateY(-1px);
        box-shadow: 0 4px 15px rgba($ios-primary, 0.3);
      }

      &:disabled {
        opacity: 0.5;
        cursor: not-allowed;
        transform: none;
        box-shadow: none;
      }
    }
  }
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

// 响应式设计
@media (max-width: 768px) {
  .team-assignment-modal {
    padding: 10px;

    .modal-content {
      max-width: 100%;
      max-height: 95vh;
    }

    .modal-body {
      padding: 16px;

      .assignment-form {
        .team-selection {
          .role-section {
            .member-grid {
              grid-template-columns: 1fr;
            }
          }
        }
      }
    }

    .modal-footer {
      padding: 16px;
      flex-direction: column;
      gap: 8px;

      .cancel-btn,
      .confirm-btn {
        width: 100%;
      }
    }
  }
}